1 5 6 package org.exoplatform.services.jcr.impl.core.nodetype; 7 8 import javax.jcr.nodetype.PropertyDef; 9 import javax.jcr.nodetype.NodeType; 10 import javax.jcr.Value; 11 import javax.jcr.nodetype.NoSuchNodeTypeException; 12 import javax.jcr.PropertyType; 13 import javax.jcr.version.OnParentVersionAction; 14 15 21 22 public class PropertyDefImpl implements PropertyDef { 23 24 private String name; 25 private String declaringNodeType; 26 private int requiredType; 27 private String valueConstraint; 28 private Value defaultValue; 29 private boolean autoCreate; 30 private boolean mandatory; 31 private int onVersion; 32 private boolean readOnly; 33 private boolean primaryItem; 34 private boolean multiple; 35 36 public PropertyDefImpl(String name, String declaringNodeType, int requiredType, 37 String valueConstraint, Value defaultValue, boolean autoCreate, boolean mandatory, 38 int onVersion, boolean readOnly, boolean primaryItem, boolean multiple) { 39 40 this.name = name; 41 this.declaringNodeType = declaringNodeType; 42 this.requiredType = requiredType; 43 this.valueConstraint = valueConstraint; 44 this.defaultValue = defaultValue; 45 this.autoCreate = autoCreate; 46 this.mandatory = mandatory; 47 this.onVersion = onVersion; 48 this.readOnly = readOnly; 49 this.primaryItem = primaryItem; 50 this.multiple = multiple; 51 } 52 53 public PropertyDefImpl(String declaringNodeType) { 55 56 this.name = null; 57 this.declaringNodeType = declaringNodeType; 58 this.requiredType = PropertyType.UNDEFINED; 59 this.valueConstraint = null; 60 this.defaultValue = null; 61 this.autoCreate = false; 62 this.mandatory = false; 63 this.onVersion = OnParentVersionAction.IGNORE; 64 this.readOnly = false; 65 this.primaryItem = false; 66 this.multiple = true; 67 } 68 69 77 public String getName() { 78 return name; 79 } 80 81 85 public NodeType getDeclaringNodeType() { 86 try { 87 return NodeTypeManagerImpl.getInstance().getNodeType(declaringNodeType); 88 } catch (NoSuchNodeTypeException e) { 89 throw new RuntimeException (e.getMessage()); 90 } 91 } 92 93 94 101 public int getRequiredType() { 102 return requiredType; 103 } 104 105 116 public String getValueConstraint() { 117 return valueConstraint; 118 } 119 120 123 public Value getDefaultValue() { 124 return defaultValue; 125 } 126 127 130 public boolean isAutoCreate() { 131 return autoCreate; 132 } 133 134 137 public boolean isMandatory() { 138 return mandatory; 139 } 140 141 144 public int getOnParentVersion() { 145 return onVersion; 146 } 147 148 151 public boolean isReadOnly() { 152 return readOnly; 153 } 154 155 158 public boolean isPrimaryItem() { 159 return primaryItem; 160 } 161 162 165 public boolean isMultiple() { 166 return multiple; 167 } 168 169 public String toString() { 170 return "PropertyDefImpl: " + name; 171 } 172 173 public boolean equals(Object obj) { 174 if (obj == null) 175 return false; 176 if (!(obj instanceof PropertyDefImpl)) 177 return false; 178 if (this.getName() == null) 179 return ((PropertyDefImpl) obj).getName() == null; 180 return this.getName().equals(((PropertyDefImpl) obj).getName()); 181 } 182 183 } 184 | Popular Tags |