Java 类weka.core.xml.XMLDocument 实例源码

项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * builds the ColorUIResource from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readColorUIResource(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  String name;
  Color color;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  color = null;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_COLOR)) {
      color = (Color) invokeReadFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new ColorUIResource(color);

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the Dimension from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readDimension(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  double      width;
  double      height;
  String      name;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  width    = 0;
  height   = 0;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_WIDTH))
      width = readDoubleFromXML(child);
    else if (name.equals(VAL_HEIGHT))
      height = readDoubleFromXML(child);
    else
      System.out.println("WARNING: '" + name
          + "' is not a recognized name for " + node.getAttribute(ATT_NAME) + "!");
  }

  result = new Dimension();
  ((Dimension) result).setSize(width, height);

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the Point from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readPoint(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  double      x;
  double      y;
  String      name;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  x        = 0;
  y        = 0;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_X))
      x = readDoubleFromXML(child);
    else if (name.equals(VAL_Y))
      y = readDoubleFromXML(child);
    else
      System.out.println("WARNING: '" + name
          + "' is not a recognized name for " + node.getAttribute(ATT_NAME) + "!");
  }

  result = new Point();
  ((Point) result).setLocation(x, y);

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the ColorUIResource from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readColorUIResource(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  String      name;
  Color       color;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  color    = null;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_COLOR))
      color = (Color) invokeReadFromXML(child);
    else
      System.out.println("WARNING: '" + name
          + "' is not a recognized name for " + node.getAttribute(ATT_NAME) + "!");
  }

  result = new ColorUIResource(color);

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the FontUIResource from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readFontUIResource(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  String      name;
  Font        font;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  font     = null;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FONT))
      font = (Font) invokeReadFromXML(child);
    else
      System.out.println("WARNING: '" + name
          + "' is not a recognized name for " + node.getAttribute(ATT_NAME) + "!");
  }

  result = new FontUIResource(font);

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the ColorUIResource from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readColorUIResource(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  String name;
  Color color;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  color = null;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_COLOR)) {
      color = (Color) invokeReadFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new ColorUIResource(color);

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the FontUIResource from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readFontUIResource(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  String name;
  Font font;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  font = null;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FONT)) {
      font = (Font) invokeReadFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new FontUIResource(font);

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the Dimension from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readDimension(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  double      width;
  double      height;
  String      name;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  width    = 0;
  height   = 0;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_WIDTH))
      width = readDoubleFromXML(child);
    else if (name.equals(VAL_HEIGHT))
      height = readDoubleFromXML(child);
    else
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_ReadDimension_Text_First") + name
          + Messages.getInstance().getString("XMLBeans_ReadDimension_Text_Second") + node.getAttribute(ATT_NAME) + Messages.getInstance().getString("XMLBeans_ReadDimension_Text_Third"));
  }

  result = new Dimension();
  ((Dimension) result).setSize(width, height);

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the Point from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readPoint(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  double      x;
  double      y;
  String      name;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  x        = 0;
  y        = 0;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_X))
      x = readDoubleFromXML(child);
    else if (name.equals(VAL_Y))
      y = readDoubleFromXML(child);
    else
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_ReadPoint_Text_First") + name
          + Messages.getInstance().getString("XMLBeans_ReadPoint_Text_Second") + node.getAttribute(ATT_NAME) 
          + Messages.getInstance().getString("XMLBeans_ReadPoint_Text_Third"));
  }

  result = new Point();
  ((Point) result).setLocation(x, y);

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the ColorUIResource from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readColorUIResource(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  String      name;
  Color       color;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  color    = null;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_COLOR))
      color = (Color) invokeReadFromXML(child);
    else
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_ReadColorUIResource_Text_First") + name
          + Messages.getInstance().getString("XMLBeans_ReadColorUIResource_Text_Second") + node.getAttribute(ATT_NAME)
          + Messages.getInstance().getString("XMLBeans_ReadColorUIResource_Text_Third"));
  }

  result = new ColorUIResource(color);

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the FontUIResource from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readFontUIResource(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  String      name;
  Font        font;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  font     = null;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FONT))
      font = (Font) invokeReadFromXML(child);
    else
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_ReadFontUIResource_Text_First") + name
          + Messages.getInstance().getString("XMLBeans_ReadFontUIResource_Text_Second") + node.getAttribute(ATT_NAME)
          + Messages.getInstance().getString("XMLBeans_ReadFontUIResource_Text_Third"));
  }

  result = new FontUIResource(font);

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * additional pre-processing can happen in derived classes before the actual
 * reading from XML (working on the raw XML). right now it does nothing with
 * the document, only empties the help-vector for the BeanInstances and reads
 * the IDs for the BeanInstances, s.t. the correct references can be set again
 * 
 * @param document the document to pre-process
 * @return the processed object
 * @throws Exception if post-processing fails
 * @see #m_BeanInstances
 */
