private static String modifyFile(String str) throws IOException { String search = "<jndi-binding type=\"XAPooledDataSource\""; String last_search = "</jndi-binding>"; String newDB = "newDB_" + OSProcess.getId(); String jndi_str = "<jndi-binding type=\"XAPooledDataSource\" jndi-name=\"XAPooledDataSource\" jdbc-driver-class=\"org.apache.derby.jdbc.EmbeddedDriver\" init-pool-size=\"5\" max-pool-size=\"5\" idle-timeout-seconds=\"600\" blocking-timeout-seconds=\"6\" login-timeout-seconds=\"2\" conn-pooled-datasource-class=\"org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource\" xa-datasource-class=\"org.apache.derby.jdbc.EmbeddedXADataSource\" user-name=\"mitul\" password=\"83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a\" connection-url=\"jdbc:derby:" + newDB + ";create=true\" >"; String config_prop = "<config-property>" + "<config-property-name>description</config-property-name>" + "<config-property-type>java.lang.String</config-property-type>" + "<config-property-value>hi</config-property-value>" + "</config-property>" + "<config-property>" + "<config-property-name>user</config-property-name>" + "<config-property-type>java.lang.String</config-property-type>" + "<config-property-value>jeeves</config-property-value>" + "</config-property>" + "<config-property>" + "<config-property-name>password</config-property-name>" + "<config-property-type>java.lang.String</config-property-type>" + "<config-property-value>83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a</config-property-value> " + "</config-property>" + "<config-property>" + "<config-property-name>databaseName</config-property-name>" + "<config-property-type>java.lang.String</config-property-type>" + "<config-property-value>" + newDB + "</config-property-value>" + "</config-property>\n"; String new_str = jndi_str + config_prop; /* * String new_str = " <jndi-binding type=\"XAPooledDataSource\" * jndi-name=\"XAPooledDataSource\" * jdbc-driver-class=\"org.apache.derby.jdbc.EmbeddedDriver\" * init-pool-size=\"5\" max-pool-size=\"5\" idle-timeout-seconds=\"600\" * blocking-timeout-seconds=\"6\" login-timeout-seconds=\"2\" * conn-pooled-datasource-class=\"org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource\" * xa-datasource-class=\"org.apache.derby.jdbc.EmbeddedXADataSource\" * user-name=\"mitul\" * password=\"83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a\" * connection-url=\"jdbc:derby:"+newDB+";create=true\" > <property * key=\"description\" value=\"hi\"/> <property key=\"databaseName\" * value=\""+newDB+"\"/> <property key=\"user\" value=\"mitul\"/> <property * key=\"password\" * value=\"83f0069202c571faf1ae6c42b4ad46030e4e31c17409e19a\"/>"; */ int n1 = str.indexOf(search); getLogWriter().fine("Start Index = " + n1); int n2 = str.indexOf(last_search, n1); StringBuffer sbuff = new StringBuffer(str); getLogWriter().fine("END Index = " + n2); String modified_str = sbuff.replace(n1, n2, new_str).toString(); return modified_str; }
private String changePropertiesByColumns(String source, boolean qualified) throws XavaException { StringBuffer r = new StringBuffer(source); int i = r.toString().indexOf("${"); int f = 0; while (i >= 0) { f = r.toString().indexOf("}", i + 2); if (f < 0) break; String property = r.substring(i + 2, f); String column = "0"; // thus it remained if it is calculated if (!getMetaModel().isCalculated(property)) { column = Strings.isModelName(property) ? getTable(property) : qualified ? getQualifiedColumn(property) : getColumn(property); } r.replace(i, f + 1, column); i = r.toString().indexOf("${"); } return r.toString(); }
public String changePropertiesByCMPAttributes(String source) throws XavaException { StringBuffer r = new StringBuffer(source); int i = r.toString().indexOf("${"); int f = 0; while (i >= 0) { f = r.toString().indexOf("}", i + 2); if (f < 0) break; String property = r.substring(i + 2, f); String cmpAttribute = null; if (property.indexOf('.') >= 0) { cmpAttribute = "o._" + Strings.firstUpper(Strings.change(property, ".", "_")); } else { MetaProperty metaProperty = getMetaModel().getMetaProperty(property); if (metaProperty.getMapping().hasConverter()) { cmpAttribute = "o._" + Strings.firstUpper(property); } else { cmpAttribute = "o." + property; } } r.replace(i, f + 1, cmpAttribute); i = r.toString().indexOf("${"); } return r.toString(); }