org.apache.directory.shared.ldap.schema
Class SchemaUtils

java.lang.Object
  extended by org.apache.directory.shared.ldap.schema.SchemaUtils

public class SchemaUtils
extends java.lang.Object

Various utility methods for schema functions and objects.

Version:
$Rev: 928015 $
Author:
Apache Directory Project

Constructor Summary
SchemaUtils()
           
 
Method Summary
static java.util.Set<java.lang.String> getOptions(java.lang.String attributeId)
          Get the options from the attributeType.
static Entry getTargetEntry(java.util.List<? extends Modification> mods, Entry entry)
          Gets the target entry as it would look after a modification operation were performed on it.
static java.lang.StringBuffer render(AttributeType at)
          Renders an attributeType into a new StringBuffer according to the Attribute Type Description Syntax 1.3.6.1.4.1.1466.115.121.1.3.
static java.lang.StringBuffer render(AttributeType[] ats)
          Renders a list of attributeTypes for things like the must or may list of objectClasses using the ( oid $ oid ) format.
static java.lang.StringBuffer render(DITContentRule dcr)
          NOT FULLY IMPLEMENTED!
static java.lang.StringBuffer render(DITStructureRule dsr)
          NOT FULLY IMPLEMENTED!
static java.lang.StringBuffer render(LdapSyntax syntax)
          Renders a Syntax into a new StringBuffer according to the LDAP Syntax Description Syntax 1.3.6.1.4.1.1466.115.121.1.54.
static java.lang.String render(LoadableSchemaObject description)
          Returns a String description of a schema.
static java.lang.StringBuffer render(java.util.Map<java.lang.String,java.util.List<java.lang.String>> extensions)
          Renders an attributeType description object into a new StringBuffer according to the Attribute Type Description Syntax defined in MODELS 1.3.6.1.4.1.1466.115.121.1.3.
static java.lang.StringBuffer render(MatchingRule mr)
          Renders an matchingRule into a new StringBuffer according to the MatchingRule Description Syntax 1.3.6.1.4.1.1466.115.121.1.30.
static java.lang.StringBuffer render(MatchingRuleUse mru)
          NOT FULLY IMPLEMENTED!
static java.lang.StringBuffer render(NameForm nf)
          NOT FULLY IMPLEMENTED!
static java.lang.StringBuffer render(ObjectClass oc)
          Renders an objectClass into a new StringBuffer according to the Object Class Description Syntax 1.3.6.1.4.1.1466.115.121.1.37.
static java.lang.StringBuffer render(ObjectClass[] ocs)
          Renders a list of object classes for things like a list of superior objectClasses using the ( oid $ oid ) format.
static java.lang.StringBuffer render(java.lang.StringBuffer buf, AttributeType[] ats)
          Renders a list of attributeTypes for things like the must or may list of objectClasses using the ( oid $ oid ) format into an existing buffer.
static java.lang.StringBuffer render(java.lang.StringBuffer buf, java.util.List<java.lang.String> qdescrs)
          Renders qdescrs into an existing buffer.
static java.lang.StringBuffer render(java.lang.StringBuffer buf, ObjectClass[] ocs)
          Renders a list of object classes for things like a list of superior objectClasses using the ( oid $ oid ) format into an existing buffer.
static java.lang.String stripOptions(java.lang.String attributeId)
          Remove the options from the attributeType, and returns the ID.
static byte[] uuidToBytes(java.util.UUID uuid)
          Transform an UUID in a byte array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaUtils

public SchemaUtils()
Method Detail

getTargetEntry

public static Entry getTargetEntry(java.util.List<? extends Modification> mods,
                                   Entry entry)
                            throws LdapException
Gets the target entry as it would look after a modification operation were performed on it.

Parameters:
mods - the modifications performed on the entry
entry - the source entry that is modified
Returns:
the resultant entry after the modifications have taken place
Throws:
LdapException - if there are problems accessing attributes

render

public static java.lang.StringBuffer render(java.lang.StringBuffer buf,
                                            java.util.List<java.lang.String> qdescrs)
Renders qdescrs into an existing buffer.

Parameters:
buf - the string buffer to render the quoted description strs into
qdescrs - the quoted description strings to render
Returns:
the same string buffer that was given for call chaining

render

public static java.lang.StringBuffer render(ObjectClass[] ocs)
Renders a list of object classes for things like a list of superior objectClasses using the ( oid $ oid ) format.

Parameters:
ocs - the objectClasses to list
Returns:
a buffer which contains the rendered list

render

public static java.lang.StringBuffer render(java.lang.StringBuffer buf,
                                            ObjectClass[] ocs)
