Package freenet.node

Examples of freenet.node.FSParseException


     * @throws FSParseException If the key=value pair does not exist or if the value cannot be
     * parsed as a short.
     */
  public short getShort(String key) throws FSParseException {
    String s = get(key);
    if(s == null) throw new FSParseException("No key "+key);
    try {
      return Short.parseShort(s);
    } catch (NumberFormatException e) {
      throw new FSParseException("Cannot parse "+s+" for short "+key);
    }
  }
View Full Code Here


     * @throws FSParseException If the key=value pair does not exist or if the value cannot be
     * parsed as a byte.
     */
  public byte getByte(String key) throws FSParseException {
    String s = get(key);
    if(s == null) throw new FSParseException("No key " + key);
    try {
      return Byte.parseByte(s);
    } catch (NumberFormatException e) {
      throw new FSParseException("Cannot parse \"" + s + "\" as a byte.");
    }
  }
View Full Code Here

   * @return The byte array to fetch.
   * @throws FSParseException If the key does not exist or cannot be parsed as a byte array.
   */
  public byte[] getByteArray(String key) throws FSParseException {
        String s = get(key);
        if(s == null) throw new FSParseException("No key " + key);
        try {
            return Base64.decode(s);
        } catch (IllegalBase64Exception e) {
            throw new FSParseException("Cannot parse value \""+s+"\" as a byte[]");
        }
  }
View Full Code Here

   * @return The character to fetch.
   * @throws FSParseException If the key does not exist or there is more than one character.
   */
  public char getChar(String key) throws FSParseException {
    String s = get(key);
    if(s == null) throw new FSParseException("No key "+key);
      if (s.length() == 1)
        return s.charAt(0);
      else
        throw new FSParseException("Cannot parse "+s+" for char "+key);
  }
View Full Code Here

  public boolean getBoolean(String key) throws FSParseException {
    try {
        return Fields.stringToBool(get(key));
    } catch(NumberFormatException e) {
        throw new FSParseException(e);
    }
  }
View Full Code Here

        putSingle(key, unsplit(copy));
    }

  public String getString(String key) throws FSParseException {
    String s = get(key);
    if(s == null) throw new FSParseException("No such element "+key);
    return s;
  }
View Full Code Here

  public static DSAGroup create(SimpleFieldSet fs) throws IllegalBase64Exception, FSParseException {
    String myP = fs.get("p");
    String myQ = fs.get("q");
    String myG = fs.get("g");
    if(myP == null || myQ == null || myG == null) throw new FSParseException("The given SFS doesn't contain required fields!");
    BigInteger p = new NativeBigInteger(1, Base64.decode(myP));
    BigInteger q = new NativeBigInteger(1, Base64.decode(myQ));
    BigInteger g = new NativeBigInteger(1, Base64.decode(myG));
    DSAGroup dg = new DSAGroup(p, q, g);
    if(dg.equals(Global.DSAgroupBigA)) return Global.DSAgroupBigA;
View Full Code Here

  public static DSAPublicKey create(SimpleFieldSet set, DSAGroup group) throws FSParseException {
    NativeBigInteger x;
    try {
      x = new NativeBigInteger(1, Base64.decode(set.get("y")));
    } catch (IllegalBase64Exception e) {
      throw new FSParseException(e);
    }
    try {
      return new DSAPublicKey(group, x);
    } catch (IllegalArgumentException e) {
      throw new FSParseException(e);
    }
  }
View Full Code Here

TOP

Related Classes of freenet.node.FSParseException

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.