Package tools.util

Examples of tools.util.SEXParser


}

public jiqlTableInfo(String t)throws SQLException{
  if (t ==null)return;
  //(" WTEFROM " + t);
  SEXParser sexp = new SEXParser();
  Enumeration en = sexp.parse(t);
  /*try{
 
  en = sexp.parse(t);
  }catch (Exc)*/
  while (en.hasMoreElements())
  {
    NameValue nv = (NameValue)en.nextElement();
  Enumeration eni = null;
  try{
 
   eni = sexp.parse(nv.value);
  }catch (Exception e){
 
    e.printStackTrace();
    throw jiqlException.get("tableinfo_parse_error",t + " Table Info Parse Error " + nv.value);
 
   
  }
  while (eni.hasMoreElements())
  {
    nv = (NameValue)eni.nextElement();
    //(nv.name + " TI FROM NV " + nv.value);
    if (nv.name.equals("name"))
      setName(nv.value);
    else if (nv.name.equals("prefix_value"))
      prefixValue = nv.value;
    else if (nv.name.equals("prefix"))
      prefix = new Boolean(nv.value).booleanValue();
    else if (nv.name.equals("tableleafs"))
      tableleafs = new Boolean(nv.value).booleanValue();
    else if (nv.name.equals("fieldList"))
      fieldList = new EZArrayList(new StringTokenizer(nv.value,";"));


    else if (nv.name.equals("primarykeys"))
      primarykeys = new EZArrayList(new StringTokenizer(nv.value,";"));
    else if (nv.name.equals("autoincrements"))
      autoincrement = new EZArrayList(new StringTokenizer(nv.value,";"));

    else if (nv.name.equals("notnulls"))
      notnulls = new EZArrayList(new StringTokenizer(nv.value,";"));
    else if (nv.name.equals("constraints"))
    {
       Enumeration enc = sexp.parse(nv.value);
      while (enc.hasMoreElements())
      {
        nv = (NameValue)enc.nextElement();
        Hashtable ch = sexp.parseToHash(nv.value);
        //(nv.name + " connFROM NV " + ch);
        jiqlConstraint jc = new jiqlConstraint();
        String cn = (String)ch.get("name");
        jc.setName(cn);
        String ty = (String)ch.get("type");
        jc.setType(Integer.parseInt(ty));
        String tar = (String)ch.get("target");
        EZArrayList tarv = new EZArrayList(new StringTokenizer(tar,";"));
        jc.addEnumeration(tarv.iterator());
        Hashtable rh = (Hashtable)ch.get("references");
        if (rh != null)
        {
        jiqlFunction jfr = new jiqlFunction();
        String rn = (String)rh.get("name");
        jfr.setName(rn);
        String rtar = (String)rh.get("target");
        EZArrayList rtarv = new EZArrayList(new StringTokenizer(rtar,";"));
        jfr.addEnumeration(rtarv.iterator());
        jc.setReference(jfr);
         
        }
        addConstraint(jc);
      }

     
    }
    else if (nv.name.equals("defaultvalues"))
    {
       Enumeration enc = sexp.parse(nv.value);
      while (enc.hasMoreElements())
      {
        nv = (NameValue)enc.nextElement();
        Hashtable ch = sexp.parseToHash(nv.value);
        String cn = (String)ch.get("field");
        Object fv = ch.get("value");
        defaultValues.put(cn,fv);
      }

View Full Code Here


  prefixValue = pn;
}

public String toString(){
  StringBuffer xml = new StringBuffer();
  SEXParser sp = new SEXParser();
  sp.addOpenNodeName("tableinfo",xml);
  //.addLineFeed(xml);
  sp.addOpenNodeName("name",xml);
  xml.append(getName());
  sp.addCloseNodeName("name",xml);

  sp.addOpenNodeName("prefix",xml);
  xml.append(prefix);
  sp.addCloseNodeName("prefix",xml);

  sp.addOpenNodeName("tableleafs",xml);
  xml.append(tableleafs);
  sp.addCloseNodeName("tableleafs",xml);

  sp.addOpenNodeName("prefix_value",xml);
  xml.append(prefixValue);
  sp.addCloseNodeName("prefix_value",xml);

  if (primarykeys.size() > 0)
  {
    sp.addOpenNodeName("primarykeys",xml);
    xml.append(primarykeys.toDelimitedString(";"));
    sp.addCloseNodeName("primarykeys",xml);
  }
  if (autoincrement.size() > 0)
  {
    sp.addOpenNodeName("autoincrements",xml);
    xml.append(autoincrement.toDelimitedString(";"));
    sp.addCloseNodeName("autoincrements",xml);
 
 
    if (fieldList.size() > 0)
  {
    sp.addOpenNodeName("fieldList",xml);
    xml.append(fieldList.toDelimitedString(";"));
    sp.addCloseNodeName("fieldList",xml);
  }
          //(getName() + " notnulls " + notnulls);

  if (notnulls.size() > 0)
  {
    sp.addOpenNodeName("notnulls",xml);
    xml.append(notnulls.toDelimitedString(";"));
    sp.addCloseNodeName("notnulls",xml);
  }

 
  if (constraints.size() > 0)
  {
  sp.addOpenNodeName("constraints",xml);
  //.addLineFeed(xml);
  Enumeration en = constraints.keys();
  while (en.hasMoreElements())
  {
    String jn = (String)en.nextElement();
    jiqlConstraint jc = (jiqlConstraint)constraints.get(jn);
    sp.addOpenNodeName("constraint",xml);
    //.addLineFeed(xml);
    sp.addOpenNodeName("name",xml);
    xml.append(jn);
    sp.addCloseNodeName("name",xml);
    //.addLineFeed(xml);
    sp.addOpenNodeName("type",xml);
    xml.append(jc.getType());
    sp.addCloseNodeName("type",xml);
    //.addLineFeed(xml);
    sp.addOpenNodeName("target",xml);
    xml.append(jc.toDelimitedString(";"));
    sp.addCloseNodeName("target",xml);
    //.addLineFeed(xml);
    jiqlFunction jref = jc.getReference();
    if (jref != null)
    {
    sp.addOpenNodeName("references",xml);
    //.addLineFeed(xml);
    sp.addOpenNodeName("name",xml);
    xml.append(jref.getName());
    sp.addCloseNodeName("name",xml);
    //.addLineFeed(xml);
    sp.addOpenNodeName("target",xml);
    xml.append(jref.toDelimitedString(";"));
    sp.addCloseNodeName("target",xml);
    //.addLineFeed(xml);     
    sp.addCloseNodeName("references",xml);
    //.addLineFeed(xml);
   
    sp.addCloseNodeName("constraint",xml);
    //.addLineFeed(xml);
  }
  sp.addCloseNodeName("constraints",xml);

   
  }
 
  if (defaultValues.size() > 0)
  {
  sp.addOpenNodeName("defaultvalues",xml);
  //.addLineFeed(xml);
  Enumeration en = defaultValues.keys();
  while (en.hasMoreElements())
  {
    String jn = (String)en.nextElement();
    Object jc = defaultValues.get(jn);
    sp.addOpenNodeName("defaultvalue",xml);
    //.addLineFeed(xml);
    sp.addOpenNodeName("field",xml);
    xml.append(jn);
    sp.addCloseNodeName("field",xml);
    //.addLineFeed(xml);
    sp.addOpenNodeName("value",xml);
    xml.append(jc.toString());
    sp.addCloseNodeName("value",xml);
    //.addLineFeed(xml);
 
    sp.addCloseNodeName("defaultvalue",xml);
    //.addLineFeed(xml);
  }
  sp.addCloseNodeName("defaultvalues",xml);

   
  }
 
 
  sp.addCloseNodeName("tableinfo",xml);
  return xml.toString();
}
View Full Code Here

TOP

Related Classes of tools.util.SEXParser

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.