1 10 11 package com.hp.hpl.jena.datatypes; 12 13 import com.hp.hpl.jena.graph.impl.LiteralLabel; 14 15 22 public class BaseDatatype implements RDFDatatype { 23 24 25 protected String uri; 26 27 31 public BaseDatatype(String uri) { 32 this.uri = uri; 33 } 34 35 38 public String getURI() { 39 return uri; 40 } 41 42 46 public String unparse(Object value) { 47 return value.toString(); 48 } 49 50 54 public Object parse(String lexicalForm) throws DatatypeFormatException { 55 return lexicalForm; 56 } 57 58 62 public boolean isValid(String lexicalForm) { 63 try { 64 parse(lexicalForm); 65 return true; 66 } catch (DatatypeFormatException e) { 67 return false; 68 } 69 } 70 71 78 public boolean isValidLiteral(LiteralLabel lit) { 79 return equals(lit.getDatatype()); 81 } 82 83 87 public boolean isValidValue(Object valueForm) { 88 return isValid(unparse(valueForm)); 90 } 91 92 96 public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { 97 return value1.getDatatype() == value2.getDatatype() 98 && value1.getValue().equals(value2.getValue()); 99 } 100 101 104 public boolean langTagCompatible(LiteralLabel value1, LiteralLabel value2) { 105 if (value1.language() == null) { 106 return (value2.language() == null || value2.language().equals("")); 107 } else { 108 return value1.language().equalsIgnoreCase(value2.language()); 109 } 110 } 111 112 116 public Class getJavaClass() { 117 return null; 118 } 119 120 126 public Object extendedTypeDefinition() { 127 return null; 128 } 129 130 133 public String toString() { 134 return "Datatype[" + uri 135 + (getJavaClass() == null ? "" : " -> " + getJavaClass()) 136 + "]"; 137 } 138 } 139 140 169 | Popular Tags |