Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
openldap
JLDAP
Commits
7b56aabe
Commit
7b56aabe
authored
Jan 09, 2002
by
Steve Sonntag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take vector out of LDAPSchema, DN, and RDN
parent
83390695
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
62 deletions
+88
-62
com/novell/ldap/LDAPSchema.java
com/novell/ldap/LDAPSchema.java
+32
-30
com/novell/ldap/client/ArrayList.java
com/novell/ldap/client/ArrayList.java
+13
-1
com/novell/ldap/util/DN.java
com/novell/ldap/util/DN.java
+20
-14
com/novell/ldap/util/RDN.java
com/novell/ldap/util/RDN.java
+23
-17
No files found.
com/novell/ldap/LDAPSchema.java
View file @
7b56aabe
...
...
@@ -17,6 +17,8 @@ package com.novell.ldap;
import
java.util.Enumeration
;
import
java.util.Hashtable
;
import
com.novell.ldap.client.ArrayList
;
import
com.novell.ldap.client.ArrayEnumeration
;
/**
* The schema of a particular directory server.
...
...
@@ -500,14 +502,14 @@ public class LDAPSchema {
* @return An enumeration of attribute names.
*/
public
Enumeration
getAttributeNames
()
{
java
.
util
.
Vector
names
=
new
java
.
util
.
Vector
(
attributeHashtable
.
size
());
ArrayList
names
=
new
ArrayList
(
attributeHashtable
.
size
());
Enumeration
elements
=
attributeHashtable
.
elements
();
LDAPSchemaElement
el
;
while
(
elements
.
hasMoreElements
()){
LDAPSchemaElement
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
names
.
add
(
el
.
getName
());
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
names
.
add
(
el
.
getName
());
}
return
n
ames
.
elements
(
);
return
n
ew
ArrayEnumeration
(
names
.
toArray
()
);
}
/**
...
...
@@ -516,14 +518,14 @@ public class LDAPSchema {
* @return An enumeration of object class names.
*/
public
Enumeration
getObjectClassNames
()
{
java
.
util
.
Vector
names
=
new
java
.
util
.
Vector
(
objectClassHashtable
.
size
());
ArrayList
names
=
new
ArrayList
(
objectClassHashtable
.
size
());
Enumeration
elements
=
objectClassHashtable
.
elements
();
while
(
elements
.
hasMoreElements
()){
LDAPSchemaElement
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
LDAPSchemaElement
el
;
while
(
elements
.
hasMoreElements
())
{
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
names
.
add
(
el
.
getName
());
}
return
n
ames
.
elements
(
);
return
n
ew
ArrayEnumeration
(
names
.
toArray
()
);
}
/**
...
...
@@ -532,14 +534,14 @@ public class LDAPSchema {
* @return An enumeration of matching rule names.
*/
public
Enumeration
getMatchingRuleNames
()
{
java
.
util
.
Vector
names
=
new
java
.
util
.
Vector
(
matchingRuleHashtable
.
size
());
ArrayList
names
=
new
ArrayList
(
matchingRuleHashtable
.
size
());
Enumeration
elements
=
matchingRuleHashtable
.
elements
();
LDAPSchemaElement
el
;
while
(
elements
.
hasMoreElements
()){
LDAPSchemaElement
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
names
.
add
(
el
.
getName
());
}
return
n
ames
.
elements
(
);
return
n
ew
ArrayEnumeration
(
names
.
toArray
()
);
}
/**
...
...
@@ -548,14 +550,14 @@ public class LDAPSchema {
* @return An enumeration of matching rule use names.
*/
public
Enumeration
getMatchingRuleUseNames
()
{
java
.
util
.
Vector
names
=
new
java
.
util
.
Vector
(
matchingRuleUseHashtable
.
size
());
ArrayList
names
=
new
ArrayList
(
matchingRuleUseHashtable
.
size
());
Enumeration
elements
=
matchingRuleUseHashtable
.
elements
();
LDAPSchemaElement
el
;
while
(
elements
.
hasMoreElements
()){
LDAPSchemaElement
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
names
.
add
(
el
.
getName
());
}
return
n
ames
.
elements
(
);
return
n
ew
ArrayEnumeration
(
names
.
toArray
()
);
}
/**
...
...
@@ -564,14 +566,14 @@ public class LDAPSchema {
* @return An enumeration of DIT structure rule names.
*/
public
Enumeration
getDITStructureRuleNames
()
{
java
.
util
.
Vector
names
=
new
java
.
util
.
Vector
(
dITStructureRuleHashtable
.
size
());
ArrayList
names
=
new
ArrayList
(
dITStructureRuleHashtable
.
size
());
Enumeration
elements
=
dITStructureRuleHashtable
.
elements
();
LDAPSchemaElement
el
;
while
(
elements
.
hasMoreElements
()){
LDAPSchemaElement
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
names
.
add
(
el
.
getName
());
}
return
n
ames
.
elements
(
);
return
n
ew
ArrayEnumeration
(
names
.
toArray
()
);
}
/**
...
...
@@ -580,14 +582,14 @@ public class LDAPSchema {
* @return An enumeration of DIT content rule names.
*/
public
Enumeration
getDITContentRuleNames
()
{
java
.
util
.
Vector
names
=
new
java
.
util
.
Vector
(
dITContentRuleHashtable
.
size
());
ArrayList
names
=
new
ArrayList
(
dITContentRuleHashtable
.
size
());
Enumeration
elements
=
dITContentRuleHashtable
.
elements
();
LDAPSchemaElement
el
;
while
(
elements
.
hasMoreElements
()){
LDAPSchemaElement
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
names
.
add
(
el
.
getName
());
}
return
n
ames
.
elements
(
);
return
n
ew
ArrayEnumeration
(
names
.
toArray
()
);
}
/**
...
...
@@ -596,13 +598,13 @@ public class LDAPSchema {
* @return An enumeration of name form names.
*/
public
Enumeration
getNameFormNames
()
{
java
.
util
.
Vector
names
=
new
java
.
util
.
Vector
(
nameFormHashtable
.
size
());
ArrayList
names
=
new
ArrayList
(
nameFormHashtable
.
size
());
Enumeration
elements
=
nameFormHashtable
.
elements
();
LDAPSchemaElement
el
;
while
(
elements
.
hasMoreElements
()){
LDAPSchemaElement
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
el
=
(
LDAPSchemaElement
)
elements
.
nextElement
();
names
.
add
(
el
.
getName
());
}
return
n
ames
.
elements
(
);
return
n
ew
ArrayEnumeration
(
names
.
toArray
()
);
}
}
com/novell/ldap/client/ArrayList.java
View file @
7b56aabe
...
...
@@ -25,7 +25,7 @@ import java.lang.reflect.Array;
* <strong>Note that this implementation is not synchronized.</strong>
*/
public
class
ArrayList
public
class
ArrayList
implements
Cloneable
{
/**
* The array buffer which holds ArrayList items. Its capacity
...
...
@@ -86,6 +86,18 @@ public class ArrayList
return
size
==
0
;
}
/**
* Returns a shallow copy of this object.
* It does not make copies of the elements in the ArrayList.
*
* @return a clone of this object.
*/
public
Object
clone
()
{
ArrayList
newAList
=
new
ArrayList
(
size
);
System
.
arraycopy
(
this
.
items
,
0
,
newAList
.
items
,
0
,
size
);
return
newAList
;
}
/**
* Increases the size of this <tt>ArrayList</tt>, if necessary,
* to be sure it can hold the number of items specified by
...
...
com/novell/ldap/util/DN.java
View file @
7b56aabe
...
...
@@ -14,6 +14,7 @@
******************************************************************************/
package
com.novell.ldap.util
;
import
com.novell.ldap.util.RDN
;
import
com.novell.ldap.client.ArrayList
;
import
java.util.Vector
;
/**
...
...
@@ -49,7 +50,7 @@ public class DN extends Object
private
static
final
int
HEX_RDN_VALUE
=
6
;
private
static
final
int
UNQUOTED_RDN_VALUE
=
7
;
private
Vector
rdnList
=
new
Vector
();
private
ArrayList
rdnList
=
new
ArrayList
();
public
DN
(){}
/**
...
...
@@ -234,7 +235,7 @@ public class DN extends Object
//added by cameron
currRDN
.
add
(
attrType
,
attrValue
,
rawValue
);
if
(
currChar
!=
'+'
){
rdnList
.
add
Element
(
currRDN
);
rdnList
.
add
(
currRDN
);
currRDN
=
new
RDN
();
}
...
...
@@ -271,7 +272,7 @@ public class DN extends Object
currRDN
.
add
(
attrType
,
attrValue
,
rawValue
);
if
(
currChar
!=
'+'
){
rdnList
.
add
Element
(
currRDN
);
rdnList
.
add
(
currRDN
);
currRDN
=
new
RDN
();
}
trailingSpaceCount
=
0
;
...
...
@@ -329,7 +330,7 @@ public class DN extends Object
//added by cameron
currRDN
.
add
(
attrType
,
attrValue
,
rawValue
);
if
(
currChar
!=
'+'
){
rdnList
.
add
Element
(
currRDN
);
rdnList
.
add
(
currRDN
);
currRDN
=
new
RDN
();
}
tokenIndex
=
0
;
...
...
@@ -359,7 +360,7 @@ public class DN extends Object
rawValue
=
dnString
.
substring
(
valueStart
,
currIndex
-
trailingSpaceCount
);
currRDN
.
add
(
attrType
,
attrValue
,
rawValue
);
rdnList
.
add
Element
(
currRDN
);
rdnList
.
add
(
currRDN
);
}
else
if
(
state
!=
LOOK_FOR_RDN_ATTR_TYPE
)
{
...
...
@@ -551,7 +552,12 @@ public class DN extends Object
* @return list of RDNs
*/
public
Vector
getRDNs
(){
return
(
Vector
)
rdnList
.
clone
();
int
size
=
rdnList
.
size
();
Vector
v
=
new
Vector
(
size
);
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
v
.
addElement
(
rdnList
.
get
(
i
));
}
return
v
;
}
/** Determines if this DN is <I>contained</I> by the DN passed in. For
...
...
@@ -568,8 +574,8 @@ public class DN extends Object
int
j
=
this
.
rdnList
.
size
()
-
1
;
//index to an RDN of the ContainedDN
//Search from the end of the DN for an RDN that matches the end RDN of
//containerDN.
while
(
!((
RDN
)
this
.
rdnList
.
e
lementA
t
(
j
--)).
equals
(
(
RDN
)
containerDN
.
rdnList
.
e
lementA
t
(
i
))){
while
(
!((
RDN
)
this
.
rdnList
.
g
et
(
j
--)).
equals
(
(
RDN
)
containerDN
.
rdnList
.
g
et
(
i
))){
if
(
j
<=
0
)
return
false
;
//if the end RDN of containerDN does not have any equal
...
...
@@ -579,8 +585,8 @@ public class DN extends Object
j
--;
//step backwards to verify that all RDNs in containerDN exist in this DN
for
(
/* i, j */
;
i
>=
0
&&
j
>=
0
;
i
--,
j
--){
if
(!((
RDN
)
this
.
rdnList
.
e
lementA
t
(
j
)).
equals
(
(
RDN
)
containerDN
.
rdnList
.
e
lementA
t
(
i
)))
if
(!((
RDN
)
this
.
rdnList
.
g
et
(
j
)).
equals
(
(
RDN
)
containerDN
.
rdnList
.
g
et
(
i
)))
return
false
;
}
if
(
j
==
0
&&
i
==
0
)
//the DNs are identical and thus not contained
...
...
@@ -595,7 +601,7 @@ public class DN extends Object
*/
public
DN
getParent
(){
DN
parent
=
new
DN
();
parent
.
rdnList
=
(
Vector
)
this
.
rdnList
.
clone
();
parent
.
rdnList
=
(
ArrayList
)
this
.
rdnList
.
clone
();
if
(
parent
.
rdnList
.
size
()
>=
1
)
parent
.
rdnList
.
remove
(
0
);
//remove first object
return
parent
;
...
...
@@ -606,7 +612,7 @@ public class DN extends Object
* @param an RDN to be added
*/
public
void
addRDN
(
RDN
rdn
){
rdnList
.
insertElementAt
(
rdn
,
0
);
rdnList
.
add
(
0
,
rdn
);
}
/**
...
...
@@ -614,7 +620,7 @@ public class DN extends Object
* @param an RDN to be added
*/
public
void
addRDNToFront
(
RDN
rdn
){
rdnList
.
insertElementAt
(
rdn
,
0
);
rdnList
.
add
(
0
,
rdn
);
}
/**
...
...
@@ -622,6 +628,6 @@ public class DN extends Object
* @param an RDN to be added
*/
public
void
addRDNToBack
(
RDN
rdn
){
rdnList
.
add
Element
(
rdn
);
rdnList
.
add
(
rdn
);
}
}
//end class DN
com/novell/ldap/util/RDN.java
View file @
7b56aabe
...
...
@@ -14,6 +14,7 @@
******************************************************************************/
package
com.novell.ldap.util
;
import
com.novell.ldap.client.ArrayList
;
import
java.util.Vector
;
/**
...
...
@@ -35,9 +36,9 @@ import java.util.Vector;
public
class
RDN
extends
Object
{
private
Vector
types
;
//list of Type strings
private
Vector
values
;
//list of Value strings
private
String
rawValue
;
//the unnormalized value
private
ArrayList
types
;
//list of Type strings
private
ArrayList
values
;
//list of Value strings
private
String
rawValue
;
//the unnormalized value
/**
* Creates an RDN object from the DN component specified in the string RDN
...
...
@@ -56,12 +57,14 @@ public class RDN extends Object
this
.
types
=
thisRDN
.
types
;
this
.
values
=
thisRDN
.
values
;
this
.
rawValue
=
thisRDN
.
rawValue
;
return
;
}
public
RDN
(){
types
=
new
Vector
();
values
=
new
Vector
();
types
=
new
ArrayList
();
values
=
new
ArrayList
();
rawValue
=
""
;
return
;
}
/**
...
...
@@ -69,6 +72,9 @@ public class RDN extends Object
* mulivalues in one RDN they must all be present in the other.
*
* @param the RDN to compare to
*
* @throws IllegalArgumentException if the application compares a name
* with an OID.
*/
public
boolean
equals
(
RDN
rdn
){
if
(
this
.
values
.
size
()
!=
rdn
.
values
.
size
()){
...
...
@@ -80,10 +86,10 @@ public class RDN extends Object
j
=
0
;
//May need a more intellegent compare
while
(
j
<
values
.
size
()
&&
(
!((
String
)
this
.
values
.
e
lementA
t
(
i
)).
equalsIgnoreCase
(
(
String
)
rdn
.
values
.
e
lementA
t
(
j
))
||
!
equalAttrType
((
String
)
this
.
types
.
e
lementA
t
(
i
),
(
String
)
rdn
.
types
.
e
lementA
t
(
j
)))){
!((
String
)
this
.
values
.
g
et
(
i
)).
equalsIgnoreCase
(
(
String
)
rdn
.
values
.
g
et
(
j
))
||
!
equalAttrType
((
String
)
this
.
types
.
g
et
(
i
),
(
String
)
rdn
.
types
.
g
et
(
j
)))){
j
++;
}
if
(
j
>=
rdn
.
values
.
size
())
//couldn't find first value
...
...
@@ -107,8 +113,8 @@ public class RDN extends Object
if
(
java
.
lang
.
Character
.
isDigit
(
attr1
.
charAt
(
0
))
^
//XOR
java
.
lang
.
Character
.
isDigit
(
attr2
.
charAt
(
0
))
)
//isDigit tests if it is an OID
throw
new
UnsupportedOperation
Exception
(
"OID numbers are not "
+
"currently compared to attribute
typ
es"
);
throw
new
IllegalArgument
Exception
(
"OID numbers are not "
+
"currently compared to attribute
nam
es"
);
return
attr1
.
equalsIgnoreCase
(
attr2
);
}
...
...
@@ -131,8 +137,8 @@ public class RDN extends Object
* @param rawValue or text before normalization, can be Null
*/
public
void
add
(
String
attrType
,
String
attrValue
,
String
rawValue
){
types
.
add
Element
(
attrType
);
values
.
add
Element
(
attrValue
);
types
.
add
(
attrType
);
values
.
add
(
attrValue
);
this
.
rawValue
+=
rawValue
;
}
...
...
@@ -201,7 +207,7 @@ public class RDN extends Object
* @return Type of attribute
*/
public
String
getType
(){
return
(
String
)
types
.
e
lementA
t
(
0
);
return
(
String
)
types
.
g
et
(
0
);
}
/**
...
...
@@ -211,7 +217,7 @@ public class RDN extends Object
public
String
[]
getTypes
(){
String
[]
toReturn
=
new
String
[
types
.
size
()];
for
(
int
i
=
0
;
i
<
types
.
size
();
i
++)
toReturn
[
i
]
=
(
String
)
types
.
e
lementA
t
(
i
);
toReturn
[
i
]
=
(
String
)
types
.
g
et
(
i
);
return
toReturn
;
}
...
...
@@ -222,7 +228,7 @@ public class RDN extends Object
* @return Type of attribute
*/
public
String
getValue
(){
return
(
String
)
values
.
e
lementA
t
(
0
);
return
(
String
)
values
.
g
et
(
0
);
}
/**
...
...
@@ -232,7 +238,7 @@ public class RDN extends Object
public
String
[]
getValues
(){
String
[]
toReturn
=
new
String
[
values
.
size
()];
for
(
int
i
=
0
;
i
<
values
.
size
();
i
++)
toReturn
[
i
]
=
(
String
)
values
.
e
lementA
t
(
i
);
toReturn
[
i
]
=
(
String
)
values
.
g
et
(
i
);
return
toReturn
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment