Пример #1
0
  @Override
  public void characters(char ch[], int start, int length) throws SAXException {
    if (_isCost) {
      // TODO: set cost once attribute is in IntervalReading obj
      _isCost = false;
    } else if (_isDuration) {
      // in seconds
      _intervalReading.setDuration(Integer.parseInt(new String(ch, start, length)));
      // System.out.println("Duration: " + new String(ch, start, length));
      _isDuration = false;
    } else if (_isStart) {
      // unix time stamp - must multiply by 1000L because Date obj
      // ctor expects ms not s.
      long timeStamp = 1000L * Long.parseLong(new String(ch, start, length));
      Date d = new Date(timeStamp);
      _intervalReading.setStartTime(d);

      // System.out.println("Start Time: " + new String(ch, start, length));
      _isStart = false;
    } else if (_isValue) {
      _intervalReading.setValue(Integer.parseInt(new String(ch, start, length)));
      // System.out.println("Value: " + new String(ch, start, length));
      _isValue = false;
    }
  }
Пример #2
0
 public long getLongContent(long defaultValue) {
   String c = node.getTextContent();
   if (c != null) {
     try {
       return Long.parseLong(c);
     } catch (NumberFormatException nfe) {
     }
   }
   return defaultValue;
 }
Пример #3
0
  public long getUnicodeAsLong() {
    long retval = -1;

    String s = getUnicodeAsString();
    if (s.equals("")) {
      return retval;
    } // if

    try {
      retval = Long.parseLong(s, 16);
    } catch (NumberFormatException e) {
      retval = -1;
    } // try-catch

    return retval;
  }
Пример #4
0
 /**
  * Returns the value of an attribute.
  *
  * @param name the non-null full name of the attribute.
  * @param defaultValue the default value of the attribute.
  * @return the value, or defaultValue if the attribute does not exist.
  */
 public long getLong(String name, long defaultValue) {
   String value = getString(name);
   return (value == null) ? defaultValue : Long.parseLong(value);
 }