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 LdifChangeTypeLine extends LdifValueLineBase 28 { 29 30 private static final long serialVersionUID = 8613980677301250589L; 31 32 33 protected LdifChangeTypeLine() 34 { 35 } 36 37 38 public LdifChangeTypeLine( int offset, String rawChangeTypeSpec, String rawValueType, String rawChangeType, 39 String rawNewLine ) 40 { 41 super( offset, rawChangeTypeSpec, rawValueType, rawChangeType, rawNewLine ); 42 } 43 44 45 public String getRawChangeTypeSpec() 46 { 47 return super.getRawLineStart(); 48 } 49 50 51 public String getUnfoldedChangeTypeSpec() 52 { 53 return super.getUnfoldedLineStart(); 54 } 55 56 57 public String getRawChangeType() 58 { 59 return super.getRawValue(); 60 } 61 62 63 public String getUnfoldedChangeType() 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.getUnfoldedChangeType().equals( "add" ); 78 } 79 80 81 public boolean isDelete() 82 { 83 return this.getUnfoldedChangeType().equals( "delete" ); 84 } 85 86 87 public boolean isModify() 88 { 89 return this.getUnfoldedChangeType().equals( "modify" ); 90 } 91 92 93 public boolean isModDn() 94 { 95 return this.getUnfoldedChangeType().equals( "moddn" ) || this.getUnfoldedChangeType().equals( "modrdn" ); 96 } 97 98 99 public boolean isValid() 100 { 101 return super.isValid(); 102 } 103 104 105 public String getInvalidString() 106 { 107 if ( this.getUnfoldedChangeTypeSpec().length() == 0 ) 108 { 109 return "Missing spec 'changetype'"; 110 } 111 else if ( this.getUnfoldedChangeType().length() == 0 ) 112 { 113 return "Missing changetype"; 114 } 115 else 116 { 117 return super.getInvalidString(); 118 } 119 } 120 121 122 public static LdifChangeTypeLine createDelete() 123 { 124 return new LdifChangeTypeLine( 0, "changetype", ":", "delete", BrowserCoreConstants.LINE_SEPARATOR ); 125 } 126 127 128 public static LdifChangeTypeLine createAdd() 129 { 130 return new LdifChangeTypeLine( 0, "changetype", ":", "add", BrowserCoreConstants.LINE_SEPARATOR ); 131 } 132 133 134 public static LdifChangeTypeLine createModify() 135 { 136 return new LdifChangeTypeLine( 0, "changetype", ":", "modify", BrowserCoreConstants.LINE_SEPARATOR ); 137 } 138 139 140 public static LdifChangeTypeLine createModDn() 141 { 142 return new LdifChangeTypeLine( 0, "changetype", ":", "moddn", BrowserCoreConstants.LINE_SEPARATOR ); 143 } 144 145 146 public static LdifChangeTypeLine createModRdn() 147 { 148 return new LdifChangeTypeLine( 0, "changetype", ":", "modrdn", BrowserCoreConstants.LINE_SEPARATOR ); 149 } 150 151 } 152 | Popular Tags |