Package pt.opensoft.text

Examples of pt.opensoft.text.Regex


  }

  public abstract List getNames ();

  public List getNames (String pattern) {
    Regex regex = new Regex(pattern);
    List names = getNames();
    List result = new ArrayList(names.size());
    for (Iterator iterator = names.iterator(); iterator.hasNext(); ) {
      String name = (String) iterator.next();
      if (regex.contains(name)) result.add(name);
    }
    return result;
  }
View Full Code Here


      throw new BuildException("MUST DEFINE 'currentVersion' ATTRIBUTE");
    }

    try {
      DateTime now = new DateTime();
      Regex version = new Regex(VERSION_PATTERN);
      Regex geek = new Regex(TECNICAL_PATTERN);

      BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(
        this.inputFilePath), "ISO-8859-1"));
      PrintStream writer = new PrintStream(new FileOutputStream(this.outputFilePath), false, "ISO-8859-1");

      writer.println("[Vers�o " + this.currentVersion + " (" + now.formatDate() + ")]");
      writer.println();

      boolean fullFile = this.lastVersion.equals(this.currentVersion);

      String line = reader.readLine();
      while (line != null) { // EOF
        if (!fullFile && version.matches(line) && (line.indexOf(this.lastVersion) != -1)) {
          break;
        } else if (version.matches(line) || geek.matches(line)) {
          line = reader.readLine();
          continue;
        } else {
          writer.println(line);
          line = reader.readLine();
View Full Code Here

  public static void createTable (Hashtable types, Hashtable tables, String ddl) {


    try {
            Regex regex = new Regex("CREATE\\s+TABLE\\s+(\\S+)\\s*\\((.*)\\)\\s*$",Regex.CASE_INSENSITIVE_MASK);

            if (regex.contains(ddl)) {

        String tableName = regex.getGroup(1);
        String fieldsDDL = regex.getGroup(2);

        Hashtable table = new Hashtable();

        table.put("name", tableName);
        table.put("className", tableName + "Table");
View Full Code Here

    Hashtable fields = new Hashtable();
    int max = 0;

    try {

            Regex regex = new Regex("(\\s+\\S+\\(\\d+)\\,(\\d+\\)\\s+)");

            fieldsDDL = regex.substitute(fieldsDDL, "$1;$2", Regex.SUBSTITUTE_ALL);

            Regex fieldDDLRegex1 = new Regex("^\\s*(\\S+)\\s+");

            Regex fieldDDLRegex2 = new Regex("(.*)\\s+NOT\\s+NULL", Regex.CASE_INSENSITIVE_MASK);
            Regex fieldDDLRegex3 = new Regex("(.*)\\s+NULL", Regex.CASE_INSENSITIVE_MASK);

            // fieldDDLRegex4 is dynamic

            Regex fieldDDLRegex5 = new Regex("(.*)\\((\\d+)\\)");
            Regex fieldDDLRegex6 = new Regex("(.*)\\((\\d+)\\;(\\d+)\\)");

      List list = new Regex(",").split(fieldsDDL);

      for (Iterator it = list.iterator(); it.hasNext(); ) {
        String fieldDDL = (String) it.next();

        if (! fieldDDLRegex1.contains(fieldDDL)) {
          throw new Exception("createFields::incorrect syntax::missing column name::"+fieldDDL);
                }

        String fieldName = fieldDDLRegex1.getGroup(1);
        String fieldId = getFieldId(fieldName);

        if (fieldId.length() > max) max = fieldId.length();

        String fieldNulls = "NULL";

        if (fieldDDLRegex2.contains(fieldDDL)) {
          fieldDDL = fieldDDLRegex2.getGroup(1);
          fieldNulls = "NOT NULL";
        } else if (fieldDDLRegex3.contains(fieldDDL)) {
          fieldDDL = fieldDDLRegex3.getGroup(1);
        }

        String fieldSize = "-1";

        String fieldType = "integer";

                Regex fieldDDLRegex4 = new Regex(fieldName+"\\s+(.*)\\s*$");

                if (fieldDDLRegex4.contains(fieldDDL)) {
          fieldType = fieldDDLRegex4.getGroup(1).trim();
        }

        if (fieldDDLRegex5.contains(fieldType)) {
          fieldType = fieldDDLRegex5.getGroup(1);
          fieldSize = fieldDDLRegex5.getGroup(2);
View Full Code Here

  public static void createView (Hashtable tables, Hashtable views, String ddl) {
        try {
            String viewName;

            Regex viewDDLRegex1 = new Regex("CREATE\\s+VIEW\\s+(\\S+)", Regex.CASE_INSENSITIVE_MASK);

      if (!viewDDLRegex1.contains(ddl)) {
        throw new Exception("undefined view name in ddl: "+ddl);
            }

      viewName = viewDDLRegex1.getGroup(1);

      if (debug >= 1) System.out.println(lineSeparator+"  Creating View '"+viewName+"'...");

      Hashtable view = new Hashtable();

      views.put(viewName, view);

      view.put("name", viewName);
      view.put("className", viewName + "ViewTable");
      view.put("type", "ViewTable");

      if (packageName == null)
        view.put("fullClassName", viewName + "ViewTable");
      else
        view.put("fullClassName", packageName + "." + viewName + "ViewTable");

      String columnNames = null;

            Regex viewDDLRegex2 = new Regex("CREATE\\s+VIEW\\s+\\S+\\s*\\((.*)\\)", Regex.CASE_INSENSITIVE_MASK);

      if (viewDDLRegex2.contains(ddl)){
        columnNames = viewDDLRegex2.getGroup(1);
            }

      if (debug >= 2) System.out.println(lineSeparator+"    Columns '"+columnNames+"'");

      String selectFields;

            Regex viewDDLRegex3 = new Regex("SELECT\\s+DISTINCT\\s+(.*)\\s+FROM", Regex.CASE_INSENSITIVE_MASK);
            Regex viewDDLRegex4 = new Regex("SELECT\\s+(.*)\\s+FROM", Regex.CASE_INSENSITIVE_MASK);

      if (viewDDLRegex3.contains(ddl)) {
        selectFields = viewDDLRegex3.getGroup(1);
            } else if (viewDDLRegex4.contains(ddl)) {
        selectFields = viewDDLRegex4.getGroup(1);
            } else {
        throw new Exception("no select columns in create view ddl: "+ddl);
            }

      if (debug >= 2) System.out.println(lineSeparator+"    Select Fields '"+selectFields+"'");

      String tableNames;

            Regex viewDDLRegex5 = new Regex("FROM\\s+(.*)\\s+WHERE", Regex.CASE_INSENSITIVE_MASK);
            Regex viewDDLRegex6 = new Regex("FROM\\s+(.*)", Regex.CASE_INSENSITIVE_MASK);

      if (viewDDLRegex5.contains(ddl)) {
        tableNames = viewDDLRegex5.getGroup(1);
            } else if (viewDDLRegex6.contains(ddl)) {
        tableNames = viewDDLRegex6.getGroup(1);
            } else {
        throw new Exception("no tables in create view ddl: "+ddl);
            }

            Regex viewDDLRegex7 = new Regex(",", Regex.CASE_INSENSITIVE_MASK);
      List vTableNames = viewDDLRegex7.split(tableNames);

      Vector vTables = new Vector();

      for (Iterator it = vTableNames.iterator(); it.hasNext(); ) {
        String tableName = (String) it.next();
View Full Code Here

    if (columnNames == null) columnNames = selectFields;

    try {

      List columns = new Regex(",").split(columnNames);
      List selectColumns = new Regex(",").split(selectFields);

      int i = 0;
      for (Iterator it = columns.iterator(); it.hasNext(); i++) {
        String column = (String) it.next();
        String selectColumn = (String) selectColumns.get(i);

                Regex regex1 = new Regex("(\\S+)");

        if (!regex1.contains(column)) {
          throw new Exception("incorrect syntax::missing column name::"+columnNames);
                }

        String columnName = regex1.getGroup(1);

                Regex regex2 = new Regex("\\S+\\.(\\S+))");
        if (regex2.contains(columnName)){
          columnName = regex2.getGroup(1);
                }

        Hashtable field = new Hashtable();

        String fieldId = getFieldId(columnName);

        field.put("name", columnName);
        field.put("id", fieldId);

        if (fieldId.length() > max) max = fieldId.length();

        String tableName = null;
        String tableFieldName = null;

                Regex regex3 = new Regex("(\\S+)\\.(\\S+)");
        if (regex3.contains(selectColumn)) {
          tableName = regex3.getGroup(1);
          tableFieldName = regex3.getGroup(2);
        }

        if (debug >= 2) System.out.println("    Adding field: "+columnName+" "+tableName+" "+tableFieldName);

        if (tableName != null) {
View Full Code Here

  //-----------------------------------------------------------------------------------------

  public static void alterTable (Hashtable tables, String ddl) {
    try {

            Regex tableNameRegex = new Regex("ALTER\\s+TABLE\\s+(\\w+)", Regex.CASE_INSENSITIVE_MASK);

            if (!tableNameRegex.contains(ddl)) {
        throw new Exception("missing table name::"+ddl);
            }

            String tableName = tableNameRegex.getGroup(1);

      Hashtable table = (Hashtable) tables.get(tableName);

      Hashtable fields = (Hashtable) table.get("fields");

      String expr = "ADD\\s.*PRIMARY\\s+KEY\\s*\\((.*)\\)";

      if (server.equalsIgnoreCase("ORACLE")) {
        if( new Regex("ADD\\s*CONSTRAINT", Regex.CASE_INSENSITIVE_MASK).contains(ddl) )  // added support for named primary keys constraints
          expr = "ADD\\s+CONSTRAINT\\s.*PRIMARY\\s+KEY\\s*\\((.*)\\)";
        else
          expr = "ADD\\s*\\(\\s*PRIMARY\\s+KEY\\s*\\((.*)\\)\\s*\\)";
      }else if(server.equalsIgnoreCase("SQLSERVER")) {
        expr = "ADD\\s.*PRIMARY\\s+KEY\\s+CLUSTERED\\s*\\((.*)\\)";
      }

            Regex regex1 = new Regex(expr, Regex.CASE_INSENSITIVE_MASK);

      if (regex1.contains(ddl)) {

                if (debug >= 1) System.out.println(lineSeparator+"  Altering table '"+tableName+"'");

        String keyFieldsDDL = regex1.getGroup(1);

                Regex regex2 = new Regex(",");

        List keyFields = regex2.split(keyFieldsDDL);

        for (Iterator it = keyFields.iterator(); it.hasNext(); ) {
          String fieldName = ((String) it.next()).trim();

          Hashtable field = (Hashtable) fields.get(fieldName);
View Full Code Here

      if (debug >= 1) System.out.println("  Inserting package name in template...");

      if (packageName == null)  {

        tableTemplate = new Regex("\\<packageDeclaration.*;\\s*\\>").substitute(tableTemplate, "");

            } else {

        tableTemplate = new Regex("\\<packageDeclaration\\s*(.*;\\s*)\\>").substitute(tableTemplate,"$1");

        tableTemplate = new Regex("\\<packageName\\>").substitute(tableTemplate, packageName, Regex.SUBSTITUTE_ALL);

      }

      //le a declaracao de um field do template

      if (debug >= 1) System.out.println("  Reading field declaration from template...");

            Regex regex = new Regex("\\<fieldDeclaration(.*;)\\>");

      if (!regex.contains(tableTemplate)) {
        throw new Exception("invalid syntax in template::field declaration");
            }

      String fieldDeclaration = regex.getGroup(1);

      //substitui a declaracao completa, pela tag de declaracao

      if (debug >= 1) System.out.println("  Replacing field declaration in template...");

      tableTemplate = new Regex("(\\<fieldDeclaration).*;(\\>)").substitute(tableTemplate,"$1$2");

      //le a declaracao do metodo de adicionar um field a Table

      if (debug >= 1) System.out.println("  Reading addField declaration from template...");

            Regex regex2 = new Regex("\\<addFieldDeclaration(.*;)\\>");
      if (!regex2.contains(tableTemplate)) {
        throw new Exception("invalid syntax in template::add field declaration");
            }

            String addFieldDeclaration = regex2.getGroup(1);

      //substitui a declaracao completa, pela tag de declaracao

      if (debug >= 1) System.out.println("  Replacing addField declaration in template...");

      tableTemplate = new Regex("(\\<addFieldDeclaration).*;(\\>)").substitute(tableTemplate, "$1$2");

      if (debug >= 1) System.out.println("  Making templates for each table...");

      for (Enumeration en = tables.keys(); en.hasMoreElements(); ) {
        //comeca a gerar uma nova tabela

        String newTable = tableTemplate;

        String tableName = (String) en.nextElement();
        newTable = new Regex("\\<tableName\\>", Regex.DEFAULT_MASK).substitute(newTable, tableName, Regex.SUBSTITUTE_ALL);

        Hashtable table = (Hashtable) tables.get(tableName);

        String className = tableName + "Table";
        String fullClassName = (String) table.get("fullClassName");

        newTable = new Regex("\\<className\\>", Regex.DEFAULT_MASK).substitute(newTable, className, Regex.SUBSTITUTE_ALL);

        newTable = new Regex("\\<fullClassName\\>", Regex.DEFAULT_MASK).substitute(newTable, fullClassName, Regex.SUBSTITUTE_ALL);
       
        newTable = new Regex("\\<serialVersionUID\\>", Regex.DEFAULT_MASK).substitute(newTable, String.valueOf(RandomUtil.randomLong()), Regex.SUBSTITUTE_ALL);

        String tableType = (String) table.get("type");
        newTable = new Regex("\\<tableType\\>", Regex.DEFAULT_MASK).substitute(newTable, tableType, Regex.SUBSTITUTE_ALL);

        int max = Integer.parseInt((String) table.get("max"));
        Hashtable fields = (Hashtable) table.get("fields");
        Vector orderedFields = (Vector) table.get("orderedFields");

        StringBuffer fieldDeclarations = new StringBuffer();
        StringBuffer addKeyDeclarations = new StringBuffer();
        StringBuffer addFieldDeclarations = new StringBuffer();

        for (Enumeration enum1 = orderedFields.elements(); enum1.hasMoreElements(); ) {
          String fieldName = (String) enum1.nextElement();
          Hashtable field = (Hashtable) fields.get(fieldName);

          String fieldId = (String) field.get("id");

          fieldId = StringUtil.appendChars(fieldId, ' ', max);

          String newFieldDeclaration = new Regex("<fieldId>").substitute(fieldDeclaration, fieldId);
          newFieldDeclaration = new Regex("<fieldName>").substitute(newFieldDeclaration, fieldName);

          String newAddFieldDeclaration = new Regex("<fieldId>").substitute(addFieldDeclaration, fieldId);

          String fieldType = (String) field.get("type");
          newAddFieldDeclaration = new Regex("<fieldType>").substitute(newAddFieldDeclaration, fieldType);

          if (sizes) {
            String fieldSize = (String) field.get("size");
            if (fieldSize == null) fieldSize = "";
            newAddFieldDeclaration = new Regex("<fieldSize>").substitute(newAddFieldDeclaration, fieldSize);
          } else {
            newAddFieldDeclaration = new Regex(",\\s+<fieldSize>").substitute(newAddFieldDeclaration, "");
          }

          String fieldKey = (String) field.get("key");

          if (fieldDeclarations.length() != 0) fieldDeclarations.append(lineSeparator);
          fieldDeclarations.append(newFieldDeclaration);

          if (fieldKey != null && fieldKey.equals("true")) {
            newAddFieldDeclaration = new Regex("<fieldKey>").substitute(newAddFieldDeclaration, "Key  ");
            if (addKeyDeclarations.length() != 0) addKeyDeclarations.append(lineSeparator);
            addKeyDeclarations.append(newAddFieldDeclaration);
          } else {
            newAddFieldDeclaration = new Regex("<fieldKey>").substitute(newAddFieldDeclaration, "Field");
            if (addFieldDeclarations.length() != 0) addFieldDeclarations.append(lineSeparator);
            addFieldDeclarations.append(newAddFieldDeclaration);
          }
        }

        if (addKeyDeclarations.length() != 0) addKeyDeclarations.append(lineSeparator+lineSeparator);

        newTable = new Regex("<fieldDeclaration>").substitute(newTable, fieldDeclarations.toString());
        newTable = new Regex("<addFieldDeclaration>").substitute(newTable, addKeyDeclarations.toString()+addFieldDeclarations.toString());

        writeFile(destinationDir+fileSeparator+tableName+"Table.java", newTable);
      }
    } catch (Exception e) {
      System.err.println("ERROR: "+e);
View Full Code Here

      //caso o packageName seja null retira a declaracao do package no template

      if (debug >= 1) System.out.println("  Inserting package name in template...");

      if (packageName == null) {
        tableTemplate = new Regex("\\<packageDeclaration.*;\\s*\\>").substitute(tableTemplate, "");
            } else {
        tableTemplate = new Regex("\\<packageDeclaration\\s*(.*;\\s*)\\>").substitute(tableTemplate, "$1");
        tableTemplate = new Regex("\\<packageName\\>", Regex.DEFAULT_MASK).substitute(tableTemplate, packageName, Regex.SUBSTITUTE_ALL);
      }

      //le a declaracao de um field do template

      if (debug >= 1) System.out.println("  Reading field declaration from template...");

            Regex regex1 = new Regex("\\<fieldDeclaration(.*;)\\>");
      if (!regex1.contains(tableTemplate)) {
        throw new Exception("invalid syntax in template::field declaration");
            }

      String fieldDeclaration = regex1.getGroup(1);

      //substitui a declaracao completa, pela tag de declaracao

      if (debug >= 1) System.out.println("  Replacing field declaration in template...");

      tableTemplate = new Regex("(\\<fieldDeclaration).*;(\\>)").substitute(tableTemplate, "$1$2");

      //le a declaracao de um table field do template

      if (debug >= 1) System.out.println("  Reading tableField declaration from template...");

            Regex regex2 = new Regex("\\<tableFieldDeclaration(.*;)\\>");

            if (!regex2.contains(tableTemplate))
        throw new Exception("invalid syntax in template::table field declaration");

      String tableFieldDeclaration = regex2.getGroup(1);

      //substitui a declaracao completa, pela tag de declaracao

      if (debug >= 1) System.out.println("  Replacing tableField declaration in template...");

      tableTemplate = new Regex("(\\<tableFieldDeclaration).*;(\\>)").substitute(tableTemplate, "$1$2");

      //le a declaracao do metodo de adicionar uma tabela

      if (debug >= 1) System.out.println("  Reading addTable declaration from template...");

            Regex regex3 = new Regex("\\<addTableDeclaration(.*;)\\>");

      if (!regex3.contains(tableTemplate)) {
        throw new Exception("invalid syntax in template::add table declaration");
            }

      String addTableDeclaration = regex3.getGroup(1);

      //substitui a declaracao completa, pela tag de declaracao

      if (debug >= 1) System.out.println("  Replacing table declaration from template...");

      tableTemplate = new Regex("(\\<addTableDeclaration).*;(\\>)").substitute(tableTemplate, "$1$2");

      //le a declaracao do metodo de adicionar um field a Table

      if (debug >= 1) System.out.println("  Reading addField declaration from template...");

            Regex regex4 = new Regex("\\<addFieldDeclaration(.*;)\\>");
      if (!regex4.contains(tableTemplate)) {
        throw new Exception("invalid syntax in template::add field declaration");
            }

      String addFieldDeclaration = regex4.getGroup(1);

      //substitui a declaracao completa, pela tag de declaracao

      if (debug >= 1) System.out.println("  Replacing addField declaration from template...");

      tableTemplate = new Regex("(\\<addFieldDeclaration).*;(\\>)").substitute(tableTemplate, "$1$2");

      if (debug >= 1) System.out.println("  Making templates for each view...");

      for (Enumeration en = views.keys(); en.hasMoreElements(); ) {
        //comeca a gerar uma nova view

        String newTable = tableTemplate;

        String viewName = (String) en.nextElement();

        if (debug >= 2) System.out.println("    Replacing view name tag by: '"+viewName+"'...");

        newTable = new Regex("\\<viewName\\>", Regex.DEFAULT_MASK).substitute(newTable, viewName, Regex.SUBSTITUTE_ALL);

        if (debug >= 2) System.out.println("    Getting view '"+viewName+"'...");

        Hashtable view = (Hashtable) views.get(viewName);

        if (debug >= 2) System.out.println("    Getting view table name...");

        String tableName = (String) view.get("tableName");

        if (debug >= 2) System.out.println("    Getting table '"+tableName+"'...");

        Hashtable table = (Hashtable) tables.get(tableName);

        if (debug >= 2) System.out.println("    Getting table class name...");

        String tableClassName = (String) table.get("className");

        if (debug >= 2) System.out.println("    Getting view class name...");

        String viewClassName = (String) view.get("className");

        if (debug >= 2) System.out.println("    Getting view full class name...");

        String fullViewClassName = (String) view.get("fullClassName");

        if (debug >= 2) System.out.println("    Replacing viewClassName tag '"+viewClassName+"'...");

        newTable = new Regex("<viewClassName>", Regex.DEFAULT_MASK).substitute(newTable, viewClassName, Regex.SUBSTITUTE_ALL);

        if (debug >= 2) System.out.println("    Replacing fullViewClassName tag '"+fullViewClassName+"'...");

        newTable = new Regex("<fullViewClassName>", Regex.DEFAULT_MASK).substitute(newTable, fullViewClassName, Regex.SUBSTITUTE_ALL);

        if (debug >= 2) System.out.println("    Replacing className tag '"+tableClassName+"'...");

        newTable = new Regex("<className>", Regex.DEFAULT_MASK).substitute(newTable, tableClassName, Regex.SUBSTITUTE_ALL);

        String viewType = (String) view.get("type");
        newTable = new Regex("<viewType>", Regex.DEFAULT_MASK).substitute(newTable, viewType, Regex.SUBSTITUTE_ALL);

        int max = Integer.parseInt((String) view.get("max"));
        Hashtable fields = (Hashtable) view.get("fields");
        Vector orderedFields = (Vector) view.get("orderedFields");
        Vector viewTables = (Vector) view.get("tables");

        StringBuffer fieldDeclarations = new StringBuffer();
        StringBuffer tableFieldDeclarations = new StringBuffer();
        StringBuffer addTableDeclarations = new StringBuffer();
        StringBuffer addFieldDeclarations = new StringBuffer();

        for (int i = 1; i < viewTables.size(); i++) {
          String thisTableName = (String) viewTables.elementAt(i);
          String newAddTableDeclaration = new Regex("<className>", Regex.DEFAULT_MASK).substitute(addTableDeclaration, thisTableName+"Table", Regex.SUBSTITUTE_ALL);

          if (addTableDeclarations.length() != 0) addTableDeclarations.append(lineSeparator);
          addTableDeclarations.append(newAddTableDeclaration);
        }

        for (Enumeration enum1 = orderedFields.elements(); enum1.hasMoreElements(); ) {
          String fieldName = (String) enum1.nextElement();
          Hashtable field = (Hashtable) fields.get(fieldName);

          String fieldId = (String) field.get("id");
          String fieldTableName = (String) field.get("tableName");
          String tableFieldId = getFieldId((String) field.get("tableFieldName"));

          fieldId = StringUtil.appendChars(fieldId, ' ', max);

          String newFieldDeclaration = new Regex("<fieldId>").substitute(fieldDeclaration, fieldId);
          newFieldDeclaration = new Regex("<fieldName>").substitute(newFieldDeclaration, fieldName);

          String newTableFieldDeclaration = new Regex("<fieldId>").substitute(tableFieldDeclaration, fieldId);
          newTableFieldDeclaration = new Regex("<tableName>").substitute(newTableFieldDeclaration, fieldTableName + "Table");
          newTableFieldDeclaration = new Regex("<tableFieldId>").substitute(newTableFieldDeclaration, tableFieldId);

          String newAddFieldDeclaration = new Regex("<fieldId>", Regex.DEFAULT_MASK).substitute(addFieldDeclaration, fieldId, Regex.SUBSTITUTE_ALL);
          newAddFieldDeclaration = new Regex("<className>",  Regex.DEFAULT_MASK).substitute(newAddFieldDeclaration, fieldTableName+"Table", Regex.SUBSTITUTE_ALL);

          if (sizes) {
            String fieldSize = (String) field.get("size");
            if (fieldSize == null) fieldSize = "";
            newAddFieldDeclaration = new Regex("<fieldSize>").substitute(newAddFieldDeclaration, fieldSize);
          } else {
            newAddFieldDeclaration = new Regex(",\\s+<fieldSize>").substitute(newAddFieldDeclaration, "");
          }

          if (fieldDeclarations.length() != 0) fieldDeclarations.append(lineSeparator);
          fieldDeclarations.append(newFieldDeclaration);

          if (tableFieldDeclarations.length() != 0) tableFieldDeclarations.append(lineSeparator);
          tableFieldDeclarations.append(newTableFieldDeclaration);

          if (addFieldDeclarations.length() != 0) addFieldDeclarations.append(lineSeparator);
          addFieldDeclarations.append(newAddFieldDeclaration);
        }

        newTable = new Regex("<fieldDeclaration>").substitute(newTable, fieldDeclarations.toString()+lineSeparator);
        newTable = new Regex("<tableFieldDeclaration>").substitute(newTable, tableFieldDeclarations.toString());
        newTable = new Regex("<addTableDeclaration>").substitute(newTable, addTableDeclarations.toString());
        newTable = new Regex("<addFieldDeclaration>").substitute(newTable, addFieldDeclarations.toString());

        writeFile(destinationDir+fileSeparator+viewName+"ViewTable.java", newTable);
      }
    } catch (Exception e) {
      System.err.println("ERROR: "+e.getMessage());
View Full Code Here

      if (type == null) throw new Exception("unknown type::"+type);

      for (Enumeration en = types.keys(); en.hasMoreElements(); ) {
        String key = (String) en.nextElement();

        if (!new Regex(server, Regex.CASE_INSENSITIVE_MASK).contains(key)) continue;

        if (debug >= 5) System.out.println("        searching key: "+key+"  "+server+"  "+type);

        String expression = key.substring(key.lastIndexOf(".")+1);

        if (!new Regex(expression, Regex.CASE_INSENSITIVE_MASK).matches(type)) continue;

        String value = (String) types.get(key);

        if (debug >= 4) System.out.print("        "+server+": "+type+" =~ "+expression+" -> "+value);

        if (value == null) throw new Exception("unknown type::"+type);
        type = value;

        if (new Regex("Types").contains(type)) return type;

        value = (String) types.get(type);
        if (type == null) throw new Exception("unknown type::"+type);

        if (debug >= 4) System.out.println(" -> "+value);
View Full Code Here

TOP

Related Classes of pt.opensoft.text.Regex

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.