Changeset 213 for VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/query/EntityNode.java
- Timestamp:
- 03/03/10 20:21:17 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/query/EntityNode.java
r190 r213 6 6 7 7 class EntityNode extends CommonTree implements ParseTreeNode { 8 private String entity; 8 public static enum Entity { VC, CREATOR }; 9 private Entity entity; 9 10 private String property; 10 11 11 12 public EntityNode(int type, Token entity, Token property) { 12 13 super(new CommonToken(type, "ENTITY")); 13 // check values for sanity! 14 this.entity = entity.getText(); 15 this.property = property.getText(); 14 this.entity = entityFromString(entity.getText()); 15 this.property = propertyFromString(property.getText()); 16 16 } 17 17 18 public StringgetEntity() {18 public Entity getEntity() { 19 19 return entity; 20 20 } … … 28 28 } 29 29 30 private static Entity entityFromString(String s) { 31 if (s == null) { 32 throw new NullPointerException("s == null"); 33 } 34 s = s.trim(); 35 if (s.equalsIgnoreCase("vc")) { 36 return Entity.VC; 37 } else if (s.equalsIgnoreCase("creator")) { 38 return Entity.CREATOR; 39 } else { 40 throw new IllegalArgumentException("unknown entity: " + s); 41 } 42 } 43 44 private static String propertyFromString(String s) { 45 if (s != null) { 46 s = s.trim(); 47 } 48 if ((s == null) || (s.length() < 1)) { 49 throw new IllegalArgumentException("property is null or empty"); 50 } 51 return s.toLowerCase(); 52 } 53 30 54 } // class EntityNode
Note: See TracChangeset
for help on using the changeset viewer.