001 package com.thaiopensource.relaxng.impl;
002
003 import org.relaxng.datatype.Datatype;
004
005 class DatatypeValue {
006 private final Object value;
007 private final Datatype dt;
008
009 DatatypeValue(Object value, Datatype dt) {
010 this.value = value;
011 this.dt = dt;
012 }
013
014 public int hashCode() {
015 return dt.hashCode() ^ dt.valueHashCode(value);
016 }
017
018 public boolean equals(Object obj) {
019 if (!(obj instanceof DatatypeValue))
020 return false;
021 DatatypeValue other = (DatatypeValue)obj;
022 if (other.dt != dt)
023 return false;
024 return dt.sameValue(value, other.value);
025 }
026 }