List of usage examples for java.lang StringBuffer delete
@Override public synchronized StringBuffer delete(int start, int end)
From source file:de.tarent.maven.plugins.pkg.helper.Helper.java
/** * Investigates the project's runtime dependencies and creates a dependency * line suitable for the control file from them. * //from w ww . j a v a 2s. com * @return */ public final String createDependencyLine(Set<Artifact> resolvedDependencies) throws MojoExecutionException { String defaults; StringBuffer manualDeps = new StringBuffer(); Iterator<String> ite = targetConfiguration.getManualDependencies().iterator(); while (ite.hasNext()) { String dep = ite.next(); manualDeps.append(dep); manualDeps.append(", "); } // Handle dependencies to other targetconfigurations which create binary // packages. List<String> relatedPackageNames = Utils.createPackageNames(apm.getProject().getArtifactId(), resolvedRelations, packageMap.isDebianNaming()); ite = relatedPackageNames.iterator(); while (ite.hasNext()) { String tcName = ite.next(); manualDeps.append(tcName); manualDeps.append(", "); } if (manualDeps.length() >= 2) { manualDeps.delete(manualDeps.length() - 2, manualDeps.length()); } /* * The user can override the defaultDependencyLine from the package-map. * This is helpful for debian wheezy, when the app should use * openjdk-7-jre-headless instead of default-jre. */ if (targetConfiguration.getDefaultDependencyLine() != null && !targetConfiguration.getDefaultDependencyLine().isEmpty()) { defaults = targetConfiguration.getDefaultDependencyLine(); } else { defaults = packageMap.getDefaultDependencyLine(); } // If all dependencies should be bundled the package will only // need the default Java dependencies of the system and the remainder // of the method can be skipped. if (targetConfiguration.isBundleAll()) { return Utils.joinDependencyLines(defaults, manualDeps.toString()); } final StringBuilder line = new StringBuilder(); // Add default system dependencies for Java packages. line.append(defaults); // Visitor implementation which creates the dependency line. Visitor v = new Visitor() { Set<String> processedDeps = new HashSet<String>(); public void bundle(Artifact _) { // Nothing to do here. bundleDependencies should take care of // this. } public void visit(Artifact artifact, Entry entry) { // Certain Maven Packages have only one package in the target // system. // If that one was already added we should not add it any more. if (processedDeps.contains(entry.dependencyLine)) { return; } if (entry.dependencyLine.length() == 0) { l.warn("Invalid package name for artifact: " + entry.artifactSpec); } line.append(", "); line.append(entry.dependencyLine); // Mark as included dependency. processedDeps.add(entry.dependencyLine); } }; if (!targetConfiguration.isIgnoreDependencies()) { packageMap.iterateDependencyArtifacts(l, resolvedDependencies, v, true); } return Utils.joinDependencyLines(line.toString(), manualDeps.toString()); }
From source file:marytts.tools.dbselection.WikipediaMarkupCleaner.java
private StringBuffer removeSectionRef(Scanner s, StringBuffer lineIn) { String next;/*www . j a v a 2s.c om*/ int index1 = 0, index2 = -1, index3 = -1, endTagLength = 0, numRef = 0; boolean closeRef = true; StringBuffer line = new StringBuffer(lineIn); StringBuffer nextLine; while ((index1 = line.indexOf("<ref")) >= 0) { // in one line can be more than one reference numRef++; if ((index2 = line.indexOf("</ref>", index1)) >= 0) endTagLength = 6 + index2; else if ((index3 = line.indexOf("/>", index1)) >= 0) endTagLength = 2 + index3; if (index2 == -1 && index3 == -1) {// the </ref> most be in the next lines, so get more lines until the </ref> is found while (s.hasNext() && numRef != 0) { nextLine = new StringBuffer(s.nextLine()); if (nextLine.indexOf("<ref") >= 0) numRef++; line.append(nextLine); if ((index2 = line.indexOf("</ref>", index1)) >= 0) { numRef--; endTagLength = 6 + index2; } else if ((index3 = line.indexOf("/>", index1)) >= 0) { numRef--; endTagLength = 2 + index3; } } } else // the endTag was found numRef--; if (numRef == 0) { index1 = line.indexOf("<ref"); // get again this because the position might change if (endTagLength > index1) { line.delete(index1, endTagLength); //System.out.println("nextline="+line); } else { if (debug) { System.out.print("iniTag: <ref index1=" + index1); System.out.print(" endTagLength=" + endTagLength); System.out.println(" line.length=" + line.length() + " line: " + line); System.out.println("removeSectionRef: WARNING endTagLength > length of line: " + line); //line.delete(index1, line.length()); } line = new StringBuffer(""); } } else { if (debug) System.out.println("removeSectionRef: WARNING no </ref> or /> in " + line); //line.delete(index1, line.length()); line = new StringBuffer(""); } } // while this line contains iniTag-s return line; }
From source file:de.marcelkapfer.morseconverter.MainActivity.java
public void decode(View view) { EditText editText = (EditText) findViewById(R.id.edit_message); StringBuffer message = new StringBuffer(editText.getText()); if (message.toString().endsWith(" ")) { message = message.deleteCharAt(message.length() - 1); }/*from ww w . j a v a2 s . c o m*/ // Variables StringBuffer input = new StringBuffer(); input = input.replace(0, input.length(), message.toString().toUpperCase()); StringBuffer output = new StringBuffer(); if (input.toString().equals("")) { tfOutput = "Please enter at least one character"; After(view); } else if (input.toString().equals("LETTERSPACE")) { tfOutput = "#"; After(view); } else if (input.toString().equals("END OF WORK")) { tfOutput = "000101"; After(view); } else if (input.toString().equals("ERROR")) { tfOutput = "00000000"; After(view); } else if (input.toString().equals("STARTING SIGNAL")) { tfOutput = "10101"; After(view); } else if (input.toString().equals("ENDING SIGNAL")) { tfOutput = "01010"; After(view); } else if (input.toString().equals("UNDERSTOOD")) { tfOutput = "00010"; After(view); } else if (input.toString().equals("WAIT")) { tfOutput = "01000"; After(view); } else if (input.toString().equals("SOS")) { tfOutput = "000111000"; After(view); } else if (input.toString().equals("LETTER SPACE")) { tfOutput = "#"; After(view); } else if (input.toString().equals("WORD SPACE")) { tfOutput = "+"; After(view); } else { for (int c = input.length(); c > 0; c--) { if (input.toString().startsWith(" ")) { if (output.toString().endsWith("#")) { output.delete(output.length() - 1, output.length()); } output.append("+"); input.delete(0, 1); } else if (input.toString().startsWith("A")) { output.append("01#"); input.delete(0, 1); } else if (input.toString().startsWith("B")) { output.append("1000#"); input.delete(0, 1); } else if (input.toString().startsWith("C")) { output.append("1010#"); input.delete(0, 1); } else if (input.toString().startsWith("D")) { output.append("100#"); input.delete(0, 1); } else if (input.toString().startsWith("E")) { output.append("0#"); input.delete(0, 1); } else if (input.toString().startsWith("F")) { output.append("0010#"); input.delete(0, 1); } else if (input.toString().startsWith("G")) { output.append("110#"); input.delete(0, 1); } else if (input.toString().startsWith("H")) { output.append("0000#"); input.delete(0, 1); } else if (input.toString().startsWith("I")) { output.append("00#"); input.delete(0, 1); } else if (input.toString().startsWith("J")) { output.append("0111#"); input.delete(0, 1); } else if (input.toString().startsWith("K")) { output.append("101#"); input.delete(0, 1); } else if (input.toString().startsWith("L")) { output.append("0100#"); input.delete(0, 1); } else if (input.toString().startsWith("M")) { output.append("11#"); input.delete(0, 1); } else if (input.toString().startsWith("N")) { output.append("10#"); input.delete(0, 1); } else if (input.toString().startsWith("O")) { output.append("111#"); input.delete(0, 1); } else if (input.toString().startsWith("P")) { output.append("0110#"); input.delete(0, 1); } else if (input.toString().startsWith("Q")) { output.append("1101#"); input.delete(0, 1); } else if (input.toString().startsWith("R")) { output.append("010#"); input.delete(0, 1); } else if (input.toString().startsWith("S")) { output.append("000#"); input.delete(0, 1); } else if (input.toString().startsWith("T")) { output.append("1#"); input.delete(0, 1); } else if (input.toString().startsWith("U")) { output.append("001#"); input.delete(0, 1); } else if (input.toString().startsWith("V")) { output.append("0001#"); input.delete(0, 1); } else if (input.toString().startsWith("W")) { output.append("011#"); input.delete(0, 1); } else if (input.toString().startsWith("X")) { output.append("1001#"); input.delete(0, 1); } else if (input.toString().startsWith("Y")) { output.append("1011#"); input.delete(0, 1); } else if (input.toString().startsWith("Z")) { output.append("1100#"); input.delete(0, 1); } else if (input.toString().startsWith("0")) { output.append("11111#"); input.delete(0, 1); } else if (input.toString().startsWith("1")) { output.append("01111#"); input.delete(0, 1); } else if (input.toString().startsWith("2")) { output.append("00111#"); input.delete(0, 1); } else if (input.toString().startsWith("3")) { output.append("00011#"); input.delete(0, 1); } else if (input.toString().startsWith("4")) { output.append("00001#"); input.delete(0, 1); } else if (input.toString().startsWith("5")) { output.append("00000#"); input.delete(0, 1); } else if (input.toString().startsWith("6")) { output.append("10000#"); input.delete(0, 1); } else if (input.toString().startsWith("7")) { output.append("11000#"); input.delete(0, 1); } else if (input.toString().startsWith("8")) { output.append("11100#"); input.delete(0, 1); } else if (input.toString().startsWith("9")) { output.append("11110#"); input.delete(0, 1); } else if (input.toString().startsWith("")) { output.append("0101#"); input.delete(0, 1); } else if (input.toString().startsWith("")) { output.append("1110#"); input.delete(0, 1); } else if (input.toString().startsWith("")) { output.append("0011#"); input.delete(0, 1); } else if (input.toString().startsWith("")) { output.append("00011000#"); input.delete(0, 1); } else if (input.toString().startsWith(".")) { output.append("010101#"); input.delete(0, 1); } else if (input.toString().startsWith(",")) { output.append("110011#"); input.delete(0, 1); } else if (input.toString().startsWith(":")) { output.append("111000#"); input.delete(0, 1); } else if (input.toString().startsWith(";")) { output.append("101010#"); input.delete(0, 1); } else if (input.toString().startsWith("?")) { output.append("001100#"); input.delete(0, 1); } else if (input.toString().startsWith("!")) { output.append("101011#"); input.delete(0, 1); } else if (input.toString().startsWith("-")) { output.append("100001#"); input.delete(0, 1); } else if (input.toString().startsWith("_")) { output.append("001101#"); input.delete(0, 1); } else if (input.toString().startsWith("(")) { output.append("10110#"); input.delete(0, 1); } else if (input.toString().startsWith(")")) { output.append("101101#"); input.delete(0, 1); } else if (input.toString().startsWith("=")) { output.append("10001#"); input.delete(0, 1); } else if (input.toString().startsWith("+")) { output.append("01010#"); input.delete(0, 1); } else if (input.toString().startsWith("/")) { output.append("10010#"); input.delete(0, 1); } else if (input.toString().startsWith("@")) { output.append("011010#"); input.delete(0, 1); } else if (input.toString().startsWith("'")) { output.append("011110#"); input.delete(0, 1); } else if (input.toString().startsWith("$")) { output.append("0001001#"); input.delete(0, 1); } else { tfOutput = "Code not listed or wrong."; } } if (output.toString().endsWith("#")) { output.delete(output.length() - 1, output.length()); } tfOutput = output.toString(); lastFragment = 0; After(view); } }
From source file:de.marcelkapfer.morseconverter.MainActivity.java
public void llm(View view) { EditText editText = (EditText) findViewById(R.id.edit_message); StringBuffer message = new StringBuffer(editText.getText()); if (message.toString().endsWith(" ")) { message = message.deleteCharAt(message.length() - 1); }//from ww w .j av a 2 s . c o m // Variables // Variables StringBuffer input = new StringBuffer(); input = input.replace(0, input.length(), message.toString().toUpperCase()); StringBuffer output = new StringBuffer(); if (input.toString().equals("")) { tfOutput = "Please enter at least one character"; After(view); } else if (input.toString().equals("LETTERSPACE")) { tfOutput = " "; After(view); } else if (input.toString().equals("END OF WORK")) { tfOutput = "...-.-"; After(view); } else if (input.toString().equals("ERROR")) { tfOutput = "........"; After(view); } else if (input.toString().equals("STARTING SIGNAL")) { tfOutput = "-.-.-"; After(view); } else if (input.toString().equals("ENDING SIGNAL")) { tfOutput = ".-.-."; After(view); } else if (input.toString().equals("UNDERSTOOD")) { tfOutput = "...-."; After(view); } else if (input.toString().equals("WAIT")) { tfOutput = ".-..."; After(view); } else if (input.toString().equals("SOS")) { tfOutput = "...---..."; After(view); } else if (input.toString().equals("LETTER SPACE")) { tfOutput = " "; After(view); } else if (input.toString().equals("WORD SPACE")) { tfOutput = " "; After(view); } else { for (int c = input.length(); c > 0; c--) { if (input.toString().startsWith(" ")) { if (output.toString().endsWith(" ")) { output.delete(output.length() - 3, output.length()); } output.append(" "); input.delete(0, 1); } else if (input.toString().startsWith("A")) { output.append(".- "); input.delete(0, 1); } else if (input.toString().startsWith("B")) { output.append("-... "); input.delete(0, 1); } else if (input.toString().startsWith("C")) { output.append("-.-. "); input.delete(0, 1); } else if (input.toString().startsWith("D")) { output.append("-.. "); input.delete(0, 1); } else if (input.toString().startsWith("E")) { output.append(". "); input.delete(0, 1); } else if (input.toString().startsWith("F")) { output.append("..-. "); input.delete(0, 1); } else if (input.toString().startsWith("G")) { output.append("--. "); input.delete(0, 1); } else if (input.toString().startsWith("H")) { output.append(".... "); input.delete(0, 1); } else if (input.toString().startsWith("I")) { output.append(".. "); input.delete(0, 1); } else if (input.toString().startsWith("J")) { output.append(".--- "); input.delete(0, 1); } else if (input.toString().startsWith("K")) { output.append("-.- "); input.delete(0, 1); } else if (input.toString().startsWith("L")) { output.append(".-.. "); input.delete(0, 1); } else if (input.toString().startsWith("M")) { output.append("-- "); input.delete(0, 1); } else if (input.toString().startsWith("N")) { output.append("-. "); input.delete(0, 1); } else if (input.toString().startsWith("O")) { output.append("--- "); input.delete(0, 1); } else if (input.toString().startsWith("P")) { output.append(".--. "); input.delete(0, 1); } else if (input.toString().startsWith("Q")) { output.append("--.- "); input.delete(0, 1); } else if (input.toString().startsWith("R")) { output.append(".-. "); input.delete(0, 1); } else if (input.toString().startsWith("S")) { output.append("... "); input.delete(0, 1); } else if (input.toString().startsWith("T")) { output.append("- "); input.delete(0, 1); } else if (input.toString().startsWith("U")) { output.append("..- "); input.delete(0, 1); } else if (input.toString().startsWith("V")) { output.append("...- "); input.delete(0, 1); } else if (input.toString().startsWith("W")) { output.append(".-- "); input.delete(0, 1); } else if (input.toString().startsWith("X")) { output.append("-..- "); input.delete(0, 1); } else if (input.toString().startsWith("Y")) { output.append("-.-- "); input.delete(0, 1); } else if (input.toString().startsWith("Z")) { output.append("--.. "); input.delete(0, 1); } else if (input.toString().startsWith("0")) { output.append("----- "); input.delete(0, 1); } else if (input.toString().startsWith("1")) { output.append(".---- "); input.delete(0, 1); } else if (input.toString().startsWith("2")) { output.append("..--- "); input.delete(0, 1); } else if (input.toString().startsWith("3")) { output.append("...-- "); input.delete(0, 1); } else if (input.toString().startsWith("4")) { output.append("....- "); input.delete(0, 1); } else if (input.toString().startsWith("5")) { output.append("..... "); input.delete(0, 1); } else if (input.toString().startsWith("6")) { output.append("-.... "); input.delete(0, 1); } else if (input.toString().startsWith("7")) { output.append("--... "); input.delete(0, 1); } else if (input.toString().startsWith("8")) { output.append("---.. "); input.delete(0, 1); } else if (input.toString().startsWith("9")) { output.append("----. "); input.delete(0, 1); } else if (input.toString().startsWith("")) { output.append(".-.- "); input.delete(0, 1); } else if (input.toString().startsWith("")) { output.append("---. "); input.delete(0, 1); } else if (input.toString().startsWith("")) { output.append("..-- "); input.delete(0, 1); } else if (input.toString().startsWith("")) { output.append("...--... "); input.delete(0, 1); } else if (input.toString().startsWith(".")) { output.append(".-.-.- "); input.delete(0, 1); } else if (input.toString().startsWith(",")) { output.append("--..-- "); input.delete(0, 1); } else if (input.toString().startsWith(":")) { output.append("---... "); input.delete(0, 1); } else if (input.toString().startsWith(";")) { output.append("-.-.-. "); input.delete(0, 1); } else if (input.toString().startsWith("?")) { output.append("..--.. "); input.delete(0, 1); } else if (input.toString().startsWith("!")) { output.append("-.-.-- "); input.delete(0, 1); } else if (input.toString().startsWith("-")) { output.append("-....- "); input.delete(0, 1); } else if (input.toString().startsWith("_")) { output.append("..--.- "); input.delete(0, 1); } else if (input.toString().startsWith("(")) { output.append("-.--. "); input.delete(0, 1); } else if (input.toString().startsWith(")")) { output.append("-.--.- "); input.delete(0, 1); } else if (input.toString().startsWith("=")) { output.append("-...- "); input.delete(0, 1); } else if (input.toString().startsWith("+")) { output.append(".-.-. "); input.delete(0, 1); } else if (input.toString().startsWith("/")) { output.append("-..-. "); input.delete(0, 1); } else if (input.toString().startsWith("@")) { output.append(".--.-. "); input.delete(0, 1); } else if (input.toString().startsWith("'")) { output.append(".----. "); input.delete(0, 1); } else if (input.toString().startsWith("$")) { output.append("...-..- "); input.delete(0, 1); } else { tfOutput = "Code not listed or wrong."; } } if (output.toString().endsWith(" ")) { output.delete(output.length() - 3, output.length()); } tfOutput = output.toString(); lastFragment = 1; After(view); } }
From source file:org.oscm.identityservice.bean.IdentityServiceBean.java
void checkMinimumUserRoleConstrains(PlatformUser user) throws ValidationException { if (user.getKey() > 0) { dm.flush();/* w w w .j av a 2 s .c om*/ dm.refresh(user); } dm.refresh(user.getOrganization()); final Set<OrganizationRoleType> orgRoles = user.getOrganization().getGrantedRoleTypes(); if (orgRoles.isEmpty()) { final ValidationException ve = new ValidationException( "Organization must have at least one role, before creating a user. OrgId: " + user.getOrganization().getOrganizationId()); logger.logWarn(Log4jLogger.SYSTEM_LOG | Log4jLogger.AUDIT_LOG, ve, LogMessageIdentifier.ERROR_USER_CREATION_FAILED_WITH_VALIDATION_ERROR); throw ve; } if (orgRoles.size() == 1 && orgRoles.iterator().next() == OrganizationRoleType.CUSTOMER) { ValidationException ve = new ValidationException(ReasonEnum.CUSTOMER_CREATION_ONLY_ON_MARKETPLACE, null, null); logger.logWarn(Log4jLogger.SYSTEM_LOG | Log4jLogger.AUDIT_LOG, ve, LogMessageIdentifier.ERROR_USER_CREATION_FAILED_WITH_VALIDATION_ERROR); throw ve; } final List<UserRoleType> requiredUserRoles = new ArrayList<>(); for (OrganizationRoleType orgRole : orgRoles) { final UserRoleType userRole = orgRole.correspondingUserRole(); if (userRole != null) { if (user.hasRole(userRole) || user.hasRole(UserRoleType.ORGANIZATION_ADMIN)) { return; } requiredUserRoles.add(userRole); } } final String[] s = new String[requiredUserRoles.size()]; for (int i = 0; i < requiredUserRoles.size(); i++) { s[i] = requiredUserRoles.get(i).name(); } final StringBuffer orgRoleString = new StringBuffer(); for (OrganizationRoleType orgRole : orgRoles) { orgRoleString.append(" and ").append(orgRole.name()); } orgRoleString.delete(0, 5); final StringBuffer userRoleString = new StringBuffer(); for (UserRoleType userRole : requiredUserRoles) { userRoleString.append(" or ").append(userRole.name()); } userRoleString.delete(0, 4); final ValidationException ve = new ValidationException(ReasonEnum.ROLE_REQUIRED, null, s); logger.logWarn(Log4jLogger.SYSTEM_LOG | Log4jLogger.AUDIT_LOG, ve, LogMessageIdentifier.WARN_USER_ROLE_REQUIRED, user.getUserId(), userRoleString.toString()); throw ve; }
From source file:org.talend.esb.job.api.test.TestConsumerJob.java
public void tFixedFlowInput_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFixedFlowInput_1_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; String currentComponent = ""; try {/*ww w.ja va 2 s.c o m*/ String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row1Struct row1 = new row1Struct(); row2Struct row2 = new row2Struct(); row3Struct row3 = new row3Struct(); row5Struct row5 = new row5Struct(); row4Struct row4 = new row4Struct(); row6Struct row6 = new row6Struct(); /** * [tLogRow_1 begin ] start */ ok_Hash.put("tLogRow_1", false); start_Hash.put("tLogRow_1", System.currentTimeMillis()); currentComponent = "tLogRow_1"; int tos_count_tLogRow_1 = 0; // ///////////////////// final String OUTPUT_FIELD_SEPARATOR_tLogRow_1 = "|"; java.io.PrintStream consoleOut_tLogRow_1 = null; int nb_line_tLogRow_1 = 0; // ///////////////////// /** * [tLogRow_1 begin ] stop */ /** * [tJavaFlex_2 begin ] start */ ok_Hash.put("tJavaFlex_2", false); start_Hash.put("tJavaFlex_2", System.currentTimeMillis()); currentComponent = "tJavaFlex_2"; int tos_count_tJavaFlex_2 = 0; // start part of your Java code /** * [tJavaFlex_2 begin ] stop */ /** * [tLogRow_2 begin ] start */ ok_Hash.put("tLogRow_2", false); start_Hash.put("tLogRow_2", System.currentTimeMillis()); currentComponent = "tLogRow_2"; int tos_count_tLogRow_2 = 0; // ///////////////////// final String OUTPUT_FIELD_SEPARATOR_tLogRow_2 = "|"; java.io.PrintStream consoleOut_tLogRow_2 = null; int nb_line_tLogRow_2 = 0; // ///////////////////// /** * [tLogRow_2 begin ] stop */ /** * [tJavaFlex_3 begin ] start */ ok_Hash.put("tJavaFlex_3", false); start_Hash.put("tJavaFlex_3", System.currentTimeMillis()); currentComponent = "tJavaFlex_3"; int tos_count_tJavaFlex_3 = 0; // start part of your Java code /** * [tJavaFlex_3 begin ] stop */ /** * [tESBConsumer_1 begin ] start */ ok_Hash.put("tESBConsumer_1", false); start_Hash.put("tESBConsumer_1", System.currentTimeMillis()); currentComponent = "tESBConsumer_1"; int tos_count_tESBConsumer_1 = 0; javax.xml.namespace.QName serviceName_tESBConsumer_1 = null; javax.xml.namespace.QName portName_tESBConsumer_1 = null; // [TA] commented run in TOS part due to external dependencies :: begin // org.talend.ws.helper.ServiceInvokerHelper serviceInvokerHelper_tESBConsumer_1 = null; // [TA] commented run in TOS part due to external dependencies :: end ESBConsumer consumer_tESBConsumer_1 = null; if (registry != null) { consumer_tESBConsumer_1 = registry.createConsumer(new ESBEndpointInfo() { @SuppressWarnings("serial") private java.util.Map<String, Object> props = new java.util.HashMap<String, Object>() { { put("wsdlURL", "http://www.deeptraining.com/webservices/weather.asmx?WSDL"); put("dataFormat", "PAYLOAD"); put("portName", "{}"); put("serviceName", "{}"); put("defaultOperationName", ""); put("defaultOperationNameSpace", ""); } }; public String getEndpointUri() { // projectName + "_" + processName + "_" + // componentName return "TEST_FakeESBJob_tESBConsumer_1"; } public java.util.Map<String, Object> getEndpointProperties() { return props; } public String getEndpointKey() { return "cxf"; } }); } else { System.out.println(""); System.out.println(""); System.out.println("|"); class Util_tESBConsumer_1 { public final String LIST_SIZE_SYMBOL = ".size"; public final String LEFT_SQUARE_BRACKET = "["; public final String RIGHT_SQUARE_BRACKET = "]"; public final String ALL_LIST_SYMBOL = "[*]"; public Object getValue(java.util.Map<String, Object> map, String path) { if (path == null || "".equals(path)) { return null; } if (map == null || map.isEmpty()) { return null; } java.util.List<String> paths = new java.util.ArrayList<String>(); resolvePath(map, path, paths); if (paths.size() > 0) { if (path.indexOf(ALL_LIST_SYMBOL) == -1) { return map.get(paths.get(0)); } else { int size = paths.size(); java.util.List<Object> out = new java.util.ArrayList<Object>(size); for (int i = 0; i < size; i++) { out.add(map.get(paths.get(i))); } return out; } } else { return null; } } public void resolveInputPath(java.util.Map<String, Object> inputMap) { java.util.Map<String, Object> tempStoreMap = new java.util.HashMap<String, Object>(); java.util.List<String> tempRemovePath = new java.util.ArrayList<String>(); for (String key : inputMap.keySet()) { if (key.indexOf(ALL_LIST_SYMBOL) != -1) { String listHeadPath = key.substring(0, key.indexOf(ALL_LIST_SYMBOL)); String listFootPath = key .substring(key.indexOf(ALL_LIST_SYMBOL) + ALL_LIST_SYMBOL.length()); java.util.List listElement = (java.util.List) inputMap.get(key); for (int i = 0; i < listElement.size(); i++) { tempStoreMap.put(listHeadPath + LEFT_SQUARE_BRACKET + i + RIGHT_SQUARE_BRACKET + listFootPath, listElement.get(i)); } tempRemovePath.add(key); } } inputMap.putAll(tempStoreMap); for (String removePath : tempRemovePath) { inputMap.remove(removePath); } } public void resolvePath(java.util.Map<String, Object> map, String path, java.util.List<String> paths) { String listHeadPath = ""; String listFootPath = ""; int size = 0; String tempPath = ""; if (path.indexOf(ALL_LIST_SYMBOL) != -1) { listHeadPath = path.substring(0, path.indexOf(ALL_LIST_SYMBOL)); listFootPath = path .substring(path.indexOf(ALL_LIST_SYMBOL) + ALL_LIST_SYMBOL.length()); if (map.get(listHeadPath) == null && map.get(listHeadPath + LIST_SIZE_SYMBOL) != null) { size = Integer.parseInt(map.get(listHeadPath + LIST_SIZE_SYMBOL).toString()); for (int i = 0; i < size; i++) { tempPath = listHeadPath + LEFT_SQUARE_BRACKET + i + RIGHT_SQUARE_BRACKET + listFootPath; if (tempPath.indexOf(ALL_LIST_SYMBOL) != -1) { resolvePath(map, tempPath, paths); } else { paths.add(tempPath); } } } } else { paths.add(path); } } public java.util.List<Object> normalize(String inputValue, String delimiter) { if (inputValue == null || "".equals(inputValue)) { return null; } Object[] inputValues = inputValue.split(delimiter); return java.util.Arrays.asList(inputValues); } public String denormalize(java.util.List inputValues, String delimiter) { if (inputValues == null || inputValues.isEmpty()) { return null; } StringBuffer sb = new StringBuffer(); for (Object o : inputValues) { sb.append(String.valueOf(o)); sb.append(delimiter); } if (sb.length() > 0) { sb.delete(sb.length() - delimiter.length(), sb.length()); } return sb.toString(); } } // [TA] commented run in TOS part due to external dependencies :: begin // System.setProperty("org.apache.commons.logging.Log", // "org.apache.commons.logging.impl.NoOpLog"); // // shade the log level for DynamicClientFactory.class // java.util.logging.Logger LOG_tESBConsumer_1 = org.apache.cxf.common.logging.LogUtils // .getL7dLogger(org.apache.cxf.endpoint.dynamic.DynamicClientFactory.class); // LOG_tESBConsumer_1 // .setLevel(java.util.logging.Level.WARNING); // // Util_tESBConsumer_1 util_tESBConsumer_1 = new Util_tESBConsumer_1(); // // org.talend.ws.helper.conf.ServiceHelperConfiguration config_tESBConsumer_1 = // new org.talend.ws.helper.conf.ServiceHelperConfiguration(); // // config_tESBConsumer_1.setConnectionTimeout(Long // .valueOf(20000)); // config_tESBConsumer_1 // .setReceiveTimeout(Long.valueOf(20000)); // // config_tESBConsumer_1.setKeyStoreFile(System // .getProperty("javax.net.ssl.keyStore")); // config_tESBConsumer_1.setKeyStoreType(System // .getProperty("javax.net.ssl.keyStoreType")); // config_tESBConsumer_1.setKeyStorePwd(System // .getProperty("javax.net.ssl.keyStorePassword")); // org.talend.ws.helper.ServiceDiscoveryHelper serviceDiscoveryHelper_tESBConsumer_1 = null; // // java.net.URI uri_tESBConsumer_1 = new java.net.URI( // "http://www.deeptraining.com/webservices/weather.asmx?WSDL"); // if ("http".equals(uri_tESBConsumer_1.getScheme()) // || "https".equals(uri_tESBConsumer_1.getScheme())) { // serviceInvokerHelper_tESBConsumer_1 = new org.talend.ws.helper.ServiceInvokerHelper( // "http://www.deeptraining.com/webservices/weather.asmx?WSDL", // config_tESBConsumer_1, ""); // } else { // serviceDiscoveryHelper_tESBConsumer_1 = new org.talend.ws.helper.ServiceDiscoveryHelper( // "http://www.deeptraining.com/webservices/weather.asmx?WSDL", // ""); // serviceInvokerHelper_tESBConsumer_1 = new org.talend.ws.helper.ServiceInvokerHelper( // serviceDiscoveryHelper_tESBConsumer_1, // config_tESBConsumer_1); // } // // serviceName_tESBConsumer_1 = new javax.xml.namespace.QName( // "", ""); // portName_tESBConsumer_1 = new javax.xml.namespace.QName("", // ""); // // java.util.Map<String, Object> inMap_tESBConsumer_1 = null; // [TA] commented run in TOS part due to external dependencies :: end } /** * [tESBConsumer_1 begin ] stop */ /** * [tJavaFlex_1 begin ] start */ ok_Hash.put("tJavaFlex_1", false); start_Hash.put("tJavaFlex_1", System.currentTimeMillis()); currentComponent = "tJavaFlex_1"; int tos_count_tJavaFlex_1 = 0; // start part of your Java code /** * [tJavaFlex_1 begin ] stop */ /** * [tFixedFlowInput_1 begin ] start */ ok_Hash.put("tFixedFlowInput_1", false); start_Hash.put("tFixedFlowInput_1", System.currentTimeMillis()); currentComponent = "tFixedFlowInput_1"; int tos_count_tFixedFlowInput_1 = 0; globalMap.put("NB_LINE", 1); for (int i_tFixedFlowInput_1 = 0; i_tFixedFlowInput_1 < 1; i_tFixedFlowInput_1++) { // row1.payloadString = "<request>hi</request>"; row1.payloadString = "<GetWeather xmlns='http://litwinconsulting.com/webservices/'><City>bonn</City></GetWeather>"; /** * [tFixedFlowInput_1 begin ] stop */ /** * [tFixedFlowInput_1 main ] start */ currentComponent = "tFixedFlowInput_1"; tos_count_tFixedFlowInput_1++; /** * [tFixedFlowInput_1 main ] stop */ /** * [tJavaFlex_1 main ] start */ currentComponent = "tJavaFlex_1"; // here is the main part of the component, // a piece of code executed in the row // loop org.dom4j.Document doc = org.dom4j.DocumentHelper.parseText(row1.payloadString); Document talendDoc = new Document(); talendDoc.setDocument(doc); row2.payload = talendDoc; tos_count_tJavaFlex_1++; /** * [tJavaFlex_1 main ] stop */ /** * [tESBConsumer_1 main ] start */ currentComponent = "tESBConsumer_1"; row3 = null; row4 = null; org.dom4j.Document responseDoc_tESBConsumer_1 = null; try { Document requestTalendDoc = row2.payload; if (consumer_tESBConsumer_1 == null) { // [TA] commented run in TOS part due to external dependencies :: begin // try { // responseDoc_tESBConsumer_1 = serviceInvokerHelper_tESBConsumer_1 // .invoke(serviceName_tESBConsumer_1, // portName_tESBConsumer_1, "", // requestTalendDoc.getDocument()); // } catch (javax.xml.ws.soap.SOAPFaultException e) { // String faultString = e.getFault() // .getFaultString(); // Document faultTalendDoc = null; // if (null != e.getFault().getDetail() // && null != e.getFault().getDetail() // .getFirstChild()) { // try { // javax.xml.transform.Source faultSource = new javax.xml.transform.dom.DOMSource( // e.getFault().getDetail() // .getFirstChild()); // // org.dom4j.io.DocumentResult result = new org.dom4j.io.DocumentResult(); // javax.xml.transform.TransformerFactory // .newInstance().newTransformer() // .transform(faultSource, result); // org.dom4j.Document faultDoc = result // .getDocument(); // // faultTalendDoc = new Document(); // faultTalendDoc.setDocument(faultDoc); // } catch (Exception e1) { // e1.printStackTrace(); // } // } // if (row4 == null) { // row4 = new row4Struct(); // } // row4.faultString = faultString; // row4.faultDetail = faultTalendDoc; // } // [TA] commented run in TOS part due to external dependencies :: end } else { try { responseDoc_tESBConsumer_1 = (org.dom4j.Document) consumer_tESBConsumer_1 .invoke(requestTalendDoc.getDocument()); } catch (Exception e) { String faultMessage = e.getMessage(); if (row4 == null) { row4 = new row4Struct(); } row4.faultString = faultMessage; row4.faultDetail = null; } } } catch (Exception e) { throw (e); } if (null != responseDoc_tESBConsumer_1) { if (row3 == null) { row3 = new row3Struct(); } Document responseTalendDoc_tESBConsumer_1 = new Document(); responseTalendDoc_tESBConsumer_1.setDocument(responseDoc_tESBConsumer_1); row3.payload = responseTalendDoc_tESBConsumer_1; } tos_count_tESBConsumer_1++; /** * [tESBConsumer_1 main ] stop */ // Start of branch "row3" if (row3 != null) { /** * [tJavaFlex_2 main ] start */ currentComponent = "tJavaFlex_2"; // here is the main part of the component, // a piece of code executed in the row // loop row5.payloadString = row3.payload.getDocument().asXML(); tos_count_tJavaFlex_2++; /** * [tJavaFlex_2 main ] stop */ /** * [tLogRow_1 main ] start */ currentComponent = "tLogRow_1"; // ///////////////////// StringBuilder strBuffer_tLogRow_1 = new StringBuilder(); strBuffer_tLogRow_1.append("[tLogRow_1] "); if (row5.payloadString != null) { // strBuffer_tLogRow_1.append(String.valueOf(row5.payloadString)); } // if (globalMap.get("tLogRow_CONSOLE") != null) { consoleOut_tLogRow_1 = (java.io.PrintStream) globalMap.get("tLogRow_CONSOLE"); } else { consoleOut_tLogRow_1 = new java.io.PrintStream( new java.io.BufferedOutputStream(System.out)); globalMap.put("tLogRow_CONSOLE", consoleOut_tLogRow_1); } consoleOut_tLogRow_1.println(strBuffer_tLogRow_1.toString()); consoleOut_tLogRow_1.flush(); nb_line_tLogRow_1++; // //// // //// // ///////////////////// tos_count_tLogRow_1++; /** * [tLogRow_1 main ] stop */ } // End of branch "row3" // Start of branch "row4" if (row4 != null) { /** * [tJavaFlex_3 main ] start */ currentComponent = "tJavaFlex_3"; row6.faultString = row4.faultString; // here is the main part of the component, // a piece of code executed in the row // loop // row6.faultString = row4.faultString; if (null != row4.faultDetail) { row6.faultDetailString = row4.faultDetail.getDocument().asXML(); } tos_count_tJavaFlex_3++; /** * [tJavaFlex_3 main ] stop */ /** * [tLogRow_2 main ] start */ currentComponent = "tLogRow_2"; // ///////////////////// StringBuilder strBuffer_tLogRow_2 = new StringBuilder(); strBuffer_tLogRow_2.append("[tLogRow_2] "); if (row6.faultString != null) { // strBuffer_tLogRow_2.append(String.valueOf(row6.faultString)); } // strBuffer_tLogRow_2.append("|"); if (row6.faultDetailString != null) { // strBuffer_tLogRow_2.append(String.valueOf(row6.faultDetailString)); } // if (globalMap.get("tLogRow_CONSOLE") != null) { consoleOut_tLogRow_2 = (java.io.PrintStream) globalMap.get("tLogRow_CONSOLE"); } else { consoleOut_tLogRow_2 = new java.io.PrintStream( new java.io.BufferedOutputStream(System.out)); globalMap.put("tLogRow_CONSOLE", consoleOut_tLogRow_2); } consoleOut_tLogRow_2.println(strBuffer_tLogRow_2.toString()); consoleOut_tLogRow_2.flush(); nb_line_tLogRow_2++; // //// // //// // ///////////////////// tos_count_tLogRow_2++; /** * [tLogRow_2 main ] stop */ } // End of branch "row4" /** * [tFixedFlowInput_1 end ] start */ currentComponent = "tFixedFlowInput_1"; } ok_Hash.put("tFixedFlowInput_1", true); end_Hash.put("tFixedFlowInput_1", System.currentTimeMillis()); /** * [tFixedFlowInput_1 end ] stop */ /** * [tJavaFlex_1 end ] start */ currentComponent = "tJavaFlex_1"; // end of the component, outside/closing the loop ok_Hash.put("tJavaFlex_1", true); end_Hash.put("tJavaFlex_1", System.currentTimeMillis()); /** * [tJavaFlex_1 end ] stop */ /** * [tESBConsumer_1 end ] start */ currentComponent = "tESBConsumer_1"; ok_Hash.put("tESBConsumer_1", true); end_Hash.put("tESBConsumer_1", System.currentTimeMillis()); /** * [tESBConsumer_1 end ] stop */ /** * [tJavaFlex_2 end ] start */ currentComponent = "tJavaFlex_2"; // end of the component, outside/closing the loop ok_Hash.put("tJavaFlex_2", true); end_Hash.put("tJavaFlex_2", System.currentTimeMillis()); /** * [tJavaFlex_2 end ] stop */ /** * [tLogRow_1 end ] start */ currentComponent = "tLogRow_1"; // //// // //// globalMap.put("tLogRow_1_NB_LINE", nb_line_tLogRow_1); // ///////////////////// ok_Hash.put("tLogRow_1", true); end_Hash.put("tLogRow_1", System.currentTimeMillis()); /** * [tLogRow_1 end ] stop */ /** * [tJavaFlex_3 end ] start */ currentComponent = "tJavaFlex_3"; // end of the component, outside/closing the loop ok_Hash.put("tJavaFlex_3", true); end_Hash.put("tJavaFlex_3", System.currentTimeMillis()); /** * [tJavaFlex_3 end ] stop */ /** * [tLogRow_2 end ] start */ currentComponent = "tLogRow_2"; // //// // //// globalMap.put("tLogRow_2_NB_LINE", nb_line_tLogRow_2); // ///////////////////// ok_Hash.put("tLogRow_2", true); end_Hash.put("tLogRow_2", System.currentTimeMillis()); /** * [tLogRow_2 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (Error error) { throw new Error(error); } globalMap.put("tFixedFlowInput_1_SUBPROCESS_STATE", 1); }
From source file:org.amanzi.asn1.parser.token.TokenAnalyzer.java
/** * Read next Token from an input stream/* w w w . j a va2s . c o m*/ * * @return */ private String readNextToken() throws IOException { if (trailingToken != null) { String toReturn = trailingToken; trailingToken = null; return toReturn; } StringBuffer token = new StringBuffer(); parsing_loop: while (true) { int read = inputStream.read(); if (read != END_OF_FILE_CHARACTER) { char readChar = (char) read; if (isPreviousCharacter) { token.append(previousCharacter); } isPreviousCharacter = false; boolean space = false; if (ArrayUtils.contains(DEFAULT_SKIP_CHARACTERS, read)) { if (token.length() == 0) { continue; } else { space = true; } } token.append(readChar); if (isBitOrOctetString) { isBitOrOctetString = false; if ((!ControlSymbol.LEFT_BRACE.getTokenText().equals(token.toString())) && (!ControlSymbol.LEFT_BRACKET.getTokenText().equals(token.toString()))) { isPreviousCharacter = true; previousCharacter = readChar; return ControlSymbol.RIGHT_BRACE.getTokenText(); } } String tokenString = token.toString(); for (ReservedWord reservedWord : ReservedWord.getPossibleTokens(readChar)) { if (reservedWord.getTokenText().startsWith(tokenString)) { continue parsing_loop; } } if (space) { String result = token.toString().trim(); if (ReservedWord.BIT_STRING.getTokenText().equals(result) || ReservedWord.OCTET_STRING.getTokenText().equals(result)) { isBitOrOctetString = true; } return result; } for (ControlSymbol singleToken : ControlSymbol.getPossibleTokens(readChar)) { if (singleToken.checkText(tokenString)) { trailingToken = singleToken.getTokenText(); String toReturn = singleToken.cut(tokenString); if (toReturn.isEmpty()) { toReturn = trailingToken; trailingToken = null; } if (singleToken == ControlSymbol.COMMENT) { skipUntilNextLine(); token.delete(0, token.length()); break; } return toReturn; } } } else { if ((token.length() > 0) || (read == END_OF_FILE_CHARACTER)) { break; } } } return token.toString(); }
From source file:Leitura.Jxr.java
public ArrayList<DadosTeste> leTxt(String classe, String path, FileInputStream reader) throws IOException { StringBuffer sbaux = new StringBuffer(); char corrente; int bloco = 0; char[] aux;/*from w w w .j av a2 s .c o m*/ boolean met = false; boolean obj = false; boolean cod = false; boolean ponto = false; boolean bClasse = false; boolean achei = false; boolean statment = false; boolean clas = false; ArrayList<String> object = new ArrayList<String>(); ArrayList<String> mChamado = new ArrayList<String>(); ArrayList<DadosTeste> dados = new ArrayList<>(); String metodoTeste = null; String classeTeste = null; String classeObj = null; String objeto = null; String auxiliar = null; DadosTeste dadosTeste = null; // System.out.println(reader.available()+"->"+classe); while (reader.available() > 0) { corrente = (char) reader.read(); if ((corrente == '\t') || (corrente == '\r')) { continue; } sbaux.append(corrente); // verifica abertura de blocos if (corrente != '=') { auxiliar = sbaux.toString(); // guarda o nome do objeto } if ((corrente == ' ') && (auxiliar.equals("do") || auxiliar.equals("if") || auxiliar.equals("else") || auxiliar.equals("for") || auxiliar.equals("while") || auxiliar.equals("switch") || auxiliar.equals("try") || auxiliar.equals("catch"))) { statment = true; } if ((corrente == '{') && (statment == false)) { bloco++; } if ((corrente == '}') && (statment == false)) { bloco--; } else if ((corrente == '}') && (statment == true)) { statment = false; } //ler os caracteres at formar uma palavra reservada do java if ((sbaux.toString().equals("public")) || (sbaux.toString().equals("protected")) || (sbaux.toString().equals("private")) || (sbaux.toString().equals("static")) || (sbaux.toString().equals("final")) || (sbaux.toString().equals("native")) || (sbaux.toString().equals("synchronized")) || (sbaux.toString().equals("abstract")) || (sbaux.toString().equals("threadsafe")) || (sbaux.toString().equals("transient"))) { met = true; // encontrei palavra reservada sbaux.delete(0, sbaux.length()); } if (sbaux.toString().equals("class ") && classeTeste == null) { met = false; clas = true; sbaux.delete(0, sbaux.length()); } if (clas == true && !auxiliar.toString().equals("class ") && corrente == ' ') { classeTeste = sbaux.toString(); clas = false; sbaux.delete(0, sbaux.length()); } //verificar se a palavra reservada eh de um mtodo if (met == true && corrente == '.') { met = false; sbaux.delete(0, sbaux.length()); } if (auxiliar.equals("new")) { met = false; } if (met == true && ((corrente == ')') || (corrente == '='))) { met = false; } if ((met == true) && ((corrente == ' ') || (corrente == '('))) { aux = sbaux.toString().toCharArray(); // verifica se eh um metoo ou declarao de varivel for (int i = 0; i < aux.length; i++) { if (aux[i] == '(') { sbaux.deleteCharAt(i); metodoTeste = sbaux.toString(); //encontrei metodo do teste sbaux.delete(0, sbaux.length()); met = false; //System.out.println("metodo ->" + metodoTeste); break; } } } if (sbaux.toString().equals(classe + " ")) { bClasse = true; } if ((corrente == '{') && (bClasse == true)) { bClasse = false; obj = false; } if ((bClasse == true) && (corrente == ' ')) { classeObj = classe; //System.out.println(classeObj); bClasse = false; obj = true; // encontrou um objeto sbaux.delete(0, sbaux.length()); } if ((corrente == '(') || (corrente == '.') || (corrente == ')')) { obj = false; // torna obj falso para no pegar a instanciao do objeto ex: Calculadora calc = new Calculadora() } if ((obj == true) && ((corrente == '=') || (corrente == ';'))) { objeto = auxiliar.replace(';', ' ').trim(); object.add(objeto); obj = false; //System.out.println(object); } // verifica os mtodos do cdigo for (int i = 0; i < object.size(); i++) { if ((sbaux.toString()).equals(object.get(i))) { cod = true; // verifica se encontrou um objeto } } if ((corrente == '.') && (cod == true)) { ponto = true; // verifica se o objeto vai chamar um metodo sbaux.delete(0, sbaux.length()); } if ((cod == true) && (ponto == true)) { if ((corrente == '(') || (corrente == ' ')) { if (sbaux.length() != 0) { sbaux.deleteCharAt(sbaux.length() - 1); for (int i = 0; i < mChamado.size(); i++) { if (mChamado.get(i).equals(sbaux.toString())) achei = true; } if (achei != true) { mChamado.add(sbaux.toString()); // metodo do codigo encontrado achei = false; } } cod = false; ponto = false; } } if (StringUtils.isNotBlank(metodoTeste) && StringUtils.isNotBlank(classeObj) && !object.isEmpty() && !mChamado.isEmpty() && (bloco % 2 != 0)) { // System.out.println("ClasseOBj: "+classeObj+" Objeto: "+object+" MChamado: "+mChamado+" Metodo Teste:"+metodoTeste+" ClasseTeste: "+classeTeste); dadosTeste = new DadosTeste(classeObj, object, mChamado, metodoTeste, classeTeste.trim()); //infJxr.put(metodoTeste + "_" + classeObj, dadosTeste); dados.add(dadosTeste); classeObj = null; object = new ArrayList<>(); mChamado = new ArrayList<>(); metodoTeste = null; objeto = null; met = false; obj = false; cod = false; ponto = false; bClasse = false; achei = false; } if ((corrente == '\n') || (corrente == ' ') || (corrente == ',') || auxiliar.equals("") || (corrente == '(')) { sbaux.delete(0, sbaux.length()); } } clas = false; classeTeste = null; return dados; }
From source file:com.wabacus.config.component.application.report.ConditionBean.java
public String getConditionExpressionAndParams(ReportRequest rrequest, List<String> lstConditions, List<IDataType> lstConditionsTypes) { if (!this.isExistConditionExpression(true)) return null;//??<condition/>??????#name#?sql????? if (this.isConstant()) return conditionExpression.getValue(); if (this.iterator < 2) { String conditionvalue = getDynamicConditionvalueForSql(rrequest, -1); if (conditionvalue.equals("")) return ""; ConditionExpressionBean cexpressionbean = getConditionRuntimeExpressionBean(rrequest, -1); return cexpressionbean.getRuntimeConditionExpressionValue(this, conditionvalue, lstConditions, lstConditionsTypes);//w w w . j a va 2 s .c om } else { String conditionvalueTmp; StringBuffer andExpressionBuf = new StringBuffer(); StringBuffer orExpressionBuf = new StringBuffer();//or?? List<String> lstAndConditions = null; List<IDataType> lstAndConditionsType = null; new ArrayList<IDataType>(); List<String> lstOrConditions = null; new ArrayList<String>(); List<IDataType> lstOrConditionsType = null; if (lstConditions != null && lstConditionsTypes != null) { lstAndConditions = new ArrayList<String>(); lstAndConditionsType = new ArrayList<IDataType>(); lstOrConditions = new ArrayList<String>(); lstOrConditionsType = new ArrayList<IDataType>(); } for (int i = 0; i < this.iterator; i++) { conditionvalueTmp = getDynamicConditionvalueForSql(rrequest, i); if (conditionvalueTmp.equals("")) continue; String innerlogicTmp = getInnerLogicValue(rrequest, i); ConditionExpressionBean cexpressionbean = getConditionRuntimeExpressionBean(rrequest, i); if (!innerlogicTmp.equalsIgnoreCase("or")) { andExpressionBuf.append(cexpressionbean.getRuntimeConditionExpressionValue(this, conditionvalueTmp, lstAndConditions, lstAndConditionsType)); andExpressionBuf.append(" and "); } else { orExpressionBuf.append(cexpressionbean.getRuntimeConditionExpressionValue(this, conditionvalueTmp, lstOrConditions, lstOrConditionsType)); orExpressionBuf.append(" or "); } } if (andExpressionBuf.toString().endsWith(" and ")) { andExpressionBuf.delete(andExpressionBuf.length() - " and ".length(), andExpressionBuf.length()); } if (orExpressionBuf.toString().endsWith(" or ")) { orExpressionBuf.delete(orExpressionBuf.length() - " or ".length(), orExpressionBuf.length()); } if (andExpressionBuf.length() == 0 && orExpressionBuf.length() == 0) return ""; if (lstConditions != null && lstConditionsTypes != null) { //and if (lstAndConditions.size() > 0) lstConditions.addAll(lstAndConditions); if (lstAndConditionsType.size() > 0) lstConditionsTypes.addAll(lstAndConditionsType); if (lstOrConditions.size() > 0) lstConditions.addAll(lstOrConditions); if (lstOrConditionsType.size() > 0) lstConditionsTypes.addAll(lstOrConditionsType); } String conditionexpression = ""; if (!andExpressionBuf.toString().trim().equals("")) { conditionexpression = "(" + andExpressionBuf.toString() + ")"; } if (!orExpressionBuf.toString().trim().equals("")) { if (conditionexpression.equals("")) { conditionexpression = "(" + orExpressionBuf.toString() + ")"; } else { conditionexpression = conditionexpression + " or (" + orExpressionBuf.toString() + ")"; } } if (!conditionexpression.trim().equals("")) conditionexpression = "(" + conditionexpression + ")"; return conditionexpression; } }
From source file:cx.fbn.nevernote.sql.NoteTable.java
public Note mapNoteFromQuery(NSqlQuery query, boolean loadContent, boolean loadResources, boolean loadRecognition, boolean loadBinary, boolean loadTags) { DateFormat indfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); // indfm = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy"); Note n = new Note(); NoteAttributes na = new NoteAttributes(); n.setAttributes(na);/* w ww .j av a 2s. c o m*/ n.setGuid(query.valueString(0)); n.setUpdateSequenceNum(new Integer(query.valueString(1))); n.setTitle(query.valueString(2)); try { n.setCreated(indfm.parse(query.valueString(3)).getTime()); n.setUpdated(indfm.parse(query.valueString(4)).getTime()); n.setDeleted(indfm.parse(query.valueString(5)).getTime()); } catch (ParseException e) { e.printStackTrace(); } n.setActive(query.valueBoolean(6, true)); n.setNotebookGuid(query.valueString(7)); try { String attributeSubjectDate = query.valueString(8); if (!attributeSubjectDate.equals("")) na.setSubjectDate(indfm.parse(attributeSubjectDate).getTime()); } catch (ParseException e) { e.printStackTrace(); } na.setLatitude(new Float(query.valueString(9))); na.setLongitude(new Float(query.valueString(10))); na.setAltitude(new Float(query.valueString(11))); na.setAuthor(query.valueString(12)); na.setSource(query.valueString(13)); na.setSourceURL(query.valueString(14)); na.setSourceApplication(query.valueString(15)); na.setContentClass(query.valueString(16)); if (loadTags) { List<String> tagGuids = noteTagsTable.getNoteTags(n.getGuid()); List<String> tagNames = new ArrayList<String>(); TagTable tagTable = db.getTagTable(); for (int i = 0; i < tagGuids.size(); i++) { String currentGuid = tagGuids.get(i); Tag tag = tagTable.getTag(currentGuid); if (tag.getName() != null) tagNames.add(tag.getName()); else tagNames.add(""); } n.setTagNames(tagNames); n.setTagGuids(tagGuids); } if (loadContent) { QTextCodec codec = QTextCodec.codecForLocale(); codec = QTextCodec.codecForName("UTF-8"); String unicode = codec.fromUnicode(query.valueString(17)).toString(); // This is a hack. Basically I need to convert HTML Entities to "normal" text, but if I // convert the < character to < it will mess up the XML parsing. So, to get around this // I am "bit stuffing" the < to &< so StringEscapeUtils doesn't unescape it. After // I'm done I convert it back. StringBuffer buffer = new StringBuffer(unicode); if (Global.enableHTMLEntitiesFix && unicode.indexOf("&#") > 0) { unicode = query.valueString(17); //System.out.println(unicode); //unicode = unicode.replace("<", "&_lt;"); //unicode = codec.fromUnicode(StringEscapeUtils.unescapeHtml(unicode)).toString(); //unicode = unicode.replace("&_lt;", "<"); //System.out.println("************************"); int j = 1; for (int i = buffer.indexOf("&#"); i != -1 && buffer.indexOf("&#", i) > 0; i = buffer.indexOf("&#", i + 1)) { j = buffer.indexOf(";", i) + 1; if (i < j) { String entity = buffer.substring(i, j).toString(); int len = entity.length() - 1; String tempEntity = entity.substring(2, len); try { Integer.parseInt(tempEntity); entity = codec.fromUnicode(StringEscapeUtils.unescapeHtml4(entity)).toString(); buffer.delete(i, j); buffer.insert(i, entity); } catch (Exception e) { } } } } n.setContent(unicode); // n.setContent(query.valueString(16).toString()); String contentHash = query.valueString(18); if (contentHash != null) n.setContentHash(contentHash.getBytes()); n.setContentLength(new Integer(query.valueString(19))); } if (loadResources) n.setResources(noteResourceTable.getNoteResources(n.getGuid(), loadBinary)); if (loadRecognition) { if (n.getResources() == null) { List<Resource> resources = noteResourceTable.getNoteResourcesRecognition(n.getGuid()); n.setResources(resources); } else { // We need to merge the recognition resources with the note resources retrieved earlier for (int i = 0; i < n.getResources().size(); i++) { Resource r = noteResourceTable.getNoteResourceRecognition(n.getResources().get(i).getGuid()); n.getResources().get(i).setRecognition(r.getRecognition()); } } } n.setContent(fixCarriageReturn(n.getContent())); return n; }