Package aQute

Examples of aQute.struct


    void resolve(Object rover) throws Exception {
      if (rover == null)
        return;

      if (rover instanceof struct) {
        struct struct = (struct) rover;

        for (Field f : struct.fields()) {
          Object o = f.get(struct);

          if (o == null)
            continue;
View Full Code Here


    }
    return null;
  }

  private struct parseStruct(Class< ? extends struct> type, XMLStreamReader rd) throws Exception {
    struct object = type.newInstance();

    while (rd.hasNext()) {
      int nextTag = rd.next();
      outer: switch (nextTag) {
        case XMLStreamConstants.CHARACTERS :
          if (!rd.getText().trim().isEmpty()) {
            for (Field f : object.fields()) {
              if (f.getType() == String.class) {
                f.set(object, rd.getText());
                break outer;
              }
            }
            // Hmm, no string field
            if (object.__extra == null) {
              object.__extra = new HashMap<String,Object>();
            }
            String s = (String) object.__extra.get(".");
            if (s == null) {
              s = rd.getText();
            } else
              s += rd.getText();
            object.__extra.put(".", s);
          }
          break;

        case XMLStreamConstants.START_ELEMENT :
          String name = rd.getLocalName();
          Field field = object.getField(name);
          Object value;
          if (field == null) {
            Map<String,Object> map = object.__extra;
            if (map == null) {
              map = new HashMap<String,Object>();
View Full Code Here

    void resolve(Object rover) throws Exception {
      if (rover == null)
        return;

      if (rover instanceof struct) {
        struct struct = (struct) rover;

        for (Field f : struct.fields()) {
          Object o = f.get(struct);

          if (o == null)
            continue;
View Full Code Here

    }
    return null;
  }

  private struct parseStruct(Class< ? extends struct> type, XMLStreamReader rd) throws Exception {
    struct object = type.newInstance();

    while (rd.hasNext()) {
      int nextTag = rd.next();
      outer: switch (nextTag) {
        case XMLStreamConstants.CHARACTERS :
          if (!rd.getText().trim().isEmpty()) {
            for (Field f : object.fields()) {
              if (f.getType() == String.class) {
                f.set(object, rd.getText());
                break outer;
              }
            }
            // Hmm, no string field
            if (object.__extra == null) {
              object.__extra = new HashMap<String,Object>();
            }
            String s = (String) object.__extra.get(".");
            if (s == null) {
              s = rd.getText();
            } else
              s += rd.getText();
            object.__extra.put(".", s);
          }
          break;

        case XMLStreamConstants.START_ELEMENT :
          String name = rd.getLocalName();
          Field field = object.getField(name);
          Object value;
          if (field == null) {
            Map<String,Object> map = object.__extra;
            if (map == null) {
              map = new HashMap<String,Object>();
View Full Code Here

    void resolve(Object rover) throws Exception {
      if (rover == null)
        return;

      if (rover instanceof struct) {
        struct struct = (struct) rover;

        for (Field f : struct.fields()) {
          Object o = f.get(struct);

          if (o == null)
            continue;
View Full Code Here

TOP

Related Classes of aQute.struct

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.