Renders a list of object classes for things like a list of superior objectClasses using the ( oid $ oid ) format into an existing buffer.

Parameters:
buf - the string buffer to render the list of objectClasses into
ocs - the objectClasses to list
Returns:
a buffer which contains the rendered list

render

public static java.lang.StringBuffer render(AttributeType[] ats)
Renders a list of attributeTypes for things like the must or may list of objectClasses using the ( oid $ oid ) format.

Parameters:
ats - the attributeTypes to list
Returns:
a buffer which contains the rendered list

render

public static java.lang.StringBuffer render(java.lang.StringBuffer buf,
                                            AttributeType[] ats)
Renders a list of attributeTypes for things like the must or may list of objectClasses using the ( oid $ oid ) format into an existing buffer.

Parameters:
buf - the string buffer to render the list of attributeTypes into
ats - the attributeTypes to list
Returns:
a buffer which contains the rendered list

render

public static java.lang.StringBuffer render(ObjectClass oc)
                                     throws LdapException
Renders an objectClass into a new StringBuffer according to the Object Class Description Syntax 1.3.6.1.4.1.1466.115.121.1.37. The syntax is described in detail within section 4.1.1. of LDAPBIS [MODELS] which is replicated here for convenience:
  4.1.1. Object Class Definitions
 
   Object Class definitions are written according to the ABNF:
 
     ObjectClassDescription = LPAREN WSP
         numericoid                 ; object identifier
         [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
         [ SP "DESC" SP qdstring ]  ; description
         [ SP "OBSOLETE" ]          ; not active
         [ SP "SUP" SP oids ]       ; superior object classes
         [ SP kind ]                ; kind of class
         [ SP "MUST" SP oids ]      ; attribute types
         [ SP "MAY" SP oids ]       ; attribute types
         extensions WSP RPAREN
 
     kind = "ABSTRACT" / "STRUCTURAL" / "AUXILIARY"
 
   where:
     <numericoid> is object identifier assigned to this object class;
     NAME <qdescrs> are short names (descriptors) identifying this object
         class;
     DESC <qdstring> is a short descriptive string;
     OBSOLETE indicates this object class is not active;
     SUP <oids> specifies the direct superclasses of this object class;
     the kind of object class is indicated by one of ABSTRACT,
         STRUCTURAL, or AUXILIARY, default is STRUCTURAL;
     MUST and MAY specify the sets of required and allowed attribute
         types, respectively; and
     <extensions> describe extensions.
 

Parameters:
oc - the objectClass to render the description of
Returns:
the buffer containing the objectClass description
Throws:
LdapException - if there are any problems accessing objectClass information

render

public static java.lang.StringBuffer render(AttributeType at)
                                     throws LdapException
Renders an attributeType into a new StringBuffer according to the Attribute Type Description Syntax 1.3.6.1.4.1.1466.115.121.1.3. The syntax is described in detail within section 4.1.2. of LDAPBIS [MODELS] which is replicated here for convenience:
  4.1.2. Attribute Types
 
   Attribute Type definitions are written according to the ABNF:
 
   AttributeTypeDescription = LPAREN WSP
         numericoid                    ; object identifier
         [ SP "NAME" SP qdescrs ]      ; short names (descriptors)
         [ SP "DESC" SP qdstring ]     ; description
         [ SP "OBSOLETE" ]             ; not active
         [ SP "SUP" SP oid ]           ; supertype
         [ SP "EQUALITY" SP oid ]      ; equality matching rule
         [ SP "ORDERING" SP oid ]      ; ordering matching rule
         [ SP "SUBSTR" SP oid ]        ; substrings matching rule
         [ SP "SYNTAX" SP noidlen ]    ; value syntax
         [ SP "SINGLE-VALUE" ]         ; single-value
         [ SP "COLLECTIVE" ]           ; collective
         [ SP "NO-USER-MODIFICATION" ] ; not user modifiable
         [ SP "USAGE" SP usage ]       ; usage
         extensions WSP RPAREN         ; extensions
 
     usage = "userApplications"     /  ; user
             "directoryOperation"   /  ; directory operational
             "distributedOperation" /  ; DSA-shared operational
             "dSAOperation"            ; DSA-specific operational
 
   where:
     <numericoid> is object identifier assigned to this attribute type;
     NAME <qdescrs> are short names (descriptors) identifying this
         attribute type;
     DESC <qdstring> is a short descriptive string;
     OBSOLETE indicates this attribute type is not active;
     SUP oid specifies the direct supertype of this type;
     EQUALITY, ORDERING, SUBSTR provide the oid of the equality,
         ordering, and substrings matching rules, respectively;
     SYNTAX identifies value syntax by object identifier and may suggest
         a minimum upper bound;
     SINGLE-VALUE indicates attributes of this type are restricted to a
         single value;
     COLLECTIVE indicates this attribute type is collective
         [X.501][RFC3671];
     NO-USER-MODIFICATION indicates this attribute type is not user
         modifiable;
     USAGE indicates the application of this attribute type; and
     <extensions> describe extensions.
 

Parameters:
at - the AttributeType to render the description for
Returns:
the StringBuffer containing the rendered attributeType description
Throws:
LdapException - if there are problems accessing the objects associated with the attribute type.

render

public static java.lang.StringBuffer render(java.util.Map<java.lang.String,java.util.List<java.lang.String>> extensions)
Renders an attributeType description object into a new StringBuffer according to the Attribute Type Description Syntax defined in MODELS 1.3.6.1.4.1.1466.115.121.1.3. The syntax is described in detail within section 4.1.2. of (@TODO NEEDS TO CHANGE SINCE THIS IS NOW AN RFC) LDAPBIS [MODELS] which is replicated here for convenience:
  4.1.2. Attribute Types

   Attribute Type definitions are written according to the ABNF:

   AttributeTypeDescription = LPAREN WSP
         numericoid                    ; object identifier
         [ SP "NAME" SP qdescrs ]      ; short names (descriptors)
         [ SP "DESC" SP qdstring ]     ; description
         [ SP "OBSOLETE" ]             ; not active
         [ SP "SUP" SP oid ]           ; supertype
         [ SP "EQUALITY" SP oid ]      ; equality matching rule
         [ SP "ORDERING" SP oid ]      ; ordering matching rule
         [ SP "SUBSTR" SP oid ]        ; substrings matching rule
         [ SP "SYNTAX" SP noidlen ]    ; value syntax
         [ SP "SINGLE-VALUE" ]         ; single-value
         [ SP "COLLECTIVE" ]           ; collective
         [ SP "NO-USER-MODIFICATION" ] ; not user modifiable
         [ SP "USAGE" SP usage ]       ; usage
         extensions WSP RPAREN         ; extensions

     usage = "userApplications"     /  ; user
             "directoryOperation"   /  ; directory operational
             "distributedOperation" /  ; DSA-shared operational
             "dSAOperation"            ; DSA-specific operational

   where:
     <numericoid> is object identifier assigned to this attribute type;
     NAME <qdescrs> are short names (descriptors) identifying this
         attribute type;
     DESC <qdstring> is a short descriptive string;
     OBSOLETE indicates this attribute type is not active;
     SUP oid specifies the direct supertype of this type;
     EQUALITY, ORDERING, SUBSTR provide the oid of the equality,
         ordering, and substrings matching rules, respectively;
     SYNTAX identifies value syntax by object identifier and may suggest
         a minimum upper bound;
     SINGLE-VALUE indicates attributes of this type are restricted to a
         single value;
     COLLECTIVE indicates this attribute type is collective
         [X.501][RFC3671];
     NO-USER-MODIFICATION indicates this attribute type is not user
         modifiable;
     USAGE indicates the application of this attribute type; and
     <extensions> describe extensions.
 

Parameters:
atd - the AttributeTypeDescription to render the description for
extensions - the schema extensions map with key and values
Returns:
the StringBuffer containing the rendered attributeType description
Throws:
LdapException - if there are problems accessing the objects associated with the attribute type. public static StringBuffer render( AttributeType attributeType ) { StringBuffer buf = new StringBuffer(); buf.append( "( " ).append( attributeType.getOid() ); if ( attributeType.getNames() != null && attributeType.getNames().size() > 0 ) { buf.append( " NAME " ); render( buf, attributeType.getNames() ).append( " " ); } else { buf.append( " " ); } if ( attributeType.getDescription() != null ) { buf.append( "DESC " ).append( "'" ).append( attributeType.getDescription() ).append( "' " ); } if ( attributeType.isObsolete() ) { buf.append( " OBSOLETE" ); } if ( attributeType.getSupOid() != null ) { buf.append( " SUP " ).append( attributeType.getSupOid() ); } if ( attributeType.getEqualityOid() != null ) { buf.append( " EQUALITY " ).append( attributeType.getEqualityOid() ); } if ( attributeType.getOrderingOid() != null ) { buf.append( " ORDERING " ).append( attributeType.getOrderingOid() ); } if ( attributeType.getSubstrOid() != null ) { buf.append( " SUBSTR " ).append( attributeType.getSubstrOid() ); } if ( attributeType.getSyntax() != null ) { buf.append( " SYNTAX " ).append( attributeType.getSyntax() ); if ( attributeType.getLength() > 0 ) { buf.append( "{" ).append( attributeType.getLength() ).append( "}" ); } } if ( attributeType.isSingleValue() ) { buf.append( " SINGLE-VALUE" ); } if ( attributeType.isCollective() ) { buf.append( " COLLECTIVE" ); } if ( !attributeType.isCanUserModify() ) { buf.append( " NO-USER-MODIFICATION" ); } if ( attributeType.getUsage() != null ) { buf.append( " USAGE " ).append( UsageEnum.render( attributeType.getUsage() ) ); } return buf.append( render( attributeType.getExtensions() ) ).append( ")" ); } /** Renders the schema extensions into a new StringBuffer.

render

public static java.lang.StringBuffer render(MatchingRule mr)
                                     throws LdapException
Renders an matchingRule into a new StringBuffer according to the MatchingRule Description Syntax 1.3.6.1.4.1.1466.115.121.1.30. The syntax is described in detail within section 4.1.3. of LDAPBIS [MODELS] which is replicated here for convenience:
  4.1.3. Matching Rules
 
   Matching rules are used in performance of attribute value assertions,
   such as in performance of a Compare operation.  They are also used in
   evaluation of a Search filters, in determining which individual values
   are be added or deleted during performance of a Modify operation, and
   used in comparison of distinguished names.
 
   Each matching rule is identified by an object identifier (OID) and,
   optionally, one or more short names (descriptors).
 
   Matching rule definitions are written according to the ABNF:
 
   MatchingRuleDescription = LPAREN WSP
        numericoid                 ; object identifier
         [ SP "NAME" SP qdescrs ]   ; short names (descriptors)
         [ SP "DESC" SP qdstring ]  ; description
         [ SP "OBSOLETE" ]          ; not active
         SP "SYNTAX" SP numericoid  ; assertion syntax
         extensions WSP RPAREN      ; extensions
 
   where:
     <numericoid> is object identifier assigned to this matching rule;
     NAME <qdescrs> are short names (descriptors) identifying this
         matching rule;
     DESC <qdstring> is a short descriptive string;
     OBSOLETE indicates this matching rule is not active;
     SYNTAX identifies the assertion syntax (the syntax of the assertion
         value) by object identifier; and
     <extensions> describe extensions.
 

Parameters:
mr - the MatchingRule to render the description for
Returns:
the StringBuffer containing the rendered matchingRule description
Throws:
LdapException - if there are problems accessing the objects associated with the MatchingRule.

render

public static java.lang.StringBuffer render(LdapSyntax syntax)
Renders a Syntax into a new StringBuffer according to the LDAP Syntax Description Syntax 1.3.6.1.4.1.1466.115.121.1.54. The syntax is described in detail within section 4.1.5. of LDAPBIS [MODELS] which is replicated here for convenience:
  LDAP syntax definitions are written according to the ABNF:
 
   SyntaxDescription = LPAREN WSP
       numericoid                 ; object identifier
       [ SP "DESC" SP qdstring ]  ; description
       extensions WSP RPAREN      ; extensions
 
  where:
   <numericoid> is the object identifier assigned to this LDAP syntax;
   DESC <qdstring> is a short descriptive string; and
   <extensions> describe extensions.
 

Parameters:
syntax - the Syntax to render the description for
Returns:
the StringBuffer containing the rendered syntax description

render

public static java.lang.StringBuffer render(MatchingRuleUse mru)
NOT FULLY IMPLEMENTED!


render

public static java.lang.StringBuffer render(DITContentRule dcr)
NOT FULLY IMPLEMENTED!


render

public static java.lang.StringBuffer render(DITStructureRule dsr)
NOT FULLY IMPLEMENTED!


render

public static java.lang.StringBuffer render(NameForm nf)
NOT FULLY IMPLEMENTED!


render

public static java.lang.String render(LoadableSchemaObject description)
Returns a String description of a schema. The resulting String format is :
(OID [DESC ''] FQCN [BYTECODE ] X-SCHEMA '')

Parameters:
description - The description to transform to a String
Returns:

stripOptions

public static java.lang.String stripOptions(java.lang.String attributeId)
Remove the options from the attributeType, and returns the ID. RFC 4512 : attributedescription = attributetype options attributetype = oid options = *( SEMI option ) option = 1*keychar


getOptions

public static java.util.Set<java.lang.String> getOptions(java.lang.String attributeId)
Get the options from the attributeType. For instance, given : jpegphoto;binary;lang=jp your get back a set containing { "binary", "lang=jp" }


uuidToBytes

public static byte[] uuidToBytes(java.util.UUID uuid)
Transform an UUID in a byte array

Parameters:
uuid - The UUID to transform
Returns:
The byte[] representing the UUID


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.