コード例 #1
0
ファイル: TextResult.java プロジェクト: jerval/projects
 @JSON(serialize = false)
 public List getData() throws Exception {
   List list = new ArrayList();
   Obj o = new Obj();
   o.setName("我们");
   o.setPass("aaa");
   list.add(o);
   Obj o1 = new Obj();
   o1.setName("综");
   o1.setPass("df");
   list.add(o1);
   return list;
 }
コード例 #2
0
ファイル: Builders.java プロジェクト: adityavs/infer
 public Obj buildThenMutateBad(Obj input) {
   Obj.Builder builder = new Obj.Builder();
   Obj output = builder.setFromObj(input).build();
   input.g = "";
   return output;
 }
コード例 #3
0
ファイル: Builders.java プロジェクト: adityavs/infer
 public Obj mutateBad(Obj o) {
   o.g = "";
   return o;
 }
コード例 #4
0
  public Obj loadObj(Context context, String name) throws IOException {
    BufferedReader reader =
        new BufferedReader(new InputStreamReader(context.getAssets().open(name)));
    String line = reader.readLine();
    ArrayList<Float> normalList = new ArrayList<>();
    ArrayList<Float> vertexList = new ArrayList<>();
    ArrayList<Float> uvList = new ArrayList<>();

    float xScale = 0;
    float yScale = 0;
    float zScale = 0;

    Obj obj = new Obj();

    while (line != null) {
      Utils.print("Processing line: " + line);
      String[] lineSplit = line.split("\\s+");

      if (lineSplit.length > 0) {
        if (lineSplit[0].compareTo(COMMENT) == 0) {
          Utils.print("Comment, IGNORING LINE ");
        } else if (lineSplit[0].compareTo(MAT_REF) == 0) {
          Utils.print("Material Reference: " + lineSplit[1]);
          if (obj.getCurrGroup() == null) {
            Utils.print("Malformed file, no object declared");
            return null;
          }
          if (obj.getMatLib() == null) {
            Utils.print("Malformed file, no materialLib declared");
            return null;
          }
          obj.setGroupMat(lineSplit[1]);
        } else if (lineSplit[0].compareTo(SMOOTHING) == 0) {
          Utils.print("Smoothing");
        } else if (lineSplit[0].compareTo(MAT_LIB) == 0) {
          Utils.print("Material Library: " + lineSplit[1]);
          obj.setMatLib(new MaterialLib(context, lineSplit[1]));
        } else if (lineSplit[0].compareTo(OBJECT) == 0) {
          Utils.print("Object name: " + lineSplit[1]);
          obj.name = lineSplit[1];
        } else if (lineSplit[0].compareTo(FACE) == 0) {
          float[] faceTris = parseFace(lineSplit, vertexList, normalList, uvList);
          for (int i = 0; i < faceTris.length; i++) {
            obj.getCurrGroup().floatBuffer.add(faceTris[i]);
          }
        } else if (lineSplit[0].compareTo(GROUP) == 0) {
          Utils.print("Group: " + lineSplit[1]);
          obj.createGroup(lineSplit[1]);
        } else {
          float x = Float.parseFloat(lineSplit[1]);
          float y = Float.parseFloat(lineSplit[2]);
          if (lineSplit[0].compareTo(VERTEX) == 0) {
            float z = Float.parseFloat(lineSplit[3]);
            vertexList.add(x);
            vertexList.add(y);
            vertexList.add(z);
            if (Math.abs(x) > xScale) {
              xScale = Math.abs(x);
            }
            if (Math.abs(y) > yScale) {
              yScale = Math.abs(y);
            }
            if (Math.abs(z) > zScale) {
              zScale = Math.abs(z);
            }
          } else if (lineSplit[0].compareTo(NORMAL) == 0) {
            float z = Float.parseFloat(lineSplit[3]);
            normalList.add(x);
            normalList.add(y);
            normalList.add(z);
          } else if (lineSplit[0].compareTo(UV) == 0) {
            uvList.add(x);
            uvList.add(y);
          }
        }
        line = reader.readLine();
      }
    }
    ;
    // gUtils.print("Created Object: " + obj.toString());
    return obj;
  }
