You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/12/18 16:08:46 UTC
svn commit: r488301 - in
/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap:
codec/ codec/bind/ codec/extended/operations/ codec/search/
codec/search/controls/ filter/ message/ util/
Author: elecharny
Date: Mon Dec 18 07:08:44 2006
New Revision: 488301
URL: http://svn.apache.org/viewvc?view=rev&rev=488301
Log:
Fixed warning by using generics
Asn1Object classes now extends AbstractAsn1Object
Modified:
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ManageDsaITControl.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/LdapAuthentication.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NestableDelegate.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/SpringClassUtils.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/Control.java Mon Dec 18 07:08:44 2006
@@ -23,6 +23,7 @@
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.Asn1Object;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
@@ -36,7 +37,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class Control extends Asn1Object
+public class Control extends AbstractAsn1Object
{
// ~ Instance fields
// ----------------------------------------------------------------------------
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessage.java Mon Dec 18 07:08:44 2006
@@ -20,6 +20,7 @@
package org.apache.directory.shared.ldap.codec;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.Asn1Object;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
@@ -59,7 +60,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class LdapMessage extends Asn1Object
+public class LdapMessage extends AbstractAsn1Object
{
// ~ Instance fields
// ----------------------------------------------------------------------------
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResult.java Mon Dec 18 07:08:44 2006
@@ -20,7 +20,7 @@
package org.apache.directory.shared.ldap.codec;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
@@ -42,7 +42,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class LdapResult extends Asn1Object
+public class LdapResult extends AbstractAsn1Object
{
// ~ Instance fields
// ----------------------------------------------------------------------------
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ManageDsaITControl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ManageDsaITControl.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ManageDsaITControl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ManageDsaITControl.java Mon Dec 18 07:08:44 2006
@@ -22,7 +22,7 @@
import java.nio.ByteBuffer;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.codec.EncoderException;
@@ -64,7 +64,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ManageDsaITControl extends Asn1Object
+public class ManageDsaITControl extends AbstractAsn1Object
{
private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate( 0 );
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java Mon Dec 18 07:08:44 2006
@@ -68,7 +68,6 @@
import org.apache.directory.shared.ldap.codec.search.controls.SubEntryControl;
import org.apache.directory.shared.ldap.codec.util.LdapURL;
import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
-import org.apache.directory.shared.ldap.filter.AbstractExprNode;
import org.apache.directory.shared.ldap.filter.AssertionEnum;
import org.apache.directory.shared.ldap.filter.BranchNode;
import org.apache.directory.shared.ldap.filter.ExprNode;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/LdapAuthentication.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/LdapAuthentication.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/LdapAuthentication.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/LdapAuthentication.java Mon Dec 18 07:08:44 2006
@@ -20,7 +20,7 @@
package org.apache.directory.shared.ldap.codec.bind;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
/**
@@ -30,6 +30,6 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public abstract class LdapAuthentication extends Asn1Object
+public abstract class LdapAuthentication extends AbstractAsn1Object
{
}
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java Mon Dec 18 07:08:44 2006
@@ -21,7 +21,7 @@
package org.apache.directory.shared.ldap.codec.extended.operations;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
/**
@@ -29,7 +29,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public abstract class GracefulAction extends Asn1Object
+public abstract class GracefulAction extends AbstractAsn1Object
{
/** Undetermined value used for timeOffline */
public static final int UNDETERMINED = 0;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedure.java Mon Dec 18 07:08:44 2006
@@ -28,7 +28,7 @@
import java.util.LinkedList;
import java.util.List;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
@@ -41,7 +41,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class StoredProcedure extends Asn1Object
+public class StoredProcedure extends AbstractAsn1Object
{
private String language;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/StoredProcedureCall.java Mon Dec 18 07:08:44 2006
@@ -24,7 +24,7 @@
import java.nio.ByteBuffer;
import java.util.List;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.codec.EncoderException;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -34,7 +34,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class StoredProcedureCall extends Asn1Object
+public class StoredProcedureCall extends AbstractAsn1Object
{
private String name;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/ConnectorFilter.java Mon Dec 18 07:08:44 2006
@@ -66,7 +66,7 @@
*
* @param filter The filter to add
*/
- public void addFilter( Filter filter ) throws DecoderException
+ public void addFilter( Filter filter ) throws DecoderException
{
if ( filterSet == null )
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/Filter.java Mon Dec 18 07:08:44 2006
@@ -20,7 +20,7 @@
package org.apache.directory.shared.ldap.codec.search;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
/**
@@ -30,7 +30,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public abstract class Filter extends Asn1Object
+public abstract class Filter extends AbstractAsn1Object
{
/**
* The constructor.
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/EntryChangeControl.java Mon Dec 18 07:08:44 2006
@@ -22,7 +22,7 @@
import java.nio.ByteBuffer;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
@@ -78,7 +78,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class EntryChangeControl extends Asn1Object
+public class EntryChangeControl extends AbstractAsn1Object
{
public static final int UNDEFINED_CHANGE_NUMBER = -1;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/PSearchControl.java Mon Dec 18 07:08:44 2006
@@ -22,7 +22,7 @@
import java.nio.ByteBuffer;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
import org.apache.directory.shared.asn1.ber.tlv.Value;
@@ -34,7 +34,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class PSearchControl extends Asn1Object
+public class PSearchControl extends AbstractAsn1Object
{
/**
* If changesOnly is TRUE, the server MUST NOT return any existing entries
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/SubEntryControl.java Mon Dec 18 07:08:44 2006
@@ -22,7 +22,7 @@
import java.nio.ByteBuffer;
-import org.apache.directory.shared.asn1.Asn1Object;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
import org.apache.directory.shared.asn1.ber.tlv.Value;
import org.apache.directory.shared.asn1.codec.EncoderException;
@@ -33,7 +33,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SubEntryControl extends Asn1Object
+public class SubEntryControl extends AbstractAsn1Object
{
private boolean visibility = false;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/BranchNormalizedVisitor.java Mon Dec 18 07:08:44 2006
@@ -21,8 +21,8 @@
import java.util.List;
+import java.util.Set;
import java.util.TreeSet;
-import java.util.ArrayList;
import java.util.Comparator;
import java.io.IOException;
import java.text.ParseException;
@@ -58,16 +58,14 @@
return;
}
- Comparator nodeComparator = new NodeComparator();
+ Comparator<ExprNode> nodeComparator = new NodeComparator();
- TreeSet set = new TreeSet( nodeComparator );
+ Set<ExprNode> set = new TreeSet<ExprNode>( nodeComparator );
List<ExprNode> children = branch.getChildren();
- for ( int ii = 0; ii < children.size(); ii++ )
+ for ( ExprNode child:branch.getChildren() )
{
- ExprNode child = ( ExprNode ) children.get( ii );
-
if ( !child.isLeaf() )
{
visit( child );
@@ -148,21 +146,17 @@
return normalized.toString().trim();
}
- class NodeComparator implements Comparator
+ class NodeComparator implements Comparator<ExprNode>
{
- public int compare( Object o1, Object o2 )
+ public int compare( ExprNode o1, ExprNode o2 )
{
StringBuffer buf = new StringBuffer();
- ExprNode n1 = ( ExprNode ) o1;
-
- ExprNode n2 = ( ExprNode ) o2;
-
buf.setLength( 0 );
String s1 = null;
- n1.printToBuffer( buf );
+ o1.printToBuffer( buf );
s1 = buf.toString();
@@ -170,7 +164,7 @@
String s2 = null;
- n2.printToBuffer( buf );
+ o2.printToBuffer( buf );
s2 = buf.toString();
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributeImpl.java Mon Dec 18 07:08:44 2006
@@ -51,13 +51,13 @@
private final String upId;
/** In case we have only one value, just use this container */
- private Object value;
+ Object value;
/** the list of attribute values */
- private List list;
+ private List<Object> list;
/** The number of values stored */
- private int size = 0;
+ int size = 0;
// ------------------------------------------------------------------------
@@ -124,7 +124,7 @@
* @param list
* the list of values to start with
*/
- private LockableAttributeImpl(final String id, final List list)
+ private LockableAttributeImpl(final String id, final List<Object> list)
{
upId = id;
this.list = list;
@@ -142,11 +142,11 @@
*
* @return the Iterator wrapped as a NamingEnumberation.
*/
- public NamingEnumeration getAll()
+ public NamingEnumeration<Object> getAll()
{
if ( size < 2 )
{
- return new IteratorNamingEnumeration( new Iterator()
+ return new IteratorNamingEnumeration( new Iterator<Object>()
{
private boolean done = (size != 0);
@@ -266,7 +266,7 @@
case 1 :
exists = value.equals( attrVal );
- list = new ArrayList();
+ list = new ArrayList<Object>();
list.add( value );
list.add( attrVal );
size++;
@@ -380,7 +380,7 @@
return new LockableAttributeImpl( upId, value );
default :
- return new LockableAttributeImpl( upId, (List)((ArrayList)list).clone() );
+ return new LockableAttributeImpl( upId, (List<Object>)((ArrayList<Object>)list).clone() );
}
}
@@ -467,7 +467,7 @@
return;
case 1 :
- list = new ArrayList();
+ list = new ArrayList<Object>();
if ( index == 0 )
{
@@ -519,7 +519,7 @@
}
else
{
- list = new ArrayList();
+ list = new ArrayList<Object>();
list.add( value );
list.add( attrVal );
size = 2;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/LockableAttributesImpl.java Mon Dec 18 07:08:44 2006
@@ -52,10 +52,10 @@
{
static transient final long serialVersionUID = 1L;
- private String upId;
- private Attribute attribute;
+ String upId;
+ Attribute attribute;
- private Holder( String upId, Attribute attribute )
+ Holder( String upId, Attribute attribute )
{
this.upId = upId;
this.attribute = attribute;
@@ -143,7 +143,7 @@
}
/** Cache of lowercase id Strings to mixed cased user provided String ids */
- private Map keyMap;
+ Map<String, Holder> keyMap;
// ------------------------------------------------------------------------
@@ -155,7 +155,7 @@
*/
public LockableAttributesImpl()
{
- keyMap = new HashMap();
+ keyMap = new HashMap<String, Holder>();
}
// ------------------------------------------------------------------------
@@ -283,7 +283,7 @@
{
if ( attrId != null )
{
- Holder holder = (Holder)keyMap.get( StringTools.toLowerCase( attrId ) );
+ Holder holder = keyMap.get( StringTools.toLowerCase( attrId ) );
return holder != null ? holder.attribute : null;
}
else
@@ -303,7 +303,7 @@
* If attribute set has zero attributes, an empty enumeration is
* returned.
*/
- public NamingEnumeration getAll()
+ public NamingEnumeration<Attribute> getAll()
{
return new IteratorNamingEnumeration( new AttributeIterator( this ) );
}
@@ -319,7 +319,7 @@
* attribute set has zero attributes, an empty enumeration is
* returned.
*/
- public NamingEnumeration getIDs()
+ public NamingEnumeration<String> getIDs()
{
String[] ids = new String[keyMap.size()];
@@ -379,7 +379,7 @@
if ( keyMap.containsKey( key ) )
{
- old = (Attribute)((Holder)keyMap.remove( key )).attribute;
+ old = keyMap.remove( key ).attribute;
}
else
{
@@ -429,7 +429,7 @@
if ( keyMap.containsKey( key ) )
{
- Holder holder = (Holder)keyMap.remove( key );
+ Holder holder = keyMap.remove( key );
if ( holder != null )
{
@@ -453,15 +453,12 @@
{
LockableAttributesImpl clone = (LockableAttributesImpl)super.clone();
- clone.keyMap = (Map)((HashMap)keyMap).clone();
+ clone.keyMap = (Map<String, Holder>)(((HashMap<String, Holder>)keyMap).clone());
- Iterator keys = keyMap.keySet().iterator();
-
- while ( keys.hasNext() )
+ for ( String key:keyMap.keySet() )
{
- String key = (String)keys.next();
- Holder holder = (Holder)keyMap.get( key );
- clone.keyMap.put( key, holder.clone() );
+ Holder holder = keyMap.get( key );
+ clone.keyMap.put( key, (Holder)holder.clone() );
}
return clone;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java Mon Dec 18 07:08:44 2006
@@ -36,7 +36,7 @@
static final long serialVersionUID = 2638820668325359096L;
/** Sequence of LDAPUrls composing this Referral */
- private final List urls = new ArrayList();
+ private final List<String> urls = new ArrayList<String>();
// ------------------------------------------------------------------------
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java Mon Dec 18 07:08:44 2006
@@ -1137,7 +1137,7 @@
set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
ADD_CODES = Collections.unmodifiableSet( set );
- };
+ }
/**
* A set of result code enumerations that may result from delete operations.
@@ -1184,7 +1184,7 @@
set.add( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
set.add( ResultCodeEnum.UNAVAILABLE_CRITICAL_EXTENSION );
DELETE_CODES = Collections.unmodifiableSet( set );
- };
+ }
/**
* A set of result code enumerations resulting from modifyDn operations. The
@@ -1970,7 +1970,7 @@
if ( set.size() == 1 )
{
- return ( ResultCodeEnum ) set.iterator().next();
+ return set.iterator().next();
}
if ( type == null )
@@ -1992,7 +1992,7 @@
switch ( type )
{
case ABANDON_REQUEST :
- return ( ResultCodeEnum ) set.iterator().next();
+ return set.iterator().next();
case ADD_REQUEST :
candidates = intersection( set, ADD_CODES );
@@ -2067,7 +2067,7 @@
break;
case UNBIND_REQUEST :
- return ( ResultCodeEnum ) set.iterator().next();
+ return set.iterator().next();
}
// we don't want any codes that do not have anything to do w/ errors
@@ -2078,7 +2078,7 @@
return ResultCodeEnum.OTHER;
}
- return ( ResultCodeEnum ) candidates.iterator().next();
+ return candidates.iterator().next();
}
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/ExceptionUtils.java Mon Dec 18 07:08:44 2006
@@ -76,7 +76,7 @@
Method getCauseMethod;
try
{
- getCauseMethod = Throwable.class.getMethod( "getCause", null );
+ getCauseMethod = Throwable.class.getMethod( "getCause", (Class[])null );
}
catch ( Exception e )
{
@@ -128,9 +128,9 @@
{
if ( isNotEmpty( methodName ) )
{
- List list = new ArrayList( Arrays.asList( CAUSE_METHOD_NAMES ) );
+ List<String> list = new ArrayList<String>( Arrays.asList( CAUSE_METHOD_NAMES ) );
list.add( methodName );
- CAUSE_METHOD_NAMES = ( String[] ) list.toArray( new String[list.size()] );
+ CAUSE_METHOD_NAMES = list.toArray( new String[list.size()] );
}
}
@@ -323,7 +323,7 @@
Method method = null;
try
{
- method = throwable.getClass().getMethod( methodName, null );
+ method = throwable.getClass().getMethod( methodName, (Class[])null );
}
catch ( NoSuchMethodException ignored )
{
@@ -458,7 +458,7 @@
{
try
{
- Method method = cls.getMethod( CAUSE_METHOD_NAMES[i], null );
+ Method method = cls.getMethod( CAUSE_METHOD_NAMES[i], (Class[])null );
if ( method != null && Throwable.class.isAssignableFrom( method.getReturnType() ) )
{
return true;
@@ -539,13 +539,15 @@
*/
public static Throwable[] getThrowables( Throwable throwable )
{
- List list = new ArrayList();
+ List<Throwable> list = new ArrayList<Throwable>();
+
while ( throwable != null )
{
list.add( throwable );
throwable = ExceptionUtils.getCause( throwable );
}
- return ( Throwable[] ) list.toArray( new Throwable[list.size()] );
+
+ return list.toArray( new Throwable[list.size()] );
}
@@ -758,13 +760,16 @@
{
return ArrayUtils.EMPTY_STRING_ARRAY;
}
+
Throwable throwables[] = getThrowables( throwable );
int count = throwables.length;
- ArrayList frames = new ArrayList();
- List nextTrace = getStackFrameList( throwables[count - 1] );
+ List<String> frames = new ArrayList<String>();
+ List<String> nextTrace = getStackFrameList( throwables[count - 1] );
+
for ( int i = count; --i >= 0; )
{
- List trace = nextTrace;
+ List<String> trace = nextTrace;
+
if ( i != 0 )
{
nextTrace = getStackFrameList( throwables[i - 1] );
@@ -783,7 +788,7 @@
frames.add( trace.get( j ) );
}
}
- return ( String[] ) frames.toArray( new String[0] );
+ return frames.toArray( new String[0] );
}
@@ -902,12 +907,14 @@
{
String linebreak = SystemUtils.LINE_SEPARATOR;
StringTokenizer frames = new StringTokenizer( stackTrace, linebreak );
- List list = new LinkedList();
+ List<String> list = new LinkedList<String>();
+
while ( frames.hasMoreTokens() )
{
list.add( frames.nextToken() );
}
- return ( String[] ) list.toArray( new String[list.size()] );
+
+ return list.toArray( new String[list.size()] );
}
@@ -927,18 +934,20 @@
* is any throwable
* @return List of stack frames
*/
- static List getStackFrameList( Throwable t )
+ static List<String> getStackFrameList( Throwable t )
{
String stackTrace = getStackTrace( t );
String linebreak = SystemUtils.LINE_SEPARATOR;
StringTokenizer frames = new StringTokenizer( stackTrace, linebreak );
- List list = new LinkedList();
+ List<String> list = new LinkedList<String>();
boolean traceStarted = false;
+
while ( frames.hasMoreTokens() )
{
String token = frames.nextToken();
// Determine if the line starts with <whitespace>at
int at = token.indexOf( "at" );
+
if ( at != -1 && token.substring( 0, at ).trim().length() == 0 )
{
traceStarted = true;
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java Mon Dec 18 07:08:44 2006
@@ -24,6 +24,7 @@
import javax.naming.*;
import java.util.ArrayList;
+import java.util.List;
/**
@@ -459,7 +460,7 @@
public static String[] getCompositeComponents( String compositeNameComponent ) throws NamingException
{
int lastIndex = compositeNameComponent.length() - 1;
- ArrayList comps = new ArrayList();
+ List<String> comps = new ArrayList<String>();
for ( int ii = compositeNameComponent.length() - 1; ii >= 0; ii-- )
{
@@ -470,6 +471,7 @@
throw new NamingException( "invalid name - a name cannot start with a '+': "
+ compositeNameComponent );
}
+
if ( compositeNameComponent.charAt( ii - 1 ) != '\\' )
{
if ( lastIndex == compositeNameComponent.length() - 1 )
@@ -504,7 +506,7 @@
comps.add( compositeNameComponent );
}
- return ( String[] ) comps.toArray( EMPTY_STRING_ARRAY );
+ return comps.toArray( EMPTY_STRING_ARRAY );
}
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NestableDelegate.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NestableDelegate.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NestableDelegate.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/NestableDelegate.java Mon Dec 18 07:08:44 2006
@@ -341,7 +341,7 @@
}
// generating the nested stack trace
- List stacks = new ArrayList();
+ List<String[]> stacks = new ArrayList<String[]>();
while ( throwable != null )
{
String[] st = getStackFrames( throwable );
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java Mon Dec 18 07:08:44 2006
@@ -660,6 +660,7 @@
}
String[] items = props.getProperty( key ).trim().split( delimiter );
+
for ( int ii = 0; ii < items.length; ii++ )
{
values.add( items[ii] );
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/SpringClassUtils.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/SpringClassUtils.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/SpringClassUtils.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/SpringClassUtils.java Mon Dec 18 07:08:44 2006
@@ -20,6 +20,7 @@
package org.apache.directory.shared.ldap.util;
+
import java.beans.Introspector;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
@@ -27,6 +28,7 @@
import java.util.HashSet;
import java.util.Set;
+
/**
* Miscellaneous class utility methods. Mainly for internal use within the
* framework; consider Jakarta's Commons Lang for a more comprehensive suite
@@ -34,322 +36,390 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public abstract class SpringClassUtils {
+public abstract class SpringClassUtils
+{
+
+ /** Suffix for array class names */
+ public static final String ARRAY_SUFFIX = "[]";
+
+ /** All primitive classes */
+ private static Class[] PRIMITIVE_CLASSES =
+ { boolean.class, byte.class, char.class, short.class, int.class, long.class, float.class, double.class };
+
+ /** The package separator character '.' */
+ private static final char PACKAGE_SEPARATOR_CHAR = '.';
+
+ /** The inner class separator character '$' */
+ private static final char INNER_CLASS_SEPARATOR_CHAR = '$';
+
+ /** The CGLIB class separator character "$$" */
+ private static final String CGLIB_CLASS_SEPARATOR_CHAR = "$$";
+
+
+ /**
+ * Return a default ClassLoader to use (never <code>null</code>).
+ * Returns the thread context ClassLoader, if available.
+ * The ClassLoader that loaded the ClassUtils class will be used as fallback.
+ * <p>Call this method if you intend to use the thread context ClassLoader
+ * in a scenario where you absolutely need a non-null ClassLoader reference:
+ * for example, for class path resource loading (but not necessarily for
+ * <code>Class.forName</code>, which accepts a <code>null</code> ClassLoader
+ * reference as well).
+ * @see java.lang.Thread#getContextClassLoader()
+ */
+ public static ClassLoader getDefaultClassLoader()
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if ( cl == null )
+ {
+ // No thread context class loader -> use class loader of this class.
+ cl = SpringClassUtils.class.getClassLoader();
+ }
+ return cl;
+ }
+
+
+ /**
+ * Replacement for <code>Class.forName()</code> that also returns Class instances
+ * for primitives (like "int") and array class names (like "String[]").
+ * <p>Always uses the thread context class loader.
+ * @param name the name of the Class
+ * @return Class instance for the supplied name
+ * @see java.lang.Class#forName(String, boolean, ClassLoader)
+ * @see java.lang.Thread#getContextClassLoader()
+ */
+ public static Class forName( String name ) throws ClassNotFoundException
+ {
+ return forName( name, Thread.currentThread().getContextClassLoader() );
+ }
+
+
+ /**
+ * Replacement for <code>Class.forName()</code> that also returns Class instances
+ * for primitives (like "int") and array class names (like "String[]").
+ * @param name the name of the Class
+ * @param classLoader the class loader to use
+ * @return Class instance for the supplied name
+ * @see java.lang.Class#forName(String, boolean, ClassLoader)
+ * @see java.lang.Thread#getContextClassLoader()
+ */
+ public static Class forName( String name, ClassLoader classLoader ) throws ClassNotFoundException
+ {
+ Class clazz = resolvePrimitiveClassName( name );
+ if ( clazz != null )
+ {
+ return clazz;
+ }
+ if ( name.endsWith( ARRAY_SUFFIX ) )
+ {
+ // special handling for array class names
+ String elementClassName = name.substring( 0, name.length() - ARRAY_SUFFIX.length() );
+ Class elementClass = SpringClassUtils.forName( elementClassName, classLoader );
+ return Array.newInstance( elementClass, 0 ).getClass();
+ }
+ return Class.forName( name, true, classLoader );
+ }
+
+
+ /**
+ * Resolve the given class name as primitive class, if appropriate.
+ * @param name the name of the potentially primitive class
+ * @return the primitive class, or <code>null</code> if the name does not denote
+ * a primitive class
+ */
+ public static Class resolvePrimitiveClassName( String name )
+ {
+ // Most class names will be quite long, considering that they
+ // SHOULD sit in a package, so a length check is worthwhile.
+ if ( name.length() <= 8 )
+ {
+ // could be a primitive - likely
+ for ( int i = 0; i < PRIMITIVE_CLASSES.length; i++ )
+ {
+ Class clazz = PRIMITIVE_CLASSES[i];
+ if ( clazz.getName().equals( name ) )
+ {
+ return clazz;
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Return the short string name of a Java class in decapitalized
+ * JavaBeans property format.
+ * @param clazz the class
+ * @return the short name rendered in a standard JavaBeans property format
+ * @see java.beans.Introspector#decapitalize(String)
+ */
+ public static String getShortNameAsProperty( Class clazz )
+ {
+ return Introspector.decapitalize( getShortName( clazz ) );
+ }
+
+
+ /**
+ * Get the class name without the qualified package name.
+ * @param clazz the class to get the short name for
+ * @return the class name of the class without the package name
+ * @throws IllegalArgumentException if the class is null
+ */
+ public static String getShortName( Class clazz )
+ {
+ return getShortName( clazz.getName() );
+ }
+
+
+ /**
+ * Get the class name without the qualified package name.
+ * @param className the className to get the short name for
+ * @return the class name of the class without the package name
+ * @throws IllegalArgumentException if the className is empty
+ */
+ public static String getShortName( String className )
+ {
+ //Assert.hasLength(className, "class name must not be empty");
+ int lastDotIndex = className.lastIndexOf( PACKAGE_SEPARATOR_CHAR );
+ int nameEndIndex = className.indexOf( CGLIB_CLASS_SEPARATOR_CHAR );
+ if ( nameEndIndex == -1 )
+ {
+ nameEndIndex = className.length();
+ }
+ String shortName = className.substring( lastDotIndex + 1, nameEndIndex );
+ shortName = shortName.replace( INNER_CLASS_SEPARATOR_CHAR, PACKAGE_SEPARATOR_CHAR );
+ return shortName;
+ }
+
+
+ /**
+ * Return the qualified name of the given method, consisting of
+ * fully qualified interface/class name + "." + method name.
+ * @param method the method
+ * @return the qualified name of the method
+ */
+ public static String getQualifiedMethodName( Method method )
+ {
+ //Assert.notNull(method, "Method must not be empty");
+ return method.getDeclaringClass().getName() + "." + method.getName();
+ }
+
+
+ /**
+ * Determine whether the given class has a method with the given signature.
+ * Essentially translates <code>NoSuchMethodException</code> to "false".
+ * @param clazz the clazz to analyze
+ * @param methodName the name of the method
+ * @param paramTypes the parameter types of the method
+ */
+ public static boolean hasMethod( Class clazz, String methodName, Class[] paramTypes )
+ {
+ try
+ {
+ clazz.getMethod( methodName, paramTypes );
+ return true;
+ }
+ catch ( NoSuchMethodException ex )
+ {
+ return false;
+ }
+ }
+
+
+ /**
+ * Return the number of methods with a given name (with any argument types),
+ * for the given class and/or its superclasses. Includes non-public methods.
+ * @param clazz the clazz to check
+ * @param methodName the name of the method
+ * @return the number of methods with the given name
+ */
+ public static int getMethodCountForName( Class clazz, String methodName )
+ {
+ int count = 0;
+ do
+ {
+ for ( int i = 0; i < clazz.getDeclaredMethods().length; i++ )
+ {
+ Method method = clazz.getDeclaredMethods()[i];
+ if ( methodName.equals( method.getName() ) )
+ {
+ count++;
+ }
+ }
+ clazz = clazz.getSuperclass();
+ }
+ while ( clazz != null );
+ return count;
+ }
+
+
+ /**
+ * Does the given class and/or its superclasses at least have one or more
+ * methods (with any argument types)? Includes non-public methods.
+ * @param clazz the clazz to check
+ * @param methodName the name of the method
+ * @return whether there is at least one method with the given name
+ */
+ public static boolean hasAtLeastOneMethodWithName( Class clazz, String methodName )
+ {
+ do
+ {
+ for ( int i = 0; i < clazz.getDeclaredMethods().length; i++ )
+ {
+ Method method = clazz.getDeclaredMethods()[i];
+
+ if ( methodName.equals( method.getName() ) )
+ {
+ return true;
+ }
+ }
+ clazz = clazz.getSuperclass();
+ }
+ while ( clazz != null );
+
+ return false;
+ }
+
+
+ /**
+ * Return a static method of a class.
+ * @param methodName the static method name
+ * @param clazz the class which defines the method
+ * @param args the parameter types to the method
+ * @return the static method, or <code>null</code> if no static method was found
+ * @throws IllegalArgumentException if the method name is blank or the clazz is null
+ */
+ public static Method getStaticMethod( Class clazz, String methodName, Class[] args )
+ {
+ try
+ {
+ Method method = clazz.getDeclaredMethod( methodName, args );
+
+ if ( ( method.getModifiers() & Modifier.STATIC ) != 0 )
+ {
+ return method;
+ }
+ }
+ catch ( NoSuchMethodException ex )
+ {
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Return a path suitable for use with ClassLoader.getResource (also
+ * suitable for use with Class.getResource by prepending a slash ('/') to
+ * the return value. Built by taking the package of the specified class
+ * file, converting all dots ('.') to slashes ('/'), adding a trailing slash
+ * if necesssary, and concatenating the specified resource name to this.
+ * <br/>As such, this function may be used to build a path suitable for
+ * loading a resource file that is in the same package as a class file,
+ * although {link org.springframework.core.io.ClassPathResource} is usually
+ * even more convenient.
+ * @param clazz the Class whose package will be used as the base
+ * @param resourceName the resource name to append. A leading slash is optional.
+ * @return the built-up resource path
+ * @see java.lang.ClassLoader#getResource
+ * @see java.lang.Class#getResource
+ */
+ public static String addResourcePathToPackagePath( Class clazz, String resourceName )
+ {
+ if ( !resourceName.startsWith( "/" ) )
+ {
+ return classPackageAsResourcePath( clazz ) + "/" + resourceName;
+ }
+
+ return classPackageAsResourcePath( clazz ) + resourceName;
+ }
+
+
+ /**
+ * Given an input class object, return a string which consists of the
+ * class's package name as a pathname, i.e., all dots ('.') are replaced by
+ * slashes ('/'). Neither a leading nor trailing slash is added. The result
+ * could be concatenated with a slash and the name of a resource, and fed
+ * directly to ClassLoader.getResource(). For it to be fed to Class.getResource,
+ * a leading slash would also have to be prepended to the return value.
+ * @param clazz the input class. A null value or the default (empty) package
+ * will result in an empty string ("") being returned.
+ * @return a path which represents the package name
+ * @see java.lang.ClassLoader#getResource
+ * @see java.lang.Class#getResource
+ */
+ public static String classPackageAsResourcePath( Class clazz )
+ {
+ if ( clazz == null || clazz.getPackage() == null )
+ {
+ return "";
+ }
+
+ return clazz.getPackage().getName().replace( '.', '/' );
+ }
+
+
+ /**
+ * Return all interfaces that the given object implements as array,
+ * including ones implemented by superclasses.
+ * @param object the object to analyse for interfaces
+ * @return all interfaces that the given object implements as array
+ */
+ public static Class[] getAllInterfaces( Object object )
+ {
+ Set<Class> interfaces = getAllInterfacesAsSet( object );
+ return interfaces.toArray( new Class[interfaces.size()] );
+ }
+
+
+ /**
+ * Return all interfaces that the given class implements as array,
+ * including ones implemented by superclasses.
+ * @param clazz the class to analyse for interfaces
+ * @return all interfaces that the given object implements as array
+ */
+ public static Class[] getAllInterfacesForClass( Class clazz )
+ {
+ Set<Class> interfaces = getAllInterfacesForClassAsSet( clazz );
+ return interfaces.toArray( new Class[interfaces.size()] );
+ }
+
+
+ /**
+ * Return all interfaces that the given object implements as List,
+ * including ones implemented by superclasses.
+ * @param object the object to analyse for interfaces
+ * @return all interfaces that the given object implements as List
+ */
+ public static Set<Class> getAllInterfacesAsSet( Object object )
+ {
+ return getAllInterfacesForClassAsSet( object.getClass() );
+ }
+
+
+ /**
+ * Return all interfaces that the given class implements as Set,
+ * including ones implemented by superclasses.
+ * @param clazz the class to analyse for interfaces
+ * @return all interfaces that the given object implements as Set
+ */
+ public static Set<Class> getAllInterfacesForClassAsSet( Class clazz )
+ {
+ Set<Class> interfaces = new HashSet<Class>();
+
+ while ( clazz != null )
+ {
+ for ( int i = 0; i < clazz.getInterfaces().length; i++ )
+ {
+ Class ifc = clazz.getInterfaces()[i];
+ interfaces.add( ifc );
+ }
- /** Suffix for array class names */
- public static final String ARRAY_SUFFIX = "[]";
+ clazz = clazz.getSuperclass();
+ }
- /** All primitive classes */
- private static Class[] PRIMITIVE_CLASSES = {
- boolean.class, byte.class, char.class, short.class, int.class, long.class, float.class, double.class};
-
- /** The package separator character '.' */
- private static final char PACKAGE_SEPARATOR_CHAR = '.';
-
- /** The inner class separator character '$' */
- private static final char INNER_CLASS_SEPARATOR_CHAR = '$';
-
- /** The CGLIB class separator character "$$" */
- private static final String CGLIB_CLASS_SEPARATOR_CHAR = "$$";
-
-
- /**
- * Return a default ClassLoader to use (never <code>null</code>).
- * Returns the thread context ClassLoader, if available.
- * The ClassLoader that loaded the ClassUtils class will be used as fallback.
- * <p>Call this method if you intend to use the thread context ClassLoader
- * in a scenario where you absolutely need a non-null ClassLoader reference:
- * for example, for class path resource loading (but not necessarily for
- * <code>Class.forName</code>, which accepts a <code>null</code> ClassLoader
- * reference as well).
- * @see java.lang.Thread#getContextClassLoader()
- */
- public static ClassLoader getDefaultClassLoader() {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- // No thread context class loader -> use class loader of this class.
- cl = SpringClassUtils.class.getClassLoader();
- }
- return cl;
- }
-
- /**
- * Replacement for <code>Class.forName()</code> that also returns Class instances
- * for primitives (like "int") and array class names (like "String[]").
- * <p>Always uses the thread context class loader.
- * @param name the name of the Class
- * @return Class instance for the supplied name
- * @see java.lang.Class#forName(String, boolean, ClassLoader)
- * @see java.lang.Thread#getContextClassLoader()
- */
- public static Class forName(String name) throws ClassNotFoundException {
- return forName(name, Thread.currentThread().getContextClassLoader());
- }
-
- /**
- * Replacement for <code>Class.forName()</code> that also returns Class instances
- * for primitives (like "int") and array class names (like "String[]").
- * @param name the name of the Class
- * @param classLoader the class loader to use
- * @return Class instance for the supplied name
- * @see java.lang.Class#forName(String, boolean, ClassLoader)
- * @see java.lang.Thread#getContextClassLoader()
- */
- public static Class forName(String name, ClassLoader classLoader) throws ClassNotFoundException {
- Class clazz = resolvePrimitiveClassName(name);
- if (clazz != null) {
- return clazz;
- }
- if (name.endsWith(ARRAY_SUFFIX)) {
- // special handling for array class names
- String elementClassName = name.substring(0, name.length() - ARRAY_SUFFIX.length());
- Class elementClass = SpringClassUtils.forName(elementClassName, classLoader);
- return Array.newInstance(elementClass, 0).getClass();
- }
- return Class.forName(name, true, classLoader);
- }
-
- /**
- * Resolve the given class name as primitive class, if appropriate.
- * @param name the name of the potentially primitive class
- * @return the primitive class, or <code>null</code> if the name does not denote
- * a primitive class
- */
- public static Class resolvePrimitiveClassName(String name) {
- // Most class names will be quite long, considering that they
- // SHOULD sit in a package, so a length check is worthwhile.
- if (name.length() <= 8) {
- // could be a primitive - likely
- for (int i = 0; i < PRIMITIVE_CLASSES.length; i++) {
- Class clazz = PRIMITIVE_CLASSES[i];
- if (clazz.getName().equals(name)) {
- return clazz;
- }
- }
- }
- return null;
- }
-
- /**
- * Return the short string name of a Java class in decapitalized
- * JavaBeans property format.
- * @param clazz the class
- * @return the short name rendered in a standard JavaBeans property format
- * @see java.beans.Introspector#decapitalize(String)
- */
- public static String getShortNameAsProperty(Class clazz) {
- return Introspector.decapitalize(getShortName(clazz));
- }
-
- /**
- * Get the class name without the qualified package name.
- * @param clazz the class to get the short name for
- * @return the class name of the class without the package name
- * @throws IllegalArgumentException if the class is null
- */
- public static String getShortName(Class clazz) {
- return getShortName(clazz.getName());
- }
-
- /**
- * Get the class name without the qualified package name.
- * @param className the className to get the short name for
- * @return the class name of the class without the package name
- * @throws IllegalArgumentException if the className is empty
- */
- public static String getShortName(String className) {
- //Assert.hasLength(className, "class name must not be empty");
- int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
- int nameEndIndex = className.indexOf(CGLIB_CLASS_SEPARATOR_CHAR);
- if (nameEndIndex == -1) {
- nameEndIndex = className.length();
- }
- String shortName = className.substring(lastDotIndex + 1, nameEndIndex);
- shortName = shortName.replace(INNER_CLASS_SEPARATOR_CHAR, PACKAGE_SEPARATOR_CHAR);
- return shortName;
- }
-
- /**
- * Return the qualified name of the given method, consisting of
- * fully qualified interface/class name + "." + method name.
- * @param method the method
- * @return the qualified name of the method
- */
- public static String getQualifiedMethodName(Method method) {
- //Assert.notNull(method, "Method must not be empty");
- return method.getDeclaringClass().getName() + "." + method.getName();
- }
-
- /**
- * Determine whether the given class has a method with the given signature.
- * Essentially translates <code>NoSuchMethodException</code> to "false".
- * @param clazz the clazz to analyze
- * @param methodName the name of the method
- * @param paramTypes the parameter types of the method
- */
- public static boolean hasMethod(Class clazz, String methodName, Class[] paramTypes) {
- try {
- clazz.getMethod(methodName, paramTypes);
- return true;
- }
- catch (NoSuchMethodException ex) {
- return false;
- }
- }
-
- /**
- * Return the number of methods with a given name (with any argument types),
- * for the given class and/or its superclasses. Includes non-public methods.
- * @param clazz the clazz to check
- * @param methodName the name of the method
- * @return the number of methods with the given name
- */
- public static int getMethodCountForName(Class clazz, String methodName) {
- int count = 0;
- do {
- for (int i = 0; i < clazz.getDeclaredMethods().length; i++) {
- Method method = clazz.getDeclaredMethods()[i];
- if (methodName.equals(method.getName())) {
- count++;
- }
- }
- clazz = clazz.getSuperclass();
- }
- while (clazz != null);
- return count;
- }
-
- /**
- * Does the given class and/or its superclasses at least have one or more
- * methods (with any argument types)? Includes non-public methods.
- * @param clazz the clazz to check
- * @param methodName the name of the method
- * @return whether there is at least one method with the given name
- */
- public static boolean hasAtLeastOneMethodWithName(Class clazz, String methodName) {
- do {
- for (int i = 0; i < clazz.getDeclaredMethods().length; i++) {
- Method method = clazz.getDeclaredMethods()[i];
- if (methodName.equals(method.getName())) {
- return true;
- }
- }
- clazz = clazz.getSuperclass();
- }
- while (clazz != null);
- return false;
- }
-
- /**
- * Return a static method of a class.
- * @param methodName the static method name
- * @param clazz the class which defines the method
- * @param args the parameter types to the method
- * @return the static method, or <code>null</code> if no static method was found
- * @throws IllegalArgumentException if the method name is blank or the clazz is null
- */
- public static Method getStaticMethod(Class clazz, String methodName, Class[] args) {
- try {
- Method method = clazz.getDeclaredMethod(methodName, args);
- if ((method.getModifiers() & Modifier.STATIC) != 0) {
- return method;
- }
- } catch (NoSuchMethodException ex) {
- }
- return null;
- }
-
- /**
- * Return a path suitable for use with ClassLoader.getResource (also
- * suitable for use with Class.getResource by prepending a slash ('/') to
- * the return value. Built by taking the package of the specified class
- * file, converting all dots ('.') to slashes ('/'), adding a trailing slash
- * if necesssary, and concatenating the specified resource name to this.
- * <br/>As such, this function may be used to build a path suitable for
- * loading a resource file that is in the same package as a class file,
- * although {link org.springframework.core.io.ClassPathResource} is usually
- * even more convenient.
- * @param clazz the Class whose package will be used as the base
- * @param resourceName the resource name to append. A leading slash is optional.
- * @return the built-up resource path
- * @see java.lang.ClassLoader#getResource
- * @see java.lang.Class#getResource
- */
- public static String addResourcePathToPackagePath(Class clazz, String resourceName) {
- if (!resourceName.startsWith("/")) {
- return classPackageAsResourcePath(clazz) + "/" + resourceName;
- }
- return classPackageAsResourcePath(clazz) + resourceName;
- }
-
- /**
- * Given an input class object, return a string which consists of the
- * class's package name as a pathname, i.e., all dots ('.') are replaced by
- * slashes ('/'). Neither a leading nor trailing slash is added. The result
- * could be concatenated with a slash and the name of a resource, and fed
- * directly to ClassLoader.getResource(). For it to be fed to Class.getResource,
- * a leading slash would also have to be prepended to the return value.
- * @param clazz the input class. A null value or the default (empty) package
- * will result in an empty string ("") being returned.
- * @return a path which represents the package name
- * @see java.lang.ClassLoader#getResource
- * @see java.lang.Class#getResource
- */
- public static String classPackageAsResourcePath(Class clazz) {
- if (clazz == null || clazz.getPackage() == null) {
- return "";
- }
- return clazz.getPackage().getName().replace('.', '/');
- }
-
- /**
- * Return all interfaces that the given object implements as array,
- * including ones implemented by superclasses.
- * @param object the object to analyse for interfaces
- * @return all interfaces that the given object implements as array
- */
- public static Class[] getAllInterfaces(Object object) {
- Set interfaces = getAllInterfacesAsSet(object);
- return (Class[]) interfaces.toArray(new Class[interfaces.size()]);
- }
-
- /**
- * Return all interfaces that the given class implements as array,
- * including ones implemented by superclasses.
- * @param clazz the class to analyse for interfaces
- * @return all interfaces that the given object implements as array
- */
- public static Class[] getAllInterfacesForClass(Class clazz) {
- Set interfaces = getAllInterfacesForClassAsSet(clazz);
- return (Class[]) interfaces.toArray(new Class[interfaces.size()]);
- }
-
- /**
- * Return all interfaces that the given object implements as List,
- * including ones implemented by superclasses.
- * @param object the object to analyse for interfaces
- * @return all interfaces that the given object implements as List
- */
- public static Set getAllInterfacesAsSet(Object object) {
- return getAllInterfacesForClassAsSet(object.getClass());
- }
-
- /**
- * Return all interfaces that the given class implements as Set,
- * including ones implemented by superclasses.
- * @param clazz the class to analyse for interfaces
- * @return all interfaces that the given object implements as Set
- */
- public static Set getAllInterfacesForClassAsSet(Class clazz) {
- Set interfaces = new HashSet();
- while (clazz != null) {
- for (int i = 0; i < clazz.getInterfaces().length; i++) {
- Class ifc = clazz.getInterfaces()[i];
- interfaces.add(ifc);
- }
- clazz = clazz.getSuperclass();
- }
- return interfaces;
- }
+ return interfaces;
+ }
}
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?view=diff&rev=488301&r1=488300&r2=488301
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java Mon Dec 18 07:08:44 2006
@@ -761,7 +761,7 @@
throw new PatternSyntaxException( "Regex was null", "null", -1 );
}
- ArrayList any = new ArrayList();
+ List<String> any = new ArrayList<String>();
String remaining = ldapRegex;
int index = remaining.indexOf( '*' );
@@ -797,7 +797,7 @@
for ( int i = 0; i < anyStrs.length; i++ )
{
- anyStrs[i] = ( String ) any.get( i );
+ anyStrs[i] = any.get( i );
}
return getRegex( initialPattern, anyStrs, finalPattern );
@@ -828,7 +828,7 @@
int start = 0;
int stop = -1;
String path = null;
- ArrayList list = new ArrayList();
+ List<String> list = new ArrayList<String>();
// Abandon with no values if paths string is null
if ( paths == null || paths.trim().equals( "" ) )