001 package com.thaiopensource.relaxng.impl;
002
003 import com.thaiopensource.datatype.Datatype2;
004 import org.relaxng.datatype.DatatypeException;
005 import org.relaxng.datatype.DatatypeStreamingValidator;
006 import org.relaxng.datatype.ValidationContext;
007 import org.relaxng.datatype.helpers.StreamingValidatorImpl;
008
009 class StringDatatype implements Datatype2 {
010 public boolean isValid(String str, ValidationContext vc) {
011 return true;
012 }
013
014 public void checkValid(String str, ValidationContext vc) throws DatatypeException {
015 if (!isValid(str, vc))
016 throw new DatatypeException();
017 }
018
019 public Object createValue(String str, ValidationContext vc) {
020 return str;
021 }
022
023 public boolean isContextDependent() {
024 return false;
025 }
026
027 public boolean alwaysValid() {
028 return true;
029 }
030
031 public int getIdType() {
032 return ID_TYPE_NULL;
033 }
034
035 public boolean sameValue(Object obj1, Object obj2) {
036 return obj1.equals(obj2);
037 }
038
039 public int valueHashCode(Object obj) {
040 return obj.hashCode();
041 }
042
043 public DatatypeStreamingValidator createStreamingValidator(ValidationContext vc) {
044 return new StreamingValidatorImpl(this, vc);
045 }
046 }