コード例 #1
0
ファイル: DataImport.java プロジェクト: TuningGuide/efa
    public void endElement(String uri, String localName, String qname) {
      super.endElement(uri, localName, qname);

      if (record != null && localName.equals(DataRecord.ENCODING_RECORD)) {
        // end of record
        if (dataImport.importRecord(record, fieldsInImport)) {
          count++;
        }
        record = null;
        fieldsInImport = null;
      }
      String fieldValue = getFieldValue();
      if (record != null && fieldValue != null) {
        // end of field
        try {
          if (textImport) {
            if (!record.setFromText(fieldName, fieldValue.trim())) {
              dataImport.logImportWarning(
                  record,
                  "Value '"
                      + fieldValue
                      + "' for Field '"
                      + fieldName
                      + "' corrected to '"
                      + record.getAsText(fieldName)
                      + "'");
            }
          } else {
            record.set(fieldName, fieldValue.trim());
          }
          String[] equivFields = record.getEquivalentFields(fieldName);
          for (String f : equivFields) {
            fieldsInImport.add(f);
          }
        } catch (Exception esetvalue) {
          dataImport.logImportWarning(
              record,
              "Cannot set value '"
                  + fieldValue
                  + "' for Field '"
                  + fieldName
                  + "': "
                  + esetvalue.toString());
        }
      }
    }
コード例 #2
0
ファイル: DataImport.java プロジェクト: TuningGuide/efa
    public void startElement(String uri, String localName, String qname, Attributes atts) {
      super.startElement(uri, localName, qname, atts);

      if (localName.equals(DataExport.FIELD_EXPORT)) {
        String type = atts.getValue(DataExport.EXPORT_TYPE);
        textImport = (type != null && type.equals(DataExport.EXPORT_TYPE_TEXT));
      } else if (localName.equals(DataRecord.ENCODING_RECORD)) {
        // begin of record
        record = dataAccess.getPersistence().createNewRecord();
        fieldsInImport = new ArrayList<String>();
        return;
      } else {
        if (atts.getValue("key") != null && atts.getValue("key").equalsIgnoreCase("true")) {
          overrideKeyField = localName;
        }
      }
    }