Fix the wrong semantics of AntTaskTable#contains. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273834 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2000-2003 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -2105,8 +2105,8 @@ public class Project { | |||||
| return taskClass; | return taskClass; | ||||
| } | } | ||||
| public boolean contains( Object key ) { | |||||
| return get( key ) != null; | |||||
| public boolean containsKey(Object key) { | |||||
| return get(key) != null; | |||||
| } | } | ||||
| } | } | ||||
| @@ -61,6 +61,8 @@ import java.util.Enumeration; | |||||
| * | * | ||||
| * All operations that need access to the full list of objects | * All operations that need access to the full list of objects | ||||
| * will call initAll() first. Get and put are cheap. | * will call initAll() first. Get and put are cheap. | ||||
| * | |||||
| * @since Ant 1.6 | |||||
| */ | */ | ||||
| public class LazyHashtable extends Hashtable { | public class LazyHashtable extends Hashtable { | ||||
| protected boolean initAllDone=false; | protected boolean initAllDone=false; | ||||
| @@ -96,12 +98,19 @@ public class LazyHashtable extends Hashtable { | |||||
| public boolean contains( Object value ) { | public boolean contains( Object value ) { | ||||
| initAll(); | initAll(); | ||||
| return super.contains(value ); | |||||
| return super.contains(value); | |||||
| } | } | ||||
| public boolean containsValue( Object value ) { | |||||
| public boolean containsKey(Object value) { | |||||
| initAll(); | initAll(); | ||||
| return super.contains( value ); | |||||
| return super.containsKey(value); | |||||
| } | |||||
| /** | |||||
| * Delegates to {@link #contains contains}. | |||||
| */ | |||||
| public boolean containsValue( Object value ) { | |||||
| return contains(value); | |||||
| } | } | ||||
| public Enumeration keys() { | public Enumeration keys() { | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2000-2003 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -232,6 +232,14 @@ public class ProjectTest extends TestCase { | |||||
| assertSame(pfih, p.getInputHandler()); | assertSame(pfih, p.getInputHandler()); | ||||
| } | } | ||||
| public void testTaskDefinitionContainsKey() { | |||||
| assertTrue(p.getTaskDefinitions().containsKey("echo")); | |||||
| } | |||||
| public void testTaskDefinitionContains() { | |||||
| assertTrue(p.getTaskDefinitions().contains(org.apache.tools.ant.taskdefs.Echo.class)); | |||||
| } | |||||
| private class DummyTaskPrivate extends Task { | private class DummyTaskPrivate extends Task { | ||||
| public DummyTaskPrivate() {} | public DummyTaskPrivate() {} | ||||
| public void execute() {} | public void execute() {} | ||||