Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.directory.shared.ldap.model.schema;
import java.util.List;
import java.util.Map;
/**
* Utility class used to generate schema object specifications. Some of the
* latest work coming out of the LDAPBIS working body adds optional extensions
* to these syntaxes. Descriptions can be generated for
* the following objects:
*
*
* @author Apache Directory Project
*/
public final class DescriptionUtils
{
/**
* Private constructor.
*/
private DescriptionUtils()
{
}
/**
* Generates the description using the AttributeTypeDescription as defined
* by the syntax: 1.3.6.1.4.1.1466.115.121.1.3. Only the right hand side of
* the description starting at the opening parenthesis is generated: that
* is 'AttributeTypeDescription = ' is not generated.
*
*
*
* @param comparator
* the Comparator to generate the description for
* @return the ComparatorDescription string
*/
public static String getDescription( LdapComparator comparator )
{
return getLoadableDescription( comparator );
}
/**
* Generates the DITContentRuleDescription for a DitContentRule as defined
* by the syntax: 1.3.6.1.4.1.1466.115.121.1.16. Only the right hand side of
* the description starting at the opening parenthesis is generated: that
* is 'DITContentRuleDescription = ' is not generated.
*
*
*
* @param dITContentRule
* the DIT content rule specification
* @return the specification according to the DITContentRuleDescription
* syntax
*/
public static String getDescription( DitContentRule dITContentRule )
{
StringBuilder buf = new StringBuilder( "( " );
buf.append( dITContentRule.getOid() );
buf.append( '\n' );
if ( dITContentRule.getNames() != null )
{
buf.append( " NAME " );
getQDescrs( buf, dITContentRule.getNames() );
buf.append( '\n' );
}
if ( dITContentRule.getDescription() != null )
{
buf.append( " DESC " );
buf.append( dITContentRule.getDescription() );
buf.append( '\n' );
}
if ( dITContentRule.isObsolete() )
{
buf.append( " OBSOLETE\n" );
}
// print out all the auxiliary object class oids
List aux = dITContentRule.getAuxObjectClasses();
if ( ( aux != null ) && ( aux.size() > 0 ) )
{
buf.append( " AUX " );
getQDStrings( buf, aux );
}
List must = dITContentRule.getMustAttributeTypes();
if ( ( must != null ) && ( must.size() > 0 ) )
{
buf.append( " MUST " );
getQDStrings( buf, must );
}
List may = dITContentRule.getMayAttributeTypes();
if ( ( may != null ) && ( may.size() > 0 ) )
{
buf.append( " MAY " );
getQDStrings( buf, may );
}
List not = dITContentRule.getNotAttributeTypes();
if ( ( not != null ) && ( not.size() > 0 ) )
{
buf.append( " NOT " );
getQDStrings( buf, not );
}
if ( dITContentRule.getExtensions() != null )
{
getExtensions( buf, dITContentRule.getExtensions() );
}
buf.append( " )\n" );
return buf.toString();
}
/**
* Generates the DITStructureRuleDescription for a DitStructureRule as
* defined by the syntax: 1.3.6.1.4.1.1466.115.121.1.17. Only the right hand
* side of the description starting at the opening parenthesis is
* generated: that is 'DITStructureRuleDescription = ' is not generated.
*
*
*
* @param matchingRule
* the MatchingRule to generate the description for
* @return the MatchingRuleDescription string
*/
public static String getDescription( MatchingRule matchingRule )
{
StringBuilder buf = new StringBuilder( "( " );
buf.append( matchingRule.getOid() );
buf.append( '\n' );
if ( matchingRule.getNames() != null )
{
buf.append( " NAME " );
getQDescrs( buf, matchingRule.getNames() );
}
if ( matchingRule.getDescription() != null )
{
buf.append( " DESC " );
buf.append( matchingRule.getDescription() );
buf.append( '\n' );
}
if ( matchingRule.isObsolete() )
{
buf.append( " OBSOLETE\n" );
}
buf.append( " SYNTAX " );
buf.append( matchingRule.getSyntaxOid() );
buf.append( '\n' );
if ( matchingRule.getExtensions() != null )
{
getExtensions( buf, matchingRule.getExtensions() );
}
buf.append( " ) " );
return buf.toString();
}
/**
* Generates the MatchingRuleUseDescription for a MatchingRuleUse as defined
* by the syntax: 1.3.6.1.4.1.1466.115.121.1.31. Only the right hand side of
* the description starting at the opening parenthesis is generated: that
* is 'MatchingRuleUseDescription = ' is not generated.
*
*
* MatchingRuleUseDescription = LPAREN WSP
* numericoid ; object identifier
* [ SP "NAME" SP qdescrs ] ; short names (descriptors)
* [ SP "DESC" SP qdstring ] ; description
* [ SP "OBSOLETE" ] ; not active
* SP "APPLIES" SP oids ; attribute types
* extensions WSP RPAREN ; extensions
*
* where:
* [numericoid] is the object identifier of the matching rule
* associated with this matching rule use description;
* NAME [qdescrs] are short names (descriptors) identifying this
* matching rule use;
* DESC [qdstring] is a short descriptive string;
* OBSOLETE indicates this matching rule use is not active;
* APPLIES provides a list of attribute types the matching rule applies
* to; and
* [extensions] describe extensions.
*
*
* @param matchingRuleUse The matching rule from which we want to generate
* a MatchingRuleUseDescription.
* @return The generated MatchingRuleUseDescription
*/
public static String getDescription( MatchingRuleUse matchingRuleUse )
{
StringBuilder buf = new StringBuilder( "( " );
buf.append( matchingRuleUse.getOid() );
buf.append( '\n' );
buf.append( " NAME " );
getQDescrs( buf, matchingRuleUse.getNames() );
if ( matchingRuleUse.getDescription() != null )
{
buf.append( " DESC " );
buf.append( matchingRuleUse.getDescription() );
buf.append( '\n' );
}
if ( matchingRuleUse.isObsolete() )
{
buf.append( " OBSOLETE\n" );
}
buf.append( " APPLIES " );
List attributeTypes = matchingRuleUse.getApplicableAttributes();
if ( attributeTypes.size() == 1 )
{
buf.append( attributeTypes.get( 0 ).getOid() );
}
else
// for list of oids we need a parenthesis
{
buf.append( "( " );
boolean isFirst = true;
for ( AttributeType attributeType : attributeTypes )
{
if ( isFirst )
{
isFirst = false;
}
else
{
buf.append( " $ " );
}
buf.append( attributeType );
}
buf.append( " ) " );
}
if ( matchingRuleUse.getExtensions() != null )
{
getExtensions( buf, matchingRuleUse.getExtensions() );
}
buf.append( " )\n" );
return buf.toString();
}
/**
* Generates the NameFormDescription for a NameForm as defined by the
* syntax: 1.3.6.1.4.1.1466.115.121.1.35. Only the right hand side of the
* description starting at the opening parenthesis is generated: that is
* 'NameFormDescription = ' is not generated.
*
*
*
* @param normalizer
* the Normalizer to generate the description for
* @return the NormalizerDescription string
*/
public static String getDescription( Normalizer normalizer )
{
return getLoadableDescription( normalizer );
}
/**
* Generates the ObjectClassDescription for an ObjectClass as defined by the
* syntax: 1.3.6.1.4.1.1466.115.121.1.37. Only the right hand side of the
* description starting at the opening parenthesis is generated: that is
* 'ObjectClassDescription = ' is not generated.
*
*
*
* @param syntax
* the Syntax to generate a description for
* @return the description in the SyntaxDescription syntax
*/
public static String getDescription( LdapSyntax syntax )
{
StringBuilder buf = new StringBuilder( "( " );
buf.append( syntax.getOid() );
buf.append( '\n' );
if ( syntax.getDescription() != null )
{
buf.append( " DESC " );
buf.append( syntax.getDescription() );
buf.append( '\n' );
}
if ( syntax.getExtensions() != null )
{
getExtensions( buf, syntax.getExtensions() );
}
buf.append( " )" );
return buf.toString();
}
/**
* Generates the SyntaxCheckerDescription for a SyntaxChecker. Only the right
* hand side of the description starting at the opening parenthesis is
* generated: that is 'SyntaxCheckerDescription = ' is not generated.
*
*