コード例 #1
0
  public PacketExtension parseExtension(XmlPullParser parser)
      throws XmlPullParserException, IOException, XMPPException {
    String hash = null;
    String version = null;
    String node = null;
    if (parser.getEventType() == XmlPullParser.START_TAG
        && parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT)) {
      hash = parser.getAttributeValue(null, "hash");
      version = parser.getAttributeValue(null, "ver");
      node = parser.getAttributeValue(null, "node");
    } else {
      throw new XMPPException("Malformed Caps element");
    }

    parser.next();

    if (!(parser.getEventType() == XmlPullParser.END_TAG
        && parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT))) {
      throw new XMPPException("Malformed nested Caps element");
    }

    if (version != null && node != null) {
      return new CapsExtension(node, version, Strings.getNotEmpty(hash, ""));
    } else {
      throw new XMPPException("Caps element with missing attributes");
    }
  }
コード例 #2
0
 private static void copy(@Nonnull AFunction target, @Nonnull IFunction source) {
   target.name = source.getName();
   target.content = source.getContent();
   target.description = Strings.getNotEmpty(source.getDescription(), "");
   target.system = source.isSystem();
   if (source.isIdDefined()) {
     target.id = source.getId();
   }
   target.parameterNames = new ArrayList<String>(source.getParameterNames());
 }
コード例 #3
0
    @Nonnull
    public AFunction create() throws AFunction.Builder.CreationException {
      final AFunction result;
      if (id != null) {
        result = new AFunction(id);
      } else {
        result = new AFunction();
      }

      result.name = name;
      try {
        result.content = Locator.getInstance().getCalculator().prepareExpression(value).toString();
      } catch (CalculatorParseException e) {
        throw new CreationException(e);
      }
      result.system = system;
      result.description = Strings.getNotEmpty(description, "");
      result.parameterNames = new ArrayList<String>(parameterNames);

      return result;
    }