1 20 21 package org.apache.directory.ldapstudio.browser.core.model.ldif.lines; 22 23 24 import org.apache.directory.ldapstudio.browser.core.BrowserCoreConstants; 25 26 27 public class LdifModSpecTypeLine extends LdifValueLineBase 28 { 29 30 private static final long serialVersionUID = 82623220224991909L; 31 32 33 protected LdifModSpecTypeLine() 34 { 35 } 36 37 38 public LdifModSpecTypeLine( int offset, String rawModType, String rawValueType, String rawAttributeDescription, 39 String rawNewLine ) 40 { 41 super( offset, rawModType, rawValueType, rawAttributeDescription, rawNewLine ); 42 } 43 44 45 public String getRawModType() 46 { 47 return super.getRawLineStart(); 48 } 49 50 51 public String getUnfoldedModType() 52 { 53 return super.getUnfoldedLineStart(); 54 } 55 56 57 public String getRawAttributeDescription() 58 { 59 return super.getRawValue(); 60 } 61 62 63 public String getUnfoldedAttributeDescription() 64 { 65 return super.getUnfoldedValue(); 66 } 67 68 69 public String toRawString() 70 { 71 return super.toRawString(); 72 } 73 74 75 public boolean isAdd() 76 { 77 return this.getUnfoldedModType().equals( "add" ); 78 } 79 80 81 public boolean isReplace() 82 { 83 return this.getUnfoldedModType().equals( "replace" ); 84 } 85 86 87 public boolean isDelete() 88 { 89 return this.getUnfoldedModType().equals( "delete" ); 90 } 91 92 93 public boolean isValid() 94 { 95 return super.isValid() && ( this.isAdd() || this.isReplace() || this.isDelete() ); 96 } 97 98 99 public String getInvalidString() 100 { 101 if ( this.getUnfoldedModType().length() == 0 ) 102 { 103 return "Missing modification type 'add', 'replace' or 'delete'"; 104 } 105 else if ( !this.isAdd() && !this.isReplace() && !this.isDelete() ) 106 { 107 return "Invalid modification type, expected 'add', 'replace' or 'delete'"; 108 } 109 else if ( this.getUnfoldedAttributeDescription().length() == 0 ) 110 { 111 return "Missing attribute"; 112 } 113 else 114 { 115 return super.getInvalidString(); 116 } 117 } 118 119 120 public static LdifModSpecTypeLine createAdd( String attributeName ) 121 { 122 return new LdifModSpecTypeLine( 0, "add", ":", attributeName, BrowserCoreConstants.LINE_SEPARATOR ); 123 } 124 125 126 public static LdifModSpecTypeLine createReplace( String attributeName ) 127 { 128 return new LdifModSpecTypeLine( 0, "replace", ":", attributeName, BrowserCoreConstants.LINE_SEPARATOR ); 129 } 130 131 132 public static LdifModSpecTypeLine createDelete( String attributeName ) 133 { 134 return new LdifModSpecTypeLine( 0, "delete", ":", attributeName, BrowserCoreConstants.LINE_SEPARATOR ); 135 } 136 137 } 138 | Popular Tags |