本文整理汇总了Java中org.apache.directory.api.ldap.model.entry.Modification.getOperation方法的典型用法代码示例。如果您正苦于以下问题:Java Modification.getOperation方法的具体用法?Java Modification.getOperation怎么用?Java Modification.getOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.entry.Modification
的用法示例。
在下文中一共展示了Modification.getOperation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toServerModification
import org.apache.directory.api.ldap.model.entry.Modification; //导入方法依赖的package包/类
/**
* Convert a Modification to an instance of a ServerModification object.
*
* @param modificationImpl the modification instance to convert
* @param attributeType the associated attributeType
* @return a instance of a ServerModification object
*/
private static Modification toServerModification( Modification modification, AttributeType attributeType )
throws LdapException
{
Modification serverModification = new DefaultModification(
modification.getOperation(),
new DefaultAttribute( attributeType, modification.getAttribute() ) );
return serverModification;
}
示例2: toDsml
import org.apache.directory.api.ldap.model.entry.Modification; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Element toDsml( Element root )
{
Element element = super.toDsml( root );
ModifyRequest request = getDecorated();
// Dn
if ( request.getName() != null )
{
element.addAttribute( "dn", request.getName().getName() );
}
// Modifications
Collection<Modification> modifications = request.getModifications();
for ( Modification modification : modifications )
{
Element modElement = element.addElement( "modification" );
if ( modification.getAttribute() != null )
{
modElement.addAttribute( "name", modification.getAttribute().getId() );
for ( Value value : modification.getAttribute() )
{
if ( value.getValue() != null )
{
if ( ParserUtils.needsBase64Encoding( value.getValue() ) )
{
Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI );
Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI );
element.getDocument().getRootElement().add( xsdNamespace );
element.getDocument().getRootElement().add( xsiNamespace );
Element valueElement = modElement.addElement( "value" ).addText(
ParserUtils.base64Encode( value.getValue() ) );
valueElement.addAttribute( new QName( "type", xsiNamespace ), "xsd:"
+ ParserUtils.BASE64BINARY );
}
else
{
modElement.addElement( "value" ).setText( value.getValue() );
}
}
}
}
ModificationOperation operation = modification.getOperation();
if ( operation == ModificationOperation.ADD_ATTRIBUTE )
{
modElement.addAttribute( "operation", "add" );
}
else if ( operation == ModificationOperation.REPLACE_ATTRIBUTE )
{
modElement.addAttribute( "operation", "replace" );
}
else if ( operation == ModificationOperation.REMOVE_ATTRIBUTE )
{
modElement.addAttribute( "operation", "delete" );
}
}
return element;
}