public Node (DbMapping dbm, Record rec, WrappedNodeManager nmgr) throws DataSetException {  this.nmgr = nmgr;  dbmap = dbm; String protoField= dbmap.getPrototypeField (); if (protoField != null) { Value val = rec.getValue (protoField); if (val != null && !val.isNull ()) { String protoName = val.asString (); dbmap = nmgr.getDbMapping (protoName); if (dbmap == null) {  System.err.println ("Warning: Invalid prototype name: "+protoName+" - using default"); dbmap = dbm; } } } setPrototype (dbmap.getTypeName ());  id = rec.getValue (dbmap.getIDField ()).asString ();  String nameField =  dbmap.getNameField (); name = nameField == null ? id : rec.getValue (nameField).asString (); if (name == null || name.length() == 0) name = dbmap.getTypeName() + " " + id;  if ("user".equals (prototype)) { parentHandle = new NodeHandle (new DbKey (null, "1")); anonymous = false; }
Node () {
    public Node (DbMapping dbm, Record rec, WrappedNodeManager nmgr) throws DataSetException {	this.nmgr = nmgr;	// see what prototype/DbMapping this object should use	dbmap = dbm;	String protoField= dbmap.getPrototypeField ();	if (protoField != null) {	    Value val = rec.getValue (protoField);	    if (val != null && !val.isNull ()) {	        String protoName = val.asString ();	        dbmap = nmgr.getDbMapping (protoName);	        if (dbmap == null) {	            // invalid prototype name!	            System.err.println ("Warning: Invalid prototype name: "+protoName+" - using default");	            dbmap = dbm;	        }	    }	}	setPrototype (dbmap.getTypeName ());	id = rec.getValue (dbmap.getIDField ()).asString ();	// checkWriteLock ();	String nameField =  dbmap.getNameField ();	name = nameField == null ? id : rec.getValue (nameField).asString ();	if (name == null || name.length() == 0)	    name = dbmap.getTypeName() + " " + id;	// set parent for user objects to internal userroot node	if ("user".equals (prototype)) {	    parentHandle = new NodeHandle (new DbKey (null, "1"));	    anonymous = false;	}	created = lastmodified = System.currentTimeMillis ();	for (Iterator i=dbmap.getDBPropertyIterator(); i.hasNext(); ) {	    Relation rel = (Relation) i.next ();	    // NOTE: this should never be the case, since we're just looping through	    // mappnigs with a local db column	    if (rel.reftype != Relation.PRIMITIVE && rel.reftype != Relation.REFERENCE)	        continue;	    Value val = rec.getValue (rel.getDbField ());	    // if (val.isNull ())	    //     continue;	    Property newprop = new Property (rel.propName, this);	    if (val.isNull ())	        newprop.setStringValue (null);	    else switch (val.type ()) {	        case Types.BIT:	            newprop.setBooleanValue (val.asBoolean());	            break;	        case Types.TINYINT:	        case Types.BIGINT:	        case Types.SMALLINT:	        case Types.INTEGER:	            newprop.setIntegerValue (val.asLong());	            break;	        case Types.REAL:	        case Types.FLOAT:	        case Types.DOUBLE:	            newprop.setFloatValue (val.asDouble());	            break;	        case Types.DECIMAL:	        case Types.NUMERIC:	            java.math.BigDecimal num = val.asBigDecimal ();	            if (num.scale() > 0)	                newprop.setFloatValue (val.asDouble());	            else	                newprop.setIntegerValue (val.asLong());	            break;	        case Types.LONGVARBINARY:	        case Types.VARBINARY:	        case Types.BINARY:	            newprop.setStringValue (val.asString());	            break;	        case Types.LONGVARCHAR:	        case Types.CHAR:	        case Types.VARCHAR:	        case Types.OTHER:	            newprop.setStringValue (val.asString());	            break;	        case Types.DATE:	        case Types.TIME:	        case Types.TIMESTAMP:	            newprop.setDateValue (val.asTimestamp());	            break;	        case Types.NULL:	            newprop.setStringValue (null);	            break;	            // continue;	        default:	            newprop.setStringValue (val.asString());	            break;	    }	    if(propMap == null)	        propMap = new Hashtable ();	    propMap.put (rel.propName.toLowerCase(), newprop);	    // if the property is a pointer to another node, change the property type to NODE	    if (rel.reftype == Relation.REFERENCE && rel.usesPrimaryKey ()) {	        // FIXME: References to anything other than the primary key are not supported	        newprop.convertToNodeReference (rel.otherType);	        // newprop.nhandle = new NodeHandle (new DbKey (rel.otherType, newprop.getStringValue ()));	        // newprop.type = IProperty.NODE;	    }	    // mark property as clean, since it's fresh from the db	    newprop.dirty = false;	}	// again set created and lastmodified. This is because	// lastmodified has been been updated, and we want both values to	// be identical to show that the node hasn't been changed since	// it was first created.	created = lastmodified = System.currentTimeMillis ();	markAs (CLEAN);    }