@Override
protected Document readPreProcess(Document document) throws Exception {
  NodeList list;
  int i;
  Element node;
  String clsName;
  Vector<Element> children;
  int id;
  int n;
  Element child;

  m_BeanInstances = new Vector<Object>();
  m_BeanInstancesID = new Vector<Integer>();

  // get all BeanInstance nodes
  list = document.getElementsByTagName("*");
  clsName = BeanInstance.class.getName();
  for (i = 0; i < list.getLength(); i++) {
    node = (Element) list.item(i);

    // is it a BeanInstance?
    if (node.getAttribute(ATT_CLASS).equals(clsName)) {
      children = XMLDocument.getChildTags(node);
      id = m_BeanInstancesID.size();

      // get id-tag (if available)
      for (n = 0; n < children.size(); n++) {
        child = children.get(n);
        if (child.getAttribute(ATT_NAME).equals(VAL_ID)) {
          id = readIntFromXML(child);
        }
      }

      m_BeanInstancesID.add(new Integer(id));
    }
  }

  m_BeanInstances.setSize(m_BeanInstancesID.size());

  // set MetaBean to null
  m_CurrentMetaBean = null;

  // no BeanConnections -> see readPostProcess(Object)
  m_IgnoreBeanConnections = true;

  // reset BeanConnection-Relations
  m_BeanConnectionRelation = new Hashtable<Object, Vector<String>>();

  return document;
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * builds the Color from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readColor(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  int red;
  int green;
  int blue;
  String name;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  red = 0;
  green = 0;
  blue = 0;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_RED)) {
      red = readIntFromXML(child);
    } else if (name.equals(VAL_GREEN)) {
      green = readIntFromXML(child);
    } else if (name.equals(VAL_BLUE)) {
      blue = readIntFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new Color(red, green, blue);

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * builds the Dimension from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readDimension(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  double width;
  double height;
  String name;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  width = 0;
  height = 0;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_WIDTH)) {
      width = readDoubleFromXML(child);
    } else if (name.equals(VAL_HEIGHT)) {
      height = readDoubleFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new Dimension();
  ((Dimension) result).setSize(width, height);

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * builds the Font from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readFont(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  int style;
  int size;
  String name;
  String fontname;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  fontname = "";
  style = 0;
  size = 0;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_NAME)) {
      name = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_STYLE)) {
      style = readIntFromXML(child);
    } else if (name.equals(VAL_SIZE)) {
      size = readIntFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new Font(fontname, style, size);

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * builds the Point from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readPoint(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  double x;
  double y;
  String name;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  x = 0;
  y = 0;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_X)) {
      x = readDoubleFromXML(child);
    } else if (name.equals(VAL_Y)) {
      y = readDoubleFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new Point();
  ((Point) result).setLocation(x, y);

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * builds the BeanConnection from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readBeanConnection(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  String name;
  int i;
  int source;
  int target;
  int sourcePos;
  int targetPos;
  String event;
  boolean hidden;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  source = 0;
  target = 0;
  event = "";
  hidden = false;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_SOURCEID)) {
      source = readIntFromXML(child);
    } else if (name.equals(VAL_TARGETID)) {
      target = readIntFromXML(child);
    } else if (name.equals(VAL_EVENTNAME)) {
      event = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_HIDDEN)) {
      hidden = readBooleanFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  // get position of id
  sourcePos = m_BeanInstancesID.indexOf(new Integer(source));
  targetPos = m_BeanInstancesID.indexOf(new Integer(target));

  // do we currently ignore the connections?
  // Note: necessary because of the MetaBeans
  if (m_IgnoreBeanConnections) {
    addBeanConnectionRelation(m_CurrentMetaBean, sourcePos + "," + targetPos
      + "," + event + "," + hidden);
    return result;
  }

  // generate it normally
  result = createBeanConnection(sourcePos, targetPos, event, hidden);

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * builds the Loader from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readLoader(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  String name;
  String file;
  File fl;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = Class.forName(node.getAttribute(ATT_CLASS)).newInstance();
  children = XMLDocument.getChildTags(node);
  file = "";
  Object relativeB = null;
  boolean relative = false;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FILE)) {
      file = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_RELATIVE_PATH)) {
      relativeB = readFromXML(child);
      if (relativeB instanceof Boolean) {
        relative = ((Boolean) relativeB).booleanValue();
      }
    } else {
      readFromXML(result, name, child);
    }
  }

  if (result instanceof weka.core.converters.FileSourcedConverter) {
    ((weka.core.converters.FileSourcedConverter) result)
      .setUseRelativePath(relative);
  }

  if (file.equals("")) {
    file = null;
  }

  // set file only, if it exists
  if (file != null) {
    String tempFile = file;

    boolean containsEnv = false;
    containsEnv = Environment.containsEnvVariables(file);

    fl = new File(file);
    // only test for existence if the path does not contain environment vars
    // (trust that after they are resolved that everything is hunky dory).
    // Also
    // don't test if the file can be found as a resource in the classath
    if (containsEnv || fl.exists()
      || this.getClass().getClassLoader().getResource(file) != null) {
      ((weka.core.converters.AbstractFileLoader) result).setSource(new File(
        file));
    } else {
      System.out.println("WARNING: The file '" + tempFile
        + "' does not exist!");
    }
  }

  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:XMLBeans.java   
