コード例 #1
0
  /**
   * _more_
   *
   * @param entry _more_
   * @param className _more_
   * @param properties _more_
   * @return _more_
   * @throws Exception _more_
   */
  private RecordFile doMakeRecordFile(Entry entry, String className, Hashtable properties)
      throws Exception {
    Class c = Misc.findClass(className);
    Constructor ctor = Misc.findConstructor(c, new Class[] {String.class, Hashtable.class});
    if (ctor != null) {
      return (RecordFile) ctor.newInstance(new Object[] {entry.getFile().toString(), properties});
    }
    ctor = Misc.findConstructor(c, new Class[] {String.class});

    if (ctor != null) {
      return (RecordFile) ctor.newInstance(new Object[] {entry.getResource().getPath()});
    }

    throw new IllegalArgumentException("Could not find constructor for " + className);
  }
コード例 #2
0
  /**
   * _more_
   *
   * @param entry _more_
   * @return _more_
   * @throws Exception On badness
   */
  public Hashtable getRecordProperties(Entry entry) throws Exception {
    Object[] values = entry.getTypeHandler().getEntryValues(entry);
    String propertiesString =
        (values[IDX_PROPERTIES] != null) ? values[IDX_PROPERTIES].toString() : "";

    String typeProperties = getProperty("record.properties", (String) null);

    Hashtable p = null;

    if (typeProperties != null) {
      if (p == null) {
        p = new Hashtable();
      }
      p.putAll(RecordFile.getProperties(typeProperties));
    }

    if (propertiesString != null) {
      if (p == null) {
        p = new Hashtable();
      }
      p.putAll(RecordFile.getProperties(propertiesString));
    }

    return p;
  }
コード例 #3
0
  /**
   * _more_
   *
   * @param entry _more_
   * @param originalFile _more_
   * @throws Exception _more_
   */
  public void initializeEntry(Entry entry, File originalFile) throws Exception {

    if (anySuperTypesOfThisType()) {
      return;
    }
    Hashtable existingProperties = getRecordProperties(entry);
    if ((existingProperties != null) && (existingProperties.size() > 0)) {
      return;
    }

    // Look around for properties files that define
    // the crs, fields for text formats, etc.
    Hashtable properties =
        RecordFile.getPropertiesForFile(originalFile.toString(), PointFile.DFLT_PROPERTIES_FILE);

    // Make the properties string
    String contents = makePropertiesString(properties);
    Object[] values = entry.getTypeHandler().getEntryValues(entry);
    // Append the properties file contents
    if (values[IDX_PROPERTIES] != null) {
      values[IDX_PROPERTIES] = "\n" + contents;
    } else {
      values[IDX_PROPERTIES] = contents;
    }
  }
コード例 #4
0
  /**
   * _more_
   *
   * @param entry _more_
   * @param properties _more_
   * @return _more_
   * @throws Exception _more_
   */
  private RecordFile doMakeRecordFile(Entry entry, Hashtable properties) throws Exception {
    String recordFileClass = getProperty("record.file.class", (String) null);
    if (recordFileClass != null) {
      return doMakeRecordFile(entry, recordFileClass, properties);
    }
    String path = entry.getFile().toString();

    return (RecordFile) getRecordFileFactory().doMakeRecordFile(path, properties);
  }