use of ucar.units_vcell.QuantityDimension in project vcell by virtualcell.
the class InternalUnitDefinition method showUChar.
/**
* Insert the method's description here.
* Creation date: (4/14/2004 5:48:29 PM)
* @param obj java.lang.Object
*/
private static void showUChar(String pad, String attribute, Object obj) {
if (obj == null || obj instanceof String || obj instanceof Boolean || obj instanceof Double || obj instanceof Number || // to make much less verbose
obj instanceof Factor || obj instanceof QuantityDimension) {
// to make much less verbose
System.out.println(pad + attribute + " = " + obj);
return;
} else {
System.out.println(pad + attribute + " = " + ((obj != null) ? (obj.getClass().getName() + "@" + Integer.toHexString(obj.hashCode()) + " '" + obj + "'") : ("null")));
}
pad += " ";
if (obj instanceof ucar.units_vcell.UnitImpl) {
ucar.units_vcell.UnitImpl unitImpl = (ucar.units_vcell.UnitImpl) obj;
if (unitImpl.getDerivedUnit() != obj) {
// stops infinite recursion
showUChar(pad, "derivedUnit", unitImpl.getDerivedUnit());
}
showUChar(pad, "name", unitImpl.getName());
// showUChar(pad,"plural",unitImpl.getPlural());
showUChar(pad, "symbol", unitImpl.getSymbol());
showUChar(pad, "unitname", unitImpl.getUnitName());
showUChar(pad, "isDimensionless", new Boolean(unitImpl.isDimensionless()));
if (unitImpl instanceof DerivedUnitImpl) {
DerivedUnitImpl derivedUnitImpl = (DerivedUnitImpl) unitImpl;
if (!(derivedUnitImpl instanceof BaseUnit)) {
// stops infinite recursion
showUChar(pad, "unitDimension", derivedUnitImpl.getDimension());
}
showUChar(pad, "quantityDimension", derivedUnitImpl.getQuantityDimension());
if (derivedUnitImpl instanceof ucar.units_vcell.BaseUnit) {
ucar.units_vcell.BaseUnit baseUnit = (ucar.units_vcell.BaseUnit) derivedUnitImpl;
showUChar(pad, "baseQuantity", baseUnit.getBaseQuantity());
showUChar(pad, "id", baseUnit.getID());
}
} else if (unitImpl instanceof OffsetUnit) {
OffsetUnit offsetUnit = (OffsetUnit) unitImpl;
showUChar(pad, "offset", new Double(offsetUnit.getOffset()));
if (offsetUnit.getUnit() == offsetUnit.getDerivedUnit()) {
showUChar(pad, "unit", offsetUnit.getUnit().getClass().getName() + "@" + Integer.toHexString(offsetUnit.hashCode()) + " '" + obj + "' <<<<REPEATED>>>>");
} else {
showUChar(pad, "unit", offsetUnit.getUnit());
}
} else if (unitImpl instanceof ScaledUnit) {
ScaledUnit scaledUnit = (ScaledUnit) unitImpl;
showUChar(pad, "scale", new Double(scaledUnit.getScale()));
if (scaledUnit.getUnit() == scaledUnit.getDerivedUnit()) {
showUChar(pad, "unit", scaledUnit.getUnit().getClass().getName() + "@" + Integer.toHexString(scaledUnit.hashCode()) + " '" + obj + "' <<<<REPEATED>>>>");
} else {
showUChar(pad, "unit", scaledUnit.getUnit());
}
} else if (unitImpl instanceof TimeScaleUnit) {
TimeScaleUnit timeScaleUnit = (TimeScaleUnit) unitImpl;
showUChar(pad, "origin", timeScaleUnit.getOrigin());
if (timeScaleUnit.getUnit() == timeScaleUnit.getDerivedUnit()) {
showUChar(pad, "unit", timeScaleUnit.getUnit().getClass().getName() + "@" + Integer.toHexString(timeScaleUnit.hashCode()) + " '" + obj + "' <<<<REPEATED>>>>");
} else {
showUChar(pad, "unit", timeScaleUnit.getUnit());
}
}
} else if (obj instanceof UnitName) {
UnitName unitName = (UnitName) obj;
showUChar(pad, "name", unitName.getName());
// showUChar(pad,"plural",unitName.getPlural());
showUChar(pad, "symbol", unitName.getSymbol());
} else if (obj instanceof Dimension) {
Dimension dimension = (Dimension) obj;
Factor[] factors = dimension.getFactors();
if (factors == null || factors.length == 0) {
showUChar(pad, "factors", null);
} else {
for (int i = 0; i < factors.length; i++) {
showUChar(pad, "factors[" + i + "]", factors[i]);
}
}
// showUChar(pad,"rank",new Integer(dimension.getRank())); // adds nothing
showUChar(pad, "isDimensionless", new Boolean(dimension.isDimensionless()));
if (dimension instanceof UnitDimension) {
UnitDimension unitDimension = (UnitDimension) dimension;
showUChar(pad, "quantityDimension", unitDimension.getQuantityDimension());
}
} else if (obj instanceof Factor) {
Factor factor = (Factor) obj;
// to make much less verbose
showUChar(pad, "base", factor.getBase().toString());
showUChar(pad, "exponent", factor.getExponent());
showUChar(pad, "ID", factor.getID());
showUChar(pad, "isDimensionless", new Boolean(factor.isDimensionless()));
} else if (obj instanceof Base) {
Base base = (Base) obj;
showUChar(pad, "ID", base.getID());
showUChar(pad, "isDimensionless", new Boolean(base.isDimensionless()));
if (base instanceof BaseQuantity) {
BaseQuantity baseQuantity = (BaseQuantity) base;
showUChar(pad, "name", baseQuantity.getName());
showUChar(pad, "symbol", baseQuantity.getSymbol());
}
}
}
Aggregations