/**
 * builds the Saver from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readSaver(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  String name;
  String file;
  String dir;
  String prefix;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = Class.forName(node.getAttribute(ATT_CLASS)).newInstance();
  children = XMLDocument.getChildTags(node);
  file = null;
  dir = null;
  prefix = null;

  Object relativeB = null;
  boolean relative = false;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FILE)) {
      file = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_DIR)) {
      dir = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_PREFIX)) {
      prefix = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_RELATIVE_PATH)) {
      relativeB = readFromXML(child);
      if (relativeB instanceof Boolean) {
        relative = ((Boolean) relativeB).booleanValue();
      }
    } else {
      readFromXML(result, name, child);
    }
  }

  if ((file != null) && (file.length() == 0)) {
    file = null;
  }

  // savers only get directory and prefix, not file (KnowledgeFlow sets the
  // file/destination based on the relation, dir and prefix)
  if ((dir != null) && (prefix != null)) {
    ((weka.core.converters.AbstractFileSaver) result).setDir(dir);
    ((weka.core.converters.AbstractFileSaver) result).setFilePrefix(prefix);
  }

  if (result instanceof weka.core.converters.FileSourcedConverter) {
    ((weka.core.converters.FileSourcedConverter) result)
      .setUseRelativePath(relative);
  }

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * additional pre-processing can happen in derived classes before the 
 * actual reading from XML (working on the raw XML). right now it does 
 * nothing with the document, only empties the help-vector for the
 * BeanInstances and reads the IDs for the BeanInstances, s.t. the correct
 * references can be set again
 * 
 * @param document the document to pre-process
 * @return the processed object
 * @throws Exception if post-processing fails
 * @see #m_BeanInstances
 */
