1 20 21 package org.apache.directory.ldapstudio.browser.core.model.ldif.lines; 22 23 24 import java.io.Serializable ; 25 26 import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants; 27 import org.apache.directory.ldapstudio.browser.core.utils.LdifUtils; 28 29 30 public class LdifAttrValLine extends LdifValueLineBase implements Serializable 31 { 32 33 private static final long serialVersionUID = 2818131653565822685L; 34 35 36 protected LdifAttrValLine() 37 { 38 } 39 40 41 public LdifAttrValLine( int offset, String attributeDescripton, String valueType, String value, String newLine ) 42 { 43 super( offset, attributeDescripton, valueType, value, newLine ); 44 } 45 46 47 public String getRawAttributeDescription() 48 { 49 return super.getRawLineStart(); 50 } 51 52 53 public String getUnfoldedAttributeDescription() 54 { 55 return super.getUnfoldedLineStart(); 56 } 57 58 59 public boolean isValid() 60 { 61 return super.isValid(); 62 } 63 64 65 public String getInvalidString() 66 { 67 if ( this.getUnfoldedAttributeDescription().length() == 0 ) 68 { 69 return "Missing attribute name"; 70 } 71 else 72 { 73 return super.getInvalidString(); 74 } 75 } 76 77 78 public static LdifAttrValLine create( String name, String value ) 79 { 80 if ( LdifUtils.mustEncode( value ) ) 81 { 82 return create( name, LdifUtils.utf8encode( value ) ); 83 } 84 else 85 { 86 return new LdifAttrValLine( 0, name, ":", value, BrowserCoreConstants.LINE_SEPARATOR ); 87 } 88 } 89 90 91 public static LdifAttrValLine create( String name, byte[] value ) 92 { 93 return new LdifAttrValLine( 0, name, "::", LdifUtils.base64encode( value ), BrowserCoreConstants.LINE_SEPARATOR ); 94 } 95 96 } 97 | Popular Tags |