Make HopObject properties case sensitive.

This commit is contained in:
hns 2008-10-17 14:18:24 +00:00
parent bff550c6d9
commit 0e7c4354c9
5 changed files with 33 additions and 96 deletions

View file

@ -610,8 +610,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public IProperty get(String propname) { public IProperty get(String propname) {
propname = propname.toLowerCase();
return getProperty(propname); return getProperty(propname);
} }
@ -637,8 +635,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public String getString(String propname) { public String getString(String propname) {
propname = propname.toLowerCase();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -657,8 +653,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public long getInteger(String propname) { public long getInteger(String propname) {
propname = propname.toLowerCase();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -677,8 +671,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public double getFloat(String propname) { public double getFloat(String propname) {
propname = propname.toLowerCase();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -697,8 +689,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public Date getDate(String propname) { public Date getDate(String propname) {
propname = propname.toLowerCase();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -717,8 +707,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public boolean getBoolean(String propname) { public boolean getBoolean(String propname) {
propname = propname.toLowerCase();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -737,8 +725,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public INode getNode(String propname) { public INode getNode(String propname) {
propname = propname.toLowerCase();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -757,8 +743,6 @@ public class TransientNode implements INode, Serializable {
* @return ... * @return ...
*/ */
public Object getJavaObject(String propname) { public Object getJavaObject(String propname) {
propname = propname.toLowerCase();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -776,13 +760,11 @@ public class TransientNode implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
Property prop = (Property) propMap.get(propname);
String p2 = propname.toLowerCase();
Property prop = (Property) propMap.get(p2);
if (prop == null) { if (prop == null) {
prop = new Property(propname, this); prop = new Property(propname, this);
propMap.put(p2, prop); propMap.put(propname, prop);
} }
return prop; return prop;
@ -917,21 +899,12 @@ public class TransientNode implements INode, Serializable {
* @param propname ... * @param propname ...
*/ */
public void unset(String propname) { public void unset(String propname) {
if (propMap == null) { if (propMap != null && propname != null) {
return; propMap.remove(propname);
}
try {
propMap.remove(propname.toLowerCase());
lastmodified = System.currentTimeMillis(); lastmodified = System.currentTimeMillis();
} catch (Exception ignore) {
} }
} }
/* public String getUrl (INode root, INode users, String tmpname, String rootproto) {
throw new RuntimeException ("HREFs on transient (non-db based) Nodes not supported");
} */
public long lastModified() { public long lastModified() {
return lastmodified; return lastmodified;
} }

View file

@ -307,7 +307,7 @@ public final class DbMapping {
String dbField = props.getProperty(propName); String dbField = props.getProperty(propName);
// check if a relation for this propery already exists. If so, reuse it // check if a relation for this propery already exists. If so, reuse it
Relation rel = (Relation) prop2db.get(propName.toLowerCase()); Relation rel = (Relation) prop2db.get(propName);
if (rel == null) { if (rel == null) {
rel = new Relation(propName, this); rel = new Relation(propName, this);
@ -317,7 +317,7 @@ public final class DbMapping {
// store relation with lower case property name // store relation with lower case property name
// (ResourceProperties now preserve key capitalization!) // (ResourceProperties now preserve key capitalization!)
p2d.put(propName.toLowerCase(), rel); p2d.put(propName, rel);
if ((rel.columnName != null) && rel.isPrimitiveOrReference()) { if ((rel.columnName != null) && rel.isPrimitiveOrReference()) {
Relation old = (Relation) d2p.put(rel.columnName.toLowerCase(), rel); Relation old = (Relation) d2p.put(rel.columnName.toLowerCase(), rel);
@ -631,8 +631,7 @@ public final class DbMapping {
return null; return null;
} }
// prop2db stores keys in lower case return _propertyToColumnName(propName);
return _propertyToColumnName(propName.toLowerCase());
} }
private String _propertyToColumnName(final String propName) { private String _propertyToColumnName(final String propName) {
@ -678,9 +677,7 @@ public final class DbMapping {
return null; return null;
} }
// FIXME: prop2db stores keys in lower case, because it gets them return _propertyToRelation(propName);
// from a SystemProperties object which converts keys to lower case.
return _propertyToRelation(propName.toLowerCase());
} }
private Relation _propertyToRelation(String propName) { private Relation _propertyToRelation(String propName) {
@ -866,7 +863,7 @@ public final class DbMapping {
return null; return null;
} }
Relation rel = (Relation) prop2db.get(propname.toLowerCase()); Relation rel = (Relation) prop2db.get(propname);
if ((rel == null) && (parentMapping != null)) { if ((rel == null) && (parentMapping != null)) {
rel = parentMapping.getExactPropertyRelation(propname); rel = parentMapping.getExactPropertyRelation(propname);

View file

@ -1776,12 +1776,10 @@ public final class Node implements INode, Serializable {
} }
Relation rel = dbmap == null ? Relation rel = dbmap == null ?
null : null : dbmap.getExactPropertyRelation(propname);
dbmap.getExactPropertyRelation(propname);
// 1) check if the property is contained in the propMap // 1) check if the property is contained in the propMap
Property prop = propMap == null ? null : Property prop = propMap == null ? null : (Property) propMap.get(propname);
(Property) propMap.get(propname.toLowerCase());
if (prop != null) { if (prop != null) {
if (rel != null) { if (rel != null) {
@ -1813,7 +1811,7 @@ public final class Node implements INode, Serializable {
n.setDbMapping(rel.getVirtualMapping()); n.setDbMapping(rel.getVirtualMapping());
n.setParent(this); n.setParent(this);
setNode(propname, n); setNode(propname, n);
return (Property) propMap.get(propname.toLowerCase()); return (Property) propMap.get(propname);
} }
// 2) check if this is a create-on-demand node property // 2) check if this is a create-on-demand node property
@ -1845,7 +1843,6 @@ public final class Node implements INode, Serializable {
* @return ... * @return ...
*/ */
public String getString(String propname) { public String getString(String propname) {
// propname = propname.toLowerCase ();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -1864,7 +1861,6 @@ public final class Node implements INode, Serializable {
* @return ... * @return ...
*/ */
public long getInteger(String propname) { public long getInteger(String propname) {
// propname = propname.toLowerCase ();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -1883,7 +1879,6 @@ public final class Node implements INode, Serializable {
* @return ... * @return ...
*/ */
public double getFloat(String propname) { public double getFloat(String propname) {
// propname = propname.toLowerCase ();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -1902,7 +1897,6 @@ public final class Node implements INode, Serializable {
* @return ... * @return ...
*/ */
public Date getDate(String propname) { public Date getDate(String propname) {
// propname = propname.toLowerCase ();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -1921,7 +1915,6 @@ public final class Node implements INode, Serializable {
* @return ... * @return ...
*/ */
public boolean getBoolean(String propname) { public boolean getBoolean(String propname) {
// propname = propname.toLowerCase ();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -1940,7 +1933,6 @@ public final class Node implements INode, Serializable {
* @return ... * @return ...
*/ */
public INode getNode(String propname) { public INode getNode(String propname) {
// propname = propname.toLowerCase ();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -1959,7 +1951,6 @@ public final class Node implements INode, Serializable {
* @return ... * @return ...
*/ */
public Object getJavaObject(String propname) { public Object getJavaObject(String propname) {
// propname = propname.toLowerCase ();
Property prop = getProperty(propname); Property prop = getProperty(propname);
try { try {
@ -1984,17 +1975,14 @@ public final class Node implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
Property prop = (Property) propMap.get(propname);
String p2 = propname.toLowerCase();
Property prop = (Property) propMap.get(p2);
if (prop != null) { if (prop != null) {
prop.setValue(value, type); prop.setValue(value, type);
} else { } else {
prop = new Property(propname, this); prop = new Property(propname, this);
prop.setValue(value, type); prop.setValue(value, type);
propMap.put(p2, prop); propMap.put(propname, prop);
} }
lastmodified = System.currentTimeMillis(); lastmodified = System.currentTimeMillis();
@ -2019,10 +2007,7 @@ public final class Node implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
Property prop = (Property) propMap.get(propname);
String p2 = propname.toLowerCase();
Property prop = (Property) propMap.get(p2);
String oldvalue = null; String oldvalue = null;
if (prop != null) { if (prop != null) {
@ -2037,7 +2022,7 @@ public final class Node implements INode, Serializable {
} else { } else {
prop = new Property(propname, this); prop = new Property(propname, this);
prop.setStringValue(value); prop.setStringValue(value);
propMap.put(p2, prop); propMap.put(propname, prop);
} }
if (dbmap != null) { if (dbmap != null) {
@ -2130,17 +2115,14 @@ public final class Node implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
Property prop = (Property) propMap.get(propname);
String p2 = propname.toLowerCase();
Property prop = (Property) propMap.get(p2);
if (prop != null) { if (prop != null) {
prop.setIntegerValue(value); prop.setIntegerValue(value);
} else { } else {
prop = new Property(propname, this); prop = new Property(propname, this);
prop.setIntegerValue(value); prop.setIntegerValue(value);
propMap.put(p2, prop); propMap.put(propname, prop);
} }
notifyPropertyChange(propname); notifyPropertyChange(propname);
@ -2167,17 +2149,14 @@ public final class Node implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
Property prop = (Property) propMap.get(propname);
String p2 = propname.toLowerCase();
Property prop = (Property) propMap.get(p2);
if (prop != null) { if (prop != null) {
prop.setFloatValue(value); prop.setFloatValue(value);
} else { } else {
prop = new Property(propname, this); prop = new Property(propname, this);
prop.setFloatValue(value); prop.setFloatValue(value);
propMap.put(p2, prop); propMap.put(propname, prop);
} }
notifyPropertyChange(propname); notifyPropertyChange(propname);
@ -2204,17 +2183,14 @@ public final class Node implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
Property prop = (Property) propMap.get(propname);
String p2 = propname.toLowerCase();
Property prop = (Property) propMap.get(p2);
if (prop != null) { if (prop != null) {
prop.setBooleanValue(value); prop.setBooleanValue(value);
} else { } else {
prop = new Property(propname, this); prop = new Property(propname, this);
prop.setBooleanValue(value); prop.setBooleanValue(value);
propMap.put(p2, prop); propMap.put(propname, prop);
} }
notifyPropertyChange(propname); notifyPropertyChange(propname);
@ -2241,17 +2217,14 @@ public final class Node implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
Property prop = (Property) propMap.get(propname);
String p2 = propname.toLowerCase();
Property prop = (Property) propMap.get(p2);
if (prop != null) { if (prop != null) {
prop.setDateValue(value); prop.setDateValue(value);
} else { } else {
prop = new Property(propname, this); prop = new Property(propname, this);
prop.setDateValue(value); prop.setDateValue(value);
propMap.put(p2, prop); propMap.put(propname, prop);
} }
notifyPropertyChange(propname); notifyPropertyChange(propname);
@ -2278,17 +2251,14 @@ public final class Node implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
Property prop = (Property) propMap.get(propname);
String p2 = propname.toLowerCase();
Property prop = (Property) propMap.get(p2);
if (prop != null) { if (prop != null) {
prop.setJavaObjectValue(value); prop.setJavaObjectValue(value);
} else { } else {
prop = new Property(propname, this); prop = new Property(propname, this);
prop.setJavaObjectValue(value); prop.setJavaObjectValue(value);
propMap.put(p2, prop); propMap.put(propname, prop);
} }
notifyPropertyChange(propname); notifyPropertyChange(propname);
@ -2366,9 +2336,6 @@ public final class Node implements INode, Serializable {
} }
propname = propname.trim(); propname = propname.trim();
String p2 = propname.toLowerCase();
if (rel == null && dbmap != null) { if (rel == null && dbmap != null) {
// widen relation to non-exact (collection) mapping // widen relation to non-exact (collection) mapping
rel = dbmap.getPropertyRelation(propname); rel = dbmap.getPropertyRelation(propname);
@ -2383,7 +2350,7 @@ public final class Node implements INode, Serializable {
} }
} }
Property prop = (propMap == null) ? null : (Property) propMap.get(p2); Property prop = (propMap == null) ? null : (Property) propMap.get(propname);
if (prop != null) { if (prop != null) {
if ((prop.getType() == IProperty.NODE) && if ((prop.getType() == IProperty.NODE) &&
@ -2415,7 +2382,7 @@ public final class Node implements INode, Serializable {
propMap = new Hashtable(); propMap = new Hashtable();
} }
propMap.put(p2, prop); propMap.put(propname, prop);
if (state == CLEAN && isPersistable) { if (state == CLEAN && isPersistable) {
markAs(MODIFIED); markAs(MODIFIED);
@ -2465,9 +2432,9 @@ public final class Node implements INode, Serializable {
if (propMap != null) { if (propMap != null) {
if (relational) { if (relational) {
p = (Property) propMap.get(propname.toLowerCase()); p = (Property) propMap.get(propname);
} else { } else {
p = (Property) propMap.remove(propname.toLowerCase()); p = (Property) propMap.remove(propname);
} }
} }

View file

@ -1896,7 +1896,7 @@ public final class NodeManager {
// FIXME: References to anything other than the primary key are not supported // FIXME: References to anything other than the primary key are not supported
prop.convertToNodeReference(rel); prop.convertToNodeReference(rel);
} }
propMap.put(rel.propName.toLowerCase(), prop); propMap.put(rel.propName, prop);
} }
} }

View file

@ -144,7 +144,7 @@ public final class XmlDatabaseReader extends DefaultHandler implements XmlConsta
currentNode.setPropMap(propMap); currentNode.setPropMap(propMap);
} }
propMap.put(propName.toLowerCase(), prop); propMap.put(propName, prop);
} }
} else { } else {
// a primitive property // a primitive property
@ -233,7 +233,7 @@ public final class XmlDatabaseReader extends DefaultHandler implements XmlConsta
currentNode.setPropMap(propMap); currentNode.setPropMap(propMap);
} }
propMap.put(elementName.toLowerCase(), prop); propMap.put(elementName, prop);
elementName = null; elementName = null;
elementType = null; elementType = null;
charValue = null; charValue = null;