protected Document readPreProcess(Document document) throws Exception {
  NodeList        list;
  int             i;
  Element         node;
  String          clsName;
  Vector          children;
  int             id;
  int             n;
  Element         child;

  m_BeanInstances   = new Vector();
  m_BeanInstancesID = new Vector();

  // get all BeanInstance nodes
  list    = document.getElementsByTagName("*");
  clsName = BeanInstance.class.getName();
  for (i = 0; i < list.getLength(); i++) {
    node = (Element) list.item(i);

    // is it a BeanInstance?
    if (node.getAttribute(ATT_CLASS).equals(clsName)) {
      children = XMLDocument.getChildTags(node);
      id       = m_BeanInstancesID.size();

      // get id-tag (if available)
      for (n = 0; n < children.size(); n++) {
        child = (Element) children.get(n);
        if (child.getAttribute(ATT_NAME).equals(VAL_ID))
          id = readIntFromXML((Element) child);
      }

      m_BeanInstancesID.add(new Integer(id));
    }
  }

  m_BeanInstances.setSize(m_BeanInstancesID.size());

  // set MetaBean to null
  m_CurrentMetaBean = null;

  // no BeanConnections -> see readPostProcess(Object)
  m_IgnoreBeanConnections = true;

  // reset BeanConnection-Relations
  m_BeanConnectionRelation = new Hashtable();

  return document;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the Color from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readColor(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  int         red;
  int         green;
  int         blue;
  String      name;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  red      = 0;
  green    = 0;
  blue     = 0;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_RED))
      red = readIntFromXML(child);
    else if (name.equals(VAL_GREEN))
      green = readIntFromXML(child);
    else if (name.equals(VAL_BLUE))
      blue = readIntFromXML(child);
    else
      System.out.println("WARNING: '" + name
          + "' is not a recognized name for " + node.getAttribute(ATT_NAME) + "!");
  }

  result = new Color(red, green, blue);

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the Font from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readFont(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  int         style;
  int         size;
  String      name;
  String      fontname;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  fontname = "";
  style    = 0;
  size     = 0;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_NAME))
      name = (String) invokeReadFromXML(child);
    else if (name.equals(VAL_STYLE))
      style = readIntFromXML(child);
    else if (name.equals(VAL_SIZE))
      size = readIntFromXML(child);
    else
      System.out.println("WARNING: '" + name
          + "' is not a recognized name for " + node.getAttribute(ATT_NAME) + "!");
  }

  result = new Font(fontname, style, size);

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the BeanConnection from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readBeanConnection(Element node) throws Exception {
  Object                  result;
  Vector                  children;
  Element                 child;
  String                  name;
  int                     i;
  int                     source;
  int                     target;
  int                     sourcePos;
  int                     targetPos;
  String                  event;
  boolean                 hidden;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  source   = 0;
  target   = 0;
  event    = "";
  hidden   = false;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_SOURCEID))
      source = readIntFromXML(child);
    else if (name.equals(VAL_TARGETID))
      target = readIntFromXML(child);
    else if (name.equals(VAL_EVENTNAME))
      event = (String) invokeReadFromXML(child);
    else if (name.equals(VAL_HIDDEN))
      hidden = readBooleanFromXML(child);
    else
      System.out.println("WARNING: '" + name
          + "' is not a recognized name for " + node.getAttribute(ATT_NAME) + "!");
  }

  // get position of id
  sourcePos = m_BeanInstancesID.indexOf(new Integer(source));
  targetPos = m_BeanInstancesID.indexOf(new Integer(target));

  // do we currently ignore the connections?
  // Note: necessary because of the MetaBeans
  if (m_IgnoreBeanConnections) {
    addBeanConnectionRelation(m_CurrentMetaBean, sourcePos + "," + targetPos + "," + event + "," + hidden);
    return result;
  }

  // generate it normally
  result = createBeanConnection(sourcePos, targetPos, event, hidden);

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the Loader from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readLoader(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  String      name;
  String      file;
  File        fl;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = Class.forName(node.getAttribute(ATT_CLASS)).newInstance();
  children = XMLDocument.getChildTags(node);
  file     = "";
  Object relativeB = null;
  boolean relative = false;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FILE)) {
      file = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_RELATIVE_PATH)) {
      relativeB = readFromXML(child);
      if (relativeB instanceof Boolean) {
        relative = ((Boolean)relativeB).booleanValue();
      }
    } else {
      readFromXML(result, name, child);
    }
  }

  if (result instanceof weka.core.converters.FileSourcedConverter) {
    ((weka.core.converters.FileSourcedConverter)result).setUseRelativePath(relative);
  }

  if (file.equals(""))
    file = null;

  // set file only, if it exists
  if (file != null) {
    String tempFile = file;

    boolean containsEnv = false;
    containsEnv = Environment.containsEnvVariables(file);

    fl = new File(file);      
    // only test for existence if the path does not contain environment vars
    // (trust that after they are resolved that everything is hunky dory). Also 
    // don't test if the file can be found as a resource in the classath
    if (containsEnv || fl.exists() || 
        this.getClass().getClassLoader().getResource(file) != null) {
      ((weka.core.converters.AbstractFileLoader) result).setSource(new File(file));
    } else {
      System.out.println("WARNING: The file '" + tempFile + "' does not exist!");
    }
  }

  return result;
}
项目:autoweka    文件:XMLBeans.java   
/**
 * builds the Saver from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readSaver(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  String      name;
  String      file;
  String    dir;
  String    prefix;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = Class.forName(node.getAttribute(ATT_CLASS)).newInstance();
  children = XMLDocument.getChildTags(node);
  file     = null;
  dir      = null;
  prefix   = null;

  Object relativeB = null;
  boolean relative = false;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FILE)) {
      file = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_DIR)) {
      dir = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_PREFIX)) {
      prefix = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_RELATIVE_PATH)) {
      relativeB = readFromXML(child);
      if (relativeB instanceof Boolean) {
        relative = ((Boolean)relativeB).booleanValue();
      }
    } else {
      readFromXML(result, name, child);
    }
  }

  if ( (file != null) && (file.length() == 0) )
    file = null;

  // savers only get directory and prefix, not file (KnowledgeFlow sets the
  // file/destination based on the relation, dir and prefix)
  if ( (dir != null) && (prefix != null) ) {
    ((weka.core.converters.AbstractFileSaver) result).setDir(dir);
    ((weka.core.converters.AbstractFileSaver) result).setFilePrefix(prefix);
  }

  if (result instanceof weka.core.converters.FileSourcedConverter) {
    ((weka.core.converters.FileSourcedConverter)result).setUseRelativePath(relative);
  }

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * additional pre-processing can happen in derived classes before the actual
 * reading from XML (working on the raw XML). right now it does nothing with
 * the document, only empties the help-vector for the BeanInstances and reads
 * the IDs for the BeanInstances, s.t. the correct references can be set again
 * 
 * @param document the document to pre-process
 * @return the processed object
 * @throws Exception if post-processing fails
 * @see #m_BeanInstances
 */
