Package org.getopt.luke.decoders

Examples of org.getopt.luke.decoders.Decoder


      bw.write("' flags='" + Util.fieldFlags((Field)fields[0], infos.fieldInfo(fields[0].name())) + "'>\n");
      for (IndexableField ixf : fields) {
        String val = null;
        Field f = (Field)ixf;
        if (decode) {
          Decoder d = decoders.get(f.name());
          if (d != null) {
            val = d.decodeStored(f.name(), f);
          }
        }
        if (!decode || val == null) {
          if (f.binaryValue() != null) {
            val = Util.bytesToHex(f.binaryValue(), false);
View Full Code Here


    if (topTerms != null) {
      bw.write(" <topTerms count='" + topTerms.length + "'>\n");
      for (TermStats ts : topTerms) {
        String val = null;
        if (decode) {
          Decoder d = decoders.get(ts.field);
          if (d != null) {
            val = d.decodeTerm(ts.field, ts.termtext);
          }
        }
        if (!decode || val == null) {
          val = ts.termtext.utf8ToString();
        }
View Full Code Here

        cell = create("cell");
        add(row, cell);
      }
      cell = create("cell");
      setChoice(cell, "alignment", "right");
      Decoder dec = decoders.get(s);
      if (dec == null) dec = defDecoder;
      setString(cell, "text", dec.toString());
      add(row, cell);
      // populate combos
      Object choice = create("choice");
      add(fCombo, choice);
      setString(choice, "text", s);
View Full Code Here

            add(row, cell);
            cell = create("cell");
            setString(cell, "text", topTerms[i].field);
            add(row, cell);
            cell = create("cell");
            Decoder dec = decoders.get(topTerms[i].field);
            if (dec == null) dec = defDecoder;
            String s;
            try {
              s = dec.decodeTerm(topTerms[i].field, topTerms[i].termtext.utf8ToString());
            } catch (Throwable e) {
              //e.printStackTrace();
              s = topTerms[i].termtext.utf8ToString();
              setColor(cell, "foreground", Color.RED);
            }
View Full Code Here

          text = Util.bytesToHex(f.binaryValue(), false);
        } else {
          text = "(null)";
        }
      }
      Decoder dec = decoders.get(f.name());
      if (dec == null) dec = defDecoder;
      try {
        if (f.fieldType().stored()/* && f.numericValue() == null && f.binaryValue() == null*/) {
          text = dec.decodeStored(f.name(), f);
        } else {
          text = dec.decodeTerm(f.name(), text);
        }
      } catch (Throwable e) {
        setColor(cell, "foreground", Color.RED);
      }
      setString(cell, "text", Util.escape(text));
View Full Code Here

            return;
          }
          Object dialog = addComponent(null, "/xml/vector.xml", null, null);
          setString(find(dialog, "fld"), "text", fName);
          Object vTable = find(dialog, "vTable");
          Decoder dec = decoders.get(fName);
          if (dec == null) dec = defDecoder;
          Collections.sort(tvs, new IntPair.PairComparator(false, true));
          for (int i = 0; i < tvs.size(); i++) {
            Object r = create("row");
            add(vTable, r);
            IntPair ip = tvs.get(i);
            putProperty(r, "tf", ip);
            Object cell = create("cell");
            String s;
            try {
              s = dec.decodeTerm(fName, ip.text);
            } catch (Throwable e) {
              s = ip.text;
              setColor(cell, "foreground", Color.RED);
            }
            setString(cell, "text", Util.escape(s));
View Full Code Here

      if (t.field().equals(getString(choices[i], "text"))) {
        setInteger(fCombo, "selected", i);
        break;
      }
    }
    Decoder dec = decoders.get(t.field());
    if (dec == null) dec = defDecoder;
    String s = null;
    boolean decodeErr = false;
    try {
      s = dec.decodeTerm(t.field(), t.text());
    } catch (Throwable e) {
      s = e.getMessage();
      decodeErr = true;
    }
    setString(fText, "text", t.text());
View Full Code Here

    Document doc = ir.document(docId);
    putProperty(row, "docid", new Integer(docId));
    StringBuffer vals = new StringBuffer();
    for (int j = 0; j < idxFields.length; j++) {
      cell = create("cell");
      Decoder dec = decoders.get(idxFields[j]);
      if (dec == null) dec = defDecoder;
      IndexableField[] values = doc.getFields(idxFields[j]);
      vals.setLength(0);
      boolean decodeErr = false;
      if (values != null) for (int k = 0; k < values.length; k++) {
        if (k > 0) vals.append(' ');
        String v;
        try {
          v = dec.decodeStored(idxFields[j], (Field)values[k]);
        } catch (Throwable e) {
          e.printStackTrace();
          v = values[k].stringValue();
          decodeErr = true;
        }
View Full Code Here

      return;
    }
    String fName = (String)getProperty(row, "fName");
    Object choice = getSelectedItem(combo);
    String decName = getString(choice, "name");
    Decoder dec = null;
    if (decName.equals("s")) {
      dec = new StringDecoder();
    } else if (decName.equals("b")) {
      dec = new BinaryDecoder();
    } else if (decName.equals("d")) {
      dec = new DateDecoder();
    } else if (decName.equals("nl")) {
      dec = new NumLongDecoder();
    } else if (decName.equals("ni")) {
      dec = new NumIntDecoder();
    } else if (decName.startsWith("solr.")) {
      try {
        dec = new SolrDecoder(decName);
      } catch (Exception e) {
        e.printStackTrace();
        errorMsg("Error setting decoder: " + e.toString());
      }
    } else {
      dec = defDecoder;
    }
    decoders.put(fName, dec);
    Object cell = getItem(row, 3);
    setString(cell, "text", dec.toString());
    repaint(fList);
    actionTopTerms(find("nTerms"));
  }
View Full Code Here

TOP

Related Classes of org.getopt.luke.decoders.Decoder

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.