PropertyValuePrinter.java revision c7adcf7755f9492075a6cc9ad913a0c5a3d2d46c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
/**
* A class responsible for displaying property values. This class
* takes care of using locale specific formatting rules.
*/
final class PropertyValuePrinter {
/**
* Perform property type specific print formatting.
*/
private static class MyPropertyValueVisitor extends
// The requested size unit (null if the property's unit should be
// used).
// The requested time unit (null if the property's unit should be
// used).
private final DurationUnit timeUnit;
// Whether or not values should be displayed in a script-friendly
// manner.
private final boolean isScriptFriendly;
// The formatter to use for numeric values.
private final NumberFormat numberFormat;
// Private constructor.
boolean isScriptFriendly) {
this.isScriptFriendly = isScriptFriendly;
if (this.isScriptFriendly) {
numberFormat.setGroupingUsed(false);
} else {
numberFormat.setGroupingUsed(true);
}
}
/**
* {@inheritDoc}
*/
return "unlimited";
}
// Use human-readable string representation by default.
}
// Use either the specified unit or the property definition's
// base unit.
unit = d.getBaseUnit();
}
}
/**
* {@inheritDoc}
*/
if (d.isAllowUnlimited() && v < 0) {
return "unlimited";
}
if (isScriptFriendly) {
// Assume users want a more accurate value.
} else {
}
}
}
/**
* {@inheritDoc}
*/
// For all other property definition types the default encoding
// will do.
return d.encodeValue(v);
}
}
// The property value printer implementation.
private final MyPropertyValueVisitor pimpl;
/**
* Creates a new property value printer.
*
* @param sizeUnit
* The user requested size unit or <code>null</code> if
* best-fit.
* @param timeUnit
* The user requested time unit or <code>null</code> if
* best-fit.
* @param isScriptFriendly
* If values should be displayed in a script friendly
* manner.
*/
boolean isScriptFriendly) {
}
/**
* Print a property value according to the rules of this property
* value printer.
*
* @param <T>
* The type of property value.
* @param pd
* The property definition.
* @param value
* The property value.
* @return Returns the string representation of the property value
* encoded according to the rules of this property value
* printer.
*/
}
}