@Override
protected Document readPreProcess(Document document) throws Exception {
  NodeList list;
  int i;
  Element node;
  String clsName;
  Vector<Element> children;
  int id;
  int n;
  Element child;

  m_BeanInstances = new Vector<Object>();
  m_BeanInstancesID = new Vector<Integer>();

  // get all BeanInstance nodes
  list = document.getElementsByTagName("*");
  clsName = BeanInstance.class.getName();
  for (i = 0; i < list.getLength(); i++) {
    node = (Element) list.item(i);

    // is it a BeanInstance?
    if (node.getAttribute(ATT_CLASS).equals(clsName)) {
      children = XMLDocument.getChildTags(node);
      id = m_BeanInstancesID.size();

      // get id-tag (if available)
      for (n = 0; n < children.size(); n++) {
        child = children.get(n);
        if (child.getAttribute(ATT_NAME).equals(VAL_ID)) {
          id = readIntFromXML(child);
        }
      }

      m_BeanInstancesID.add(new Integer(id));
    }
  }

  m_BeanInstances.setSize(m_BeanInstancesID.size());

  // set MetaBean to null
  m_CurrentMetaBean = null;

  // no BeanConnections -> see readPostProcess(Object)
  m_IgnoreBeanConnections = true;

  // reset BeanConnection-Relations
  m_BeanConnectionRelation = new Hashtable<Object, Vector<String>>();

  return document;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the Color from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readColor(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  int red;
  int green;
  int blue;
  String name;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  red = 0;
  green = 0;
  blue = 0;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_RED)) {
      red = readIntFromXML(child);
    } else if (name.equals(VAL_GREEN)) {
      green = readIntFromXML(child);
    } else if (name.equals(VAL_BLUE)) {
      blue = readIntFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new Color(red, green, blue);

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the Dimension from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readDimension(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  double width;
  double height;
  String name;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  width = 0;
  height = 0;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_WIDTH)) {
      width = readDoubleFromXML(child);
    } else if (name.equals(VAL_HEIGHT)) {
      height = readDoubleFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new Dimension();
  ((Dimension) result).setSize(width, height);

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the Font from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readFont(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  int style;
  int size;
  String name;
  String fontname;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  fontname = "";
  style = 0;
  size = 0;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_NAME)) {
      name = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_STYLE)) {
      style = readIntFromXML(child);
    } else if (name.equals(VAL_SIZE)) {
      size = readIntFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new Font(fontname, style, size);

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the Point from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readPoint(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  double x;
  double y;
  String name;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  x = 0;
  y = 0;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_X)) {
      x = readDoubleFromXML(child);
    } else if (name.equals(VAL_Y)) {
      y = readDoubleFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  result = new Point();
  ((Point) result).setLocation(x, y);

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the BeanConnection from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readBeanConnection(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  String name;
  int i;
  int source;
  int target;
  int sourcePos;
  int targetPos;
  String event;
  boolean hidden;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = null;
  children = XMLDocument.getChildTags(node);
  source = 0;
  target = 0;
  event = "";
  hidden = false;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_SOURCEID)) {
      source = readIntFromXML(child);
    } else if (name.equals(VAL_TARGETID)) {
      target = readIntFromXML(child);
    } else if (name.equals(VAL_EVENTNAME)) {
      event = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_HIDDEN)) {
      hidden = readBooleanFromXML(child);
    } else {
      System.out.println("WARNING: '" + name
        + "' is not a recognized name for " + node.getAttribute(ATT_NAME)
        + "!");
    }
  }

  // get position of id
  sourcePos = m_BeanInstancesID.indexOf(new Integer(source));
  targetPos = m_BeanInstancesID.indexOf(new Integer(target));

  // do we currently ignore the connections?
  // Note: necessary because of the MetaBeans
  if (m_IgnoreBeanConnections) {
    addBeanConnectionRelation(m_CurrentMetaBean, sourcePos + "," + targetPos
      + "," + event + "," + hidden);
    return result;
  }

  // generate it normally
  result = createBeanConnection(sourcePos, targetPos, event, hidden);

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the Loader from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readLoader(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  String name;
  String file;
  File fl;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = Class.forName(node.getAttribute(ATT_CLASS)).newInstance();
  children = XMLDocument.getChildTags(node);
  file = "";
  Object relativeB = null;
  boolean relative = false;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FILE)) {
      file = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_RELATIVE_PATH)) {
      relativeB = readFromXML(child);
      if (relativeB instanceof Boolean) {
        relative = ((Boolean) relativeB).booleanValue();
      }
    } else {
      readFromXML(result, name, child);
    }
  }

  if (result instanceof weka.core.converters.FileSourcedConverter) {
    ((weka.core.converters.FileSourcedConverter) result)
      .setUseRelativePath(relative);
  }

  if (file.equals("")) {
    file = null;
  }

  // set file only, if it exists
  if (file != null) {
    String tempFile = file;

    boolean containsEnv = false;
    containsEnv = Environment.containsEnvVariables(file);

    fl = new File(file);
    // only test for existence if the path does not contain environment vars
    // (trust that after they are resolved that everything is hunky dory).
    // Also
    // don't test if the file can be found as a resource in the classath
    if (containsEnv || fl.exists()
      || this.getClass().getClassLoader().getResource(file) != null) {
      ((weka.core.converters.AbstractFileLoader) result).setSource(new File(
        file));
    } else {
      System.out.println("WARNING: The file '" + tempFile
        + "' does not exist!");
    }
  }

  return result;
}
项目:umple    文件:XMLBeans.java   
/**
 * builds the Saver from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readSaver(Element node) throws Exception {
  Object result;
  Vector<Element> children;
  Element child;
  int i;
  String name;
  String file;
  String dir;
  String prefix;

  // for debugging only
  if (DEBUG) {
    trace(new Throwable(), node.getAttribute(ATT_NAME));
  }

  m_CurrentNode = node;

  result = Class.forName(node.getAttribute(ATT_CLASS)).newInstance();
  children = XMLDocument.getChildTags(node);
  file = null;
  dir = null;
  prefix = null;

  Object relativeB = null;
  boolean relative = false;

  for (i = 0; i < children.size(); i++) {
    child = children.get(i);
    name = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FILE)) {
      file = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_DIR)) {
      dir = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_PREFIX)) {
      prefix = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_RELATIVE_PATH)) {
      relativeB = readFromXML(child);
      if (relativeB instanceof Boolean) {
        relative = ((Boolean) relativeB).booleanValue();
      }
    } else {
      readFromXML(result, name, child);
    }
  }

  if ((file != null) && (file.length() == 0)) {
    file = null;
  }

  // savers only get directory and prefix, not file (KnowledgeFlow sets the
  // file/destination based on the relation, dir and prefix)
  if ((dir != null) && (prefix != null)) {
    ((weka.core.converters.AbstractFileSaver) result).setDir(dir);
    ((weka.core.converters.AbstractFileSaver) result).setFilePrefix(prefix);
  }

  if (result instanceof weka.core.converters.FileSourcedConverter) {
    ((weka.core.converters.FileSourcedConverter) result)
      .setUseRelativePath(relative);
  }

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * additional pre-processing can happen in derived classes before the 
 * actual reading from XML (working on the raw XML). right now it does 
 * nothing with the document, only empties the help-vector for the
 * BeanInstances and reads the IDs for the BeanInstances, s.t. the correct
 * references can be set again
 * 
 * @param document the document to pre-process
 * @return the processed object
 * @throws Exception if post-processing fails
 * @see #m_BeanInstances
 */
