Exemplo n.º 1
0
 /* (non-Javadoc)
  * @see com.thoughtworks.xstream.converters.SingleValueConverter#fromString(java.lang.String)
  */
 @Override
 public Object fromString(String str) {
   Unit unit = unitToStringMap.getKey(str);
   if (unit == null) {
     String msg = "Unknown unit value string: " + str;
     throw new ConversionException(msg);
   }
   return unit;
 }
Exemplo n.º 2
0
 static {
   unitToStringMap.put(AbsoluteTimeUnit.SECOND, "absoluteSecond");
   unitToStringMap.put(AbsoluteTimeUnit.MINUTE, "absoluteMinute");
   unitToStringMap.put(AbsoluteTimeUnit.HOUR, "absoluteHour");
   unitToStringMap.put(AbsoluteTimeUnit.DAY, "absoluteDay");
   unitToStringMap.put(AbsoluteTimeUnit.WEEK, "absoluteWeek");
   unitToStringMap.put(AbsoluteTimeUnit.MONTH, "absoluteMonth");
   unitToStringMap.put(AbsoluteTimeUnit.YEAR, "absoluteYear");
   unitToStringMap.put(RelativeDayUnit.DAY, "relativeDay");
   unitToStringMap.put(RelativeHourUnit.HOUR, "relativeHour");
 }
Exemplo n.º 3
0
 /* (non-Javadoc)
  * @see com.thoughtworks.xstream.converters.SingleValueConverter#toString(java.lang.Object)
  */
 @Override
 public String toString(Object obj) {
   String unitString = unitToStringMap.get(obj);
   if (unitString == null) {
     String msg =
         "Unable to convert unexpected Unit object to an unit attribute value: " + obj.toString();
     throw new ConversionException(msg);
   }
   return unitString;
 }