本文整理汇总了Java中org.apache.directory.api.ldap.model.schema.AttributeType类的典型用法代码示例。如果您正苦于以下问题:Java AttributeType类的具体用法?Java AttributeType怎么用?Java AttributeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeType类属于org.apache.directory.api.ldap.model.schema包,在下文中一共展示了AttributeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unregister
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AttributeType unregister( String numericOid ) throws LdapException
{
try
{
AttributeType removed = super.unregister( numericOid );
removeMappingFor( removed );
// Deleting an AT which might be used as a superior means we have
// to recursively update the descendant map. We also have to remove
// the at.oid -> descendant relation
oidToDescendantSet.remove( numericOid );
// Now recurse if needed
unregisterDescendants( removed, removed.getSuperior() );
return removed;
}
catch ( LdapException ne )
{
throw new LdapNoSuchAttributeException( ne.getMessage(), ne );
}
}
示例2: testGetAttribute
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
@Test
public void testGetAttribute() throws Exception
{
AttributeType at = TestEntryUtils.getIA5StringAttributeType();
DefaultAttribute attr = new DefaultAttribute( at );
attr.add( "Test1" );
attr.add( "Test2" );
attr.add( "Test3" );
assertEquals( "1.1", attr.getId() );
assertEquals( 3, attr.size() );
assertTrue( attr.contains( "Test1" ) );
assertTrue( attr.contains( "Test2" ) );
assertTrue( attr.contains( "Test3" ) );
}
示例3: testContains
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Test the contains() method
*/
@Test
public void testContains() throws Exception
{
AttributeType at = TestEntryUtils.getIA5StringAttributeType();
DefaultAttribute attr = new DefaultAttribute( at );
attr.add( "Test 1" );
attr.add( "Test 2" );
attr.add( "Test 3" );
assertTrue( attr.contains( "test 1" ) );
assertTrue( attr.contains( "Test 2" ) );
assertTrue( attr.contains( "TEST 3" ) );
}
示例4: testIsValid
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Test the isValid method
*
* The SyntaxChecker does not accept values longer than 5 chars.
*/
@Test
public void testIsValid() throws LdapInvalidAttributeValueException
{
AttributeType attribute = EntryUtils.getBytesAttributeType();
new Value( attribute, ( byte[] ) null );
new Value( attribute, Strings.EMPTY_BYTES );
new Value( attribute, new byte[]
{ 0x01, 0x02 } );
try
{
new Value( attribute, new byte[]
{ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 } );
fail();
}
catch ( LdapInvalidAttributeValueException liave )
{
assertTrue( true );
}
}
示例5: init
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
private void init( AttributeType attributeType )
{
if ( attributeType != null )
{
if ( attributeType.getSyntax() == null )
{
// Some broken LDAP servers do not have proper syntax definitions, default to HR
LOG.info( I18n.err( I18n.ERR_04445_NO_SYNTAX ) );
isHR = true;
//throw new IllegalArgumentException( I18n.err( I18n.ERR_04445_NO_SYNTAX ) );
}
else
{
isHR = attributeType.getSyntax().isHumanReadable();
}
}
else
{
LOG.warn( "The attributeType is null" );
}
this.attributeType = attributeType;
}
示例6: testCompareTo
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Test the compareTo method
*/
@Test
public void testCompareTo() throws LdapInvalidAttributeValueException
{
AttributeType at1 = EntryUtils.getBytesAttributeType();
Value v0 = new Value( at1, BYTES1 );
Value v1 = new Value( at1, BYTES1 );
assertEquals( 0, v0.compareTo( v1 ) );
assertEquals( 0, v1.compareTo( v0 ) );
Value v2 = new Value( at1, ( byte[] ) null );
assertEquals( 1, v0.compareTo( v2 ) );
assertEquals( -1, v2.compareTo( v0 ) );
}
示例7: testGetNormalizedValue
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Test the getNormValue method
*/
@Test
public void testGetNormalizedValue() throws LdapInvalidAttributeValueException
{
AttributeType attribute = EntryUtils.getIA5StringAttributeType();
Value sv = new Value( attribute, (String)null );
assertTrue( sv.isSchemaAware() );
assertNull( sv.getValue() );
assertTrue( sv.isSchemaAware() );
sv = new Value( attribute, "" );
assertTrue( sv.isSchemaAware() );
assertEquals( 0, sv.compareTo( " " ) );
assertTrue( sv.isSchemaAware() );
sv = new Value( attribute, "TEST" );
assertTrue( sv.isSchemaAware() );
assertEquals( 0, sv.compareTo( " test " ) );
}
示例8: testApply
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Test the normalize method
*/
@Test
public void testApply() throws LdapException
{
AttributeType attribute = EntryUtils.getIA5StringAttributeType();
Value sv = Value.createValue( attribute );
sv = new Value( at, sv );
assertEquals( 0, sv.compareTo( ( String ) null ) );
sv = new Value( attribute, "" );
sv = new Value( at, sv );
assertEquals( 0, sv.compareTo( " " ) );
sv = new Value( attribute, " A TEST " );
assertEquals( 0, sv.compareTo( " a test " ) );
}
示例9: setAttributeLatestValueMap
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Set the latest value map to a defined anonymizer - if it exists -.
*
* @param attributeType The AttributeType we are targetting
* @param latestValueMap The latest value map for this attribute
*/
public void setAttributeLatestValueMap( AttributeType attributeType, Map<Integer, ?> latestValueMap )
{
Anonymizer anonymizer = attributeAnonymizers.get( attributeType.getOid() );
if ( anonymizer != null )
{
if ( attributeType.getSyntax().isHumanReadable() )
{
anonymizer.setLatestStringMap( latestValueMap );
}
else
{
anonymizer.setLatestBytesMap( latestValueMap );
}
}
}
示例10: areCompatible
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Check that the upId is either a name or the OID of a given AT
*/
private boolean areCompatible( String id, AttributeType attributeType )
{
// First, get rid of the options, if any
int optPos = id.indexOf( ';' );
String idNoOption = id;
if ( optPos != -1 )
{
idNoOption = id.substring( 0, optPos );
}
// Check that we find the ID in the AT names
for ( String name : attributeType.getNames() )
{
if ( name.equalsIgnoreCase( idNoOption ) )
{
return true;
}
}
// Not found in names, check the OID
return Oid.isOid( id ) && attributeType.getOid().equals( id );
}
示例11: createStringValue
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
private Value createStringValue( AttributeType attributeType, String value )
{
Value newValue;
if ( attributeType != null )
{
try
{
newValue = new Value( attributeType, value );
}
catch ( LdapInvalidAttributeValueException iae )
{
return null;
}
}
else
{
newValue = new Value( value );
}
return newValue;
}
示例12: testCompareTo
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Test the compareTo method
*/
@Test
public void testCompareTo() throws LdapInvalidAttributeValueException
{
AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
Value v0 = new Value( at1, "Alex" );
Value v1 = new Value( at1, "ALEX" );
assertEquals( 0, v0.compareTo( v1 ) );
assertEquals( 0, v1.compareTo( v0 ) );
Value v2 = new Value( at1, (String)null );
assertEquals( 1, v0.compareTo( v2 ) );
assertEquals( -1, v2.compareTo( v0 ) );
}
示例13: removeMappingFor
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Remove the AttributeType normalizer from the OidNormalizer map
*/
@Override
public void removeMappingFor( AttributeType attributeType ) throws LdapException
{
if ( attributeType == null )
{
return;
}
oidNormalizerMap.remove( attributeType.getOid() );
// We also have to remove all the short names for this attribute
for ( String name : attributeType.getNames() )
{
oidNormalizerMap.remove( Strings.toLowerCaseAscii( name ) );
}
}
示例14: testClone
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
/**
* Test the clone method
*/
@Test
public void testClone() throws LdapException
{
AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
Value sv = new Value( at1, "Test" );
Value sv1 = sv.clone();
assertEquals( sv, sv1 );
sv = new Value( "" );
assertNotSame( sv, sv1 );
assertEquals( "", sv.getValue() );
sv = new Value( " This is a TEST " );
sv1 = sv.clone();
assertEquals( sv, sv1 );
assertEquals( sv, sv1 );
}
示例15: loadAttributeTypes
import org.apache.directory.api.ldap.model.schema.AttributeType; //导入依赖的package包/类
private void loadAttributeTypes( Attribute attributeTypes ) throws LdapException
{
if ( attributeTypes == null )
{
return;
}
for ( Value value : attributeTypes )
{
String desc = value.getValue();
try
{
AttributeType attributeType = AT_DESCR_SCHEMA_PARSER.parseAttributeTypeDescription( desc );
updateSchemas( attributeType );
}
catch ( ParseException pe )
{
throw new LdapException( pe );
}
}
}