protected Document readPreProcess(Document document) throws Exception {
  NodeList        list;
  int             i;
  Element         node;
  String          clsName;
  Vector          children;
  int             id;
  int             n;
  Element         child;

  m_BeanInstances   = new Vector();
  m_BeanInstancesID = new Vector();

  // get all BeanInstance nodes
  list    = document.getElementsByTagName("*");
  clsName = BeanInstance.class.getName();
  for (i = 0; i < list.getLength(); i++) {
    node = (Element) list.item(i);

    // is it a BeanInstance?
    if (node.getAttribute(ATT_CLASS).equals(clsName)) {
      children = XMLDocument.getChildTags(node);
      id       = m_BeanInstancesID.size();

      // get id-tag (if available)
      for (n = 0; n < children.size(); n++) {
        child = (Element) children.get(n);
        if (child.getAttribute(ATT_NAME).equals(VAL_ID))
          id = readIntFromXML((Element) child);
      }

      m_BeanInstancesID.add(new Integer(id));
    }
  }

  m_BeanInstances.setSize(m_BeanInstancesID.size());

  // set MetaBean to null
  m_CurrentMetaBean = null;

  // no BeanConnections -> see readPostProcess(Object)
  m_IgnoreBeanConnections = true;

  // reset BeanConnection-Relations
  m_BeanConnectionRelation = new Hashtable();

  return document;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the Color from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readColor(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  int         red;
  int         green;
  int         blue;
  String      name;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  red      = 0;
  green    = 0;
  blue     = 0;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_RED))
      red = readIntFromXML(child);
    else if (name.equals(VAL_GREEN))
      green = readIntFromXML(child);
    else if (name.equals(VAL_BLUE))
      blue = readIntFromXML(child);
    else
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_ReadColor_Text_First") + name
          + Messages.getInstance().getString("XMLBeans_ReadColor_Text_Second") + node.getAttribute(ATT_NAME) + 
          Messages.getInstance().getString("XMLBeans_ReadColor_Text_Third"));
  }

  result = new Color(red, green, blue);

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the Font from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readFont(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  int         style;
  int         size;
  String      name;
  String      fontname;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  fontname = "";
  style    = 0;
  size     = 0;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_NAME))
      name = (String) invokeReadFromXML(child);
    else if (name.equals(VAL_STYLE))
      style = readIntFromXML(child);
    else if (name.equals(VAL_SIZE))
      size = readIntFromXML(child);
    else
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_ReadFont_Text_First") + name
          + Messages.getInstance().getString("XMLBeans_ReadFont_Text_Second") + node.getAttribute(ATT_NAME) + Messages.getInstance().getString("XMLBeans_ReadFont_Text_Third"));
  }

  result = new Font(fontname, style, size);

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the BeanConnection from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readBeanConnection(Element node) throws Exception {
  Object                  result;
  Vector                  children;
  Element                 child;
  String                  name;
  int                     i;
  int                     source;
  int                     target;
  int                     sourcePos;
  int                     targetPos;
  String                  event;
  boolean                 hidden;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = null;
  children = XMLDocument.getChildTags(node);
  source   = 0;
  target   = 0;
  event    = "";
  hidden   = false;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_SOURCEID))
      source = readIntFromXML(child);
    else if (name.equals(VAL_TARGETID))
      target = readIntFromXML(child);
    else if (name.equals(VAL_EVENTNAME))
      event = (String) invokeReadFromXML(child);
    else if (name.equals(VAL_HIDDEN))
      hidden = readBooleanFromXML(child);
    else
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_ReadBeanConnection_Text_First") + name
          + Messages.getInstance().getString("XMLBeans_ReadBeanConnection_Text_Second") + node.getAttribute(ATT_NAME) 
          + Messages.getInstance().getString("XMLBeans_ReadBeanConnection_Text_Third"));
  }

  // get position of id
  sourcePos = m_BeanInstancesID.indexOf(new Integer(source));
  targetPos = m_BeanInstancesID.indexOf(new Integer(target));

  // do we currently ignore the connections?
  // Note: necessary because of the MetaBeans
  if (m_IgnoreBeanConnections) {
    addBeanConnectionRelation(m_CurrentMetaBean, sourcePos + "," + targetPos + "," + event + "," + hidden);
    return result;
  }

  // generate it normally
  result = createBeanConnection(sourcePos, targetPos, event, hidden);

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the Loader from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readLoader(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  String      name;
  String      file;
  File        fl;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = Class.forName(node.getAttribute(ATT_CLASS)).newInstance();
  children = XMLDocument.getChildTags(node);
  file     = "";
  Object relativeB = null;
  boolean relative = false;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FILE)) {
      file = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_RELATIVE_PATH)) {
      relativeB = readFromXML(child);
      if (relativeB instanceof Boolean) {
        relative = ((Boolean)relativeB).booleanValue();
      }
    } else {
      readFromXML(result, name, child);
    }
  }

  if (result instanceof weka.core.converters.FileSourcedConverter) {
    ((weka.core.converters.FileSourcedConverter)result).setUseRelativePath(relative);
  }

  if (file.equals(""))
    file = null;

  // set file only, if it exists
  if (file != null) {
    String tempFile = file;

    boolean containsEnv = false;
    containsEnv = Environment.containsEnvVariables(file);

    fl = new File(file);      
    // only test for existence if the path does not contain environment vars
    // (trust that after they are resolved that everything is hunky dory)
    if (containsEnv || fl.exists()) {
      ((weka.core.converters.AbstractFileLoader) result).setSource(new File(file));
    } else {
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +Messages.getInstance().getString("XMLBeans_ReadLoader_Text_Front") + tempFile
            + Messages.getInstance().getString("XMLBeans_ReadLoader_Text_End"));
    }
  }

  return result;
}
项目:jbossBA    文件:XMLBeans.java   
/**
 * builds the Saver from the given DOM node.
 * 
 * @param node the associated XML node
 * @return the instance created from the XML description
 * @throws Exception if instantiation fails
 */
