Examples of NumericField


Examples of jp.go.aist.sot.client.gui.NumericField

        setBorder(border);

        termTitle = new JLabel(mh.getMessage("term_title"));
        termTitle.setForeground(GUIConstants.TITLE_FOREGROUND_COLOR);

        daysField = new NumericField(new LimitedDocument(3), null, 3);
        daysField.setHorizontalAlignment(SwingConstants.RIGHT);
        model = daysField.getDocument();
        model.addDocumentListener(new DocumentAdapter(daysField, controller));
        daysUnitTitle = new JLabel(mh.getMessage("days_unit_title"));
        daysUnitTitle.setForeground(GUIConstants.TITLE_FOREGROUND_COLOR);

        hoursField = new NumericField(new LimitedDocument(3), null, 3);
        hoursField.setHorizontalAlignment(SwingConstants.RIGHT);
        model = hoursField.getDocument();
        model.addDocumentListener(new DocumentAdapter(hoursField, controller));
        hoursUnitTitle = new JLabel(mh.getMessage("hours_unit_title"));
        hoursUnitTitle.setForeground(GUIConstants.TITLE_FOREGROUND_COLOR);
View Full Code Here

Examples of org.apache.lucene.document.NumericField

      String color = "red";
      String ID = Integer.toString(10);
      Document d=new Document();
      d.add(new Field("id",ID,Field.Store.YES,Index.NOT_ANALYZED_NO_NORMS));
      d.add(new Field("color",color,Field.Store.YES,Index.NOT_ANALYZED_NO_NORMS));
      d.add(new NumericField("NUM").setIntValue(10));
      dataList.add(d);
     
       color = "green";
       ID = Integer.toString(11);
       d=new Document();
      d.add(new Field("id",ID,Field.Store.YES,Index.NOT_ANALYZED_NO_NORMS));
      d.add(new Field("color",color,Field.Store.YES,Index.NOT_ANALYZED_NO_NORMS));
      d.add(new NumericField("NUM").setIntValue(11));
      dataList.add(d);
     
   
    return dataList.toArray(new Document[dataList.size()]);
}
View Full Code Here

Examples of org.apache.lucene.document.NumericField

        TEST_VERSION_CURRENT, new StandardAnalyzer(TEST_VERSION_CURRENT)));
    for (int i = 0; i < texts.length; i++) {
      addDoc(writer, texts[i]);
    }
    Document doc = new Document();
    NumericField nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(1);
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(3);
    doc = new Document();
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(5);
    doc = new Document();
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(7);
    doc = new Document();
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    writer.optimize();
    writer.close();
View Full Code Here

Examples of org.apache.lucene.document.NumericField

    IndexWriter writer = new IndexWriter(ramDir, new StandardAnalyzer(TEST_VERSION), true, IndexWriter.MaxFieldLength.UNLIMITED);
    for (int i = 0; i < texts.length; i++) {
      addDoc(writer, texts[i]);
    }
    Document doc = new Document();
    NumericField nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(1);
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(3);
    doc = new Document();
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(5);
    doc = new Document();
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    nfield = new NumericField(NUMERIC_FIELD_NAME, Store.YES, true);
    nfield.setIntValue(7);
    doc = new Document();
    doc.add(nfield);
    writer.addDocument(doc, analyzer);
    writer.optimize();
    writer.close();
View Full Code Here

Examples of org.apache.lucene.document.NumericField

      doc.add(new Field("compressed", BINARY_TO_COMPRESS, Field.Store.COMPRESS));   
      doc.add(new Field("compressedSize", Integer.toString(BINARY_COMPRESSED_LENGTH), Field.Store.YES, Field.Index.NOT_ANALYZED));
    }
    */
    // add numeric fields, to test if flex preserves encoding
    doc.add(new NumericField("trieInt", 4).setIntValue(id));
    doc.add(new NumericField("trieLong", 4).setLongValue(id));
    writer.addDocument(doc);
  }
View Full Code Here