コード例 #5
0
  protected NameClassPair createItem(String dn, Attributes attrs, Vector respCtls)
      throws NamingException {

    Object obj = null;

    String relStart; // name relative to starting search context
    String relHome; // name relative to homeCtx.currentDN
    boolean relative = true; // whether relative to currentDN

    // need to strip off all but lowest component of dn
    // so that is relative to current context (currentDN)

    try {
      Name parsed = new LdapName(dn);
      // System.err.println("dn string: " + dn);
      // System.err.println("dn name: " + parsed);

      if (startName != null && parsed.startsWith(startName)) {
        relStart = parsed.getSuffix(startName.size()).toString();
        relHome = parsed.getSuffix(homeCtx.currentParsedDN.size()).toString();
      } else {
        relative = false;
        relHome =
            relStart =
                LdapURL.toUrlString(
                    homeCtx.hostname, homeCtx.port_number, dn, homeCtx.hasLdapsScheme);
      }
    } catch (NamingException e) {
      // could not parse name
      relative = false;
      relHome =
          relStart =
              LdapURL.toUrlString(
                  homeCtx.hostname, homeCtx.port_number, dn, homeCtx.hasLdapsScheme);
    }

    // Name relative to search context
    CompositeName cn = new CompositeName();
    if (!relStart.equals("")) {
      cn.add(relStart);
    }

    // Name relative to homeCtx
    CompositeName rcn = new CompositeName();
    if (!relHome.equals("")) {
      rcn.add(relHome);
    }
    // System.err.println("relStart: " + cn);
    // System.err.println("relHome: " + rcn);

    // Fix attributes to be able to get schema
    homeCtx.setParents(attrs, rcn);

    // only generate object when requested
    if (searchArgs.cons.getReturningObjFlag()) {

      if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
        // Entry contains Java-object attributes (ser/ref object)
        // serialized object or object reference
        obj = Obj.decodeObject(attrs);
      }
      if (obj == null) {
        obj = new LdapCtx(homeCtx, dn);
      }

      // Call getObjectInstance before removing unrequested attributes
      try {
        // rcn is either relative to homeCtx or a fully qualified DN
        obj =
            DirectoryManager.getObjectInstance(
                obj, rcn, (relative ? homeCtx : null), homeCtx.envprops, attrs);
      } catch (NamingException e) {
        throw e;
      } catch (Exception e) {
        NamingException ne = new NamingException("problem generating object using object factory");
        ne.setRootCause(e);
        throw ne;
      }

      // remove Java attributes from result, if necessary
      // Even if CLASSNAME attr not there, there might be some
      // residual attributes

      String[] reqAttrs;
      if ((reqAttrs = searchArgs.reqAttrs) != null) {
        // create an attribute set for those requested
        Attributes rattrs = new BasicAttributes(true); // caseignore
        for (int i = 0; i < reqAttrs.length; i++) {
          rattrs.put(reqAttrs[i], null);
        }
        for (int i = 0; i < Obj.JAVA_ATTRIBUTES.length; i++) {
          // Remove Java-object attributes if not requested
          if (rattrs.get(Obj.JAVA_ATTRIBUTES[i]) == null) {
            attrs.remove(Obj.JAVA_ATTRIBUTES[i]);
          }
        }
      }
    }

    /*
     * name in search result is either the stringified composite name
     * relative to the search context that can be passed directly to
     * methods of the search context, or the fully qualified DN
     * which can be used with the initial context.
     */
    SearchResult sr;
    if (respCtls != null) {
      sr =
          new SearchResultWithControls(
              (relative ? cn.toString() : relStart),
              obj,
              attrs,
              relative,
              homeCtx.convertControls(respCtls));
    } else {
      sr = new SearchResult((relative ? cn.toString() : relStart), obj, attrs, relative);
    }
    sr.setNameInNamespace(dn);
    return sr;
  }