public Object readSaver(Element node) throws Exception {
  Object      result;
  Vector      children;
  Element     child;
  int         i;
  String      name;
  String      file;
  String    dir;
  String    prefix;

  // for debugging only
  if (DEBUG)
     trace(new Throwable(), node.getAttribute(ATT_NAME));

  m_CurrentNode = node;

  result   = Class.forName(node.getAttribute(ATT_CLASS)).newInstance();
  children = XMLDocument.getChildTags(node);
  file     = null;
  dir      = null;
  prefix   = null;

  Object relativeB = null;
  boolean relative = false;

  for (i = 0; i < children.size(); i++) {
    child = (Element) children.get(i);
    name  = child.getAttribute(ATT_NAME);

    if (name.equals(VAL_FILE)) {
      file = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_DIR)) {
      dir = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_PREFIX)) {
      prefix = (String) invokeReadFromXML(child);
    } else if (name.equals(VAL_RELATIVE_PATH)) {
      relativeB = readFromXML(child);
      if (relativeB instanceof Boolean) {
        relative = ((Boolean)relativeB).booleanValue();
      }
    } else {
      readFromXML(result, name, child);
    }
  }

  if ( (file != null) && (file.length() == 0) )
    file = null;

  // savers only get directory and prefix, not file (KnowledgeFlow sets the
  // file/destination based on the relation, dir and prefix)
  if ( (dir != null) && (prefix != null) ) {
    ((weka.core.converters.AbstractFileSaver) result).setDir(dir);
    ((weka.core.converters.AbstractFileSaver) result).setFilePrefix(prefix);
  }

  if (result instanceof weka.core.converters.FileSourcedConverter) {
    ((weka.core.converters.FileSourcedConverter)result).setUseRelativePath(relative);
  }

  return result;
}