Examples of org.apache.lucene.document.NumericField

  private void buildDocument(Document document, Serializer serializer) {
    List<Fieldable> docFields = document.getFields();
    serializer.fields( docFields );
    for(Fieldable fieldable : docFields) {
      if (fieldable instanceof NumericField) {
        NumericField safeField = (NumericField) fieldable;
        LuceneNumericFieldContext context = new LuceneNumericFieldContext( (NumericField) fieldable );
        switch ( safeField.getDataType() ) {
          case INT:
            serializer.addIntNumericField(
                safeField.getNumericValue().intValue(),
                context
            );
            break;
          case LONG:
            serializer.addLongNumericField(
                safeField.getNumericValue().longValue(),
                context
            );
            break;
          case FLOAT:
            serializer.addFloatNumericField(
                safeField.getNumericValue().floatValue(),
                context
            );
            break;
          case DOUBLE:
            serializer.addDoubleNumericField(
                safeField.getNumericValue().doubleValue(),
                context
            );
            break;
          default:
            String dataType = safeField.getDataType() == null ? "null" : safeField.getDataType().toString();
            throw log.unknownNumericFieldType( dataType );
        }
      }
      else if (fieldable instanceof Field) {
        Field safeField = (Field) fieldable;
        if ( safeField.isBinary() ) {
          serializer.addFieldWithBinaryData( new LuceneFieldContext( safeField ) );
        }
        else if ( safeField.stringValue() != null )  {
          serializer.addFieldWithStringData( new LuceneFieldContext( safeField ) );
        }
        else if ( safeField.readerValue() != null && safeField.readerValue() instanceof Serializable )  {
          serializer.addFieldWithSerializableReaderData( new LuceneFieldContext( safeField ) );
        }
        else if ( safeField.readerValue() != null )  {
          throw log.conversionFromReaderToStringNotYetImplemented();
        }
        else if ( safeField.tokenStreamValue() != null )  {
          serializer.addFieldWithTokenStreamData( new LuceneFieldContext( safeField ) );
        }
        else {
          throw log.unknownFieldType( safeField.getClass() );
        }
      }
      else if (fieldable instanceof Serializable) { //Today Fieldable is Serializable but for how long?
        serializer.addFieldWithSerializableFieldable( toByteArray( fieldable ) );
      }
View Full Code Here

Examples of org.apache.lucene.document.NumericField

      if (log.isTraceEnabled())
        log.trace("Ignoring unindexed/unstored field: " + field);
      return null;
    }

    final NumericField f = new NumericField(field.getName(), precisionStep, stored ? Field.Store.YES : Field.Store.NO, indexed);
    switch (type) {
      case INTEGER:
        f.setIntValue(Integer.parseInt(externalVal));
        break;
      case FLOAT:
        f.setFloatValue(Float.parseFloat(externalVal));
        break;
      case LONG:
        f.setLongValue(Long.parseLong(externalVal));
        break;
      case DOUBLE:
        f.setDoubleValue(Double.parseDouble(externalVal));
        break;
      case DATE:
        f.setLongValue(dateField.parseMath(null, externalVal).getTime());
        break;
      default:
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type);
    }

    f.setOmitNorms(field.omitNorms());
    f.setIndexOptions(getIndexOptions(field, externalVal));
    f.setBoost(boost);
    return f;
  }
View Full Code Here

Examples of org.apache.lucene.document.NumericField

    iw.close();
  }

  private void addMetadata(Document doc, int lines, int paragraphs, int paragraphLines) {
    doc.add(new Field("id", "frank_" + paragraphs, Field.Store.YES, Field.Index.NOT_ANALYZED));
    NumericField startLine = new NumericField("startLine", Field.Store.YES, true);
    startLine.setIntValue(lines - paragraphLines);
    doc.add(startLine);
    NumericField finishLine = new NumericField("finishLine", Field.Store.YES, true);
    finishLine.setIntValue(lines);
    doc.add(finishLine);
    NumericField paragraphNumber = new NumericField("paragraphNumber", Field.Store.YES, true);
    paragraphNumber.setIntValue(paragraphs);
    doc.add(paragraphNumber);
  }
View Full Code Here

Examples of org.apache.lucene.document.NumericField

      offset =  field.getBinaryOffset();

      fieldsStream.writeVInt(len);
      fieldsStream.writeBytes(data, offset, len);
    } else if (field instanceof NumericField) {
      final NumericField nf = (NumericField) field;
      final Number n = nf.getNumericValue();
      switch (nf.getDataType()) {
        case INT:
            fieldsStream.writeVVInt(n.intValue()); break;
        case LONG:
            fieldsStream.writeVVLong(n.longValue()); break;
        case FLOAT:
View Full Code Here

Examples of org.apache.lucene.document.NumericField

  private NumericField loadNumericField(FieldInfo fi, int numeric) throws IOException {
    assert numeric != 0;
    switch(numeric) {
      case FieldsWriter.FIELD_IS_NUMERIC_INT:
        return new NumericField(fi.name, Field.Store.YES, fi.isIndexed).setIntValue(fieldsStream.readVVInt());
      case FieldsWriter.FIELD_IS_NUMERIC_LONG:
        return new NumericField(fi.name, Field.Store.YES, fi.isIndexed).setLongValue(fieldsStream.readVVLong());
      case FieldsWriter.FIELD_IS_NUMERIC_FLOAT:
        return new NumericField(fi.name, Field.Store.YES, fi.isIndexed).setFloatValue(Float.intBitsToFloat(fieldsStream.readVVVInt()));
      case FieldsWriter.FIELD_IS_NUMERIC_DOUBLE:
        return new NumericField(fi.name, Field.Store.YES, fi.isIndexed).setDoubleValue(Double.longBitsToDouble(fieldsStream.readVVVLong()));
      default:
        throw new FieldReaderException("Invalid numeric type: " + Integer.toHexString(numeric));
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.