Package ru.vassaev.core.exception

Examples of ru.vassaev.core.exception.SysException


   * @throws SysException
   */
  public void setValue(String value) throws SysException {
    int l = value.length();
    if (l / (bytes ? 2 : 1) > maxl)
      throw new SysException("Inequality data and format for field \""
          + name + "\"");
    if ((vl == 0 && l / (bytes ? 2 : 1) < maxl) || (vl > 0 & l / (bytes ? 2 : 1) >= Math.pow(10, vl)))
      throw new SysException("Inequality data and format for field \""
          + name + "\"");
    // Записать тело
    if (isHexB) { // TODO
      int i = isHexH ? vl / 2 + vl % 2 : vl;
      int j = 0;
      int k = 0;
      if (l % 2 != 0 && !left) {
        dta[i] = (byte) (Byte.parseByte(value.substring(j, j + 1), 16) & 0xff);
        k = 1;
      }
      for (; j + k < l; j++) {
        int b = Byte.parseByte(value.substring(j + k, j + k + 1), 16) << 4;
        j++;
        if (j + k < l)
          b = b
              | Byte.parseByte(value.substring(j + k, j + k + 1),
                  16);
        dta[i + k + (j >> 1)] = (byte) (0xff & b);
      }
    } else {
      int i = isHexH ? vl / 2 + vl % 2 : vl;
      byte[] buf;
      try {
        buf = value.getBytes(charset);
      } catch (UnsupportedEncodingException e) {
        throw new SysException(e);
      }
      System.arraycopy(buf, 0, dta, i, buf.length);
    }
    // Установка длины
    if (vl > 0) {
View Full Code Here


      if (k < len)
        res.append(fld.substring(k));
      return res.toString();
    } catch (NumberFormatException ex) {
      throw new SysException("This field is not tag field");
    } catch (ArrayIndexOutOfBoundsException ex) {
      throw new SysException("This field is not tag field");
    }
  }
View Full Code Here

        v = fld.substring(i, k);// значение тега
        res.put(t, v);
      } while (k < len);
      return res;
    } catch (NumberFormatException ex) {
      throw new SysException("This field is not tag field");
    } catch (ArrayIndexOutOfBoundsException ex) {
      throw new SysException("This field is not tag field");
    }
  }
View Full Code Here

    byte[] v = null;
    if (val != null) {
      try {
        v = val.getBytes(charset);
      } catch (UnsupportedEncodingException e) {
        throw new SysException(e);
      }
    }
    byte[] dta = data.remove(key);
    if (dta != null)
      len = len - dta.length;
View Full Code Here

    byte[] v = null;
    if (val != null) {
      try {
        v = val.getBytes(charset);
      } catch (UnsupportedEncodingException e) {
        throw new SysException(e);
      }
    }
    byte[] dta = header.remove(key);
    if (dta != null)
      lenh = lenh - dta.length;
View Full Code Here

    if (val instanceof OutputByteBuffer)
      return (OutputByteBuffer) val;
    try {
      return OutputByteBuffer.getOutputByteBuffer(val, charset);
    } catch (IOException e) {
      throw new SysException(e);
    }
  }
View Full Code Here

        byte type = (byte) (0xff & Strings.parseIntegerNvl(val, STX));
        if (type == STX || type == SOH ||
            type == EOT || type == ACK || type == CR || type == NAK || type == ENQ)
          SAMsg.this.type = type;
        else
          throw new SysException("The type of message is incorrect");
      } else if (key.substring(0, 1).equals("h"))
          setFieldH0(Integer.parseInt(key.substring(1)), val);
      else
        setField0(Integer.parseInt(key), val);
    }
View Full Code Here

    try {
      return getPrm("prm", fullname, 0);
    } catch (SysException e) {
      throw e;
    } catch (Throwable e) {
      throw new SysException(e);
    }
  }
View Full Code Here

      if (dta == null)
        return null;
      try {
        return new String(dta, charset);
      } catch (UnsupportedEncodingException e) {
        throw new SysException(e);
      }
    }
View Full Code Here

        if ("type".equals(key)) {
          return String.valueOf(type).getBytes(charset);
        } else if (key.substring(0, 1).equals("h"))
          return header.get(Integer.valueOf(key.substring(1)));
      } catch (UnsupportedEncodingException e) {
        throw new SysException(e);
      }
      return data.get(key);
    }
View Full Code Here

TOP

Related Classes of ru.vassaev.core.exception.SysException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.