List of usage examples for org.apache.commons.lang StringUtils endsWithIgnoreCase
public static boolean endsWithIgnoreCase(String str, String suffix)
Case insensitive check if a String ends with a specified suffix.
From source file:adalid.util.velocity.SecondBaseBuilder.java
private void createTextFilePropertiesFile(String source, String target) { boolean java = StringUtils.endsWithIgnoreCase(source, ".java"); boolean bundle = StringUtils.endsWithIgnoreCase(source, ".properties"); File sourceFile = new File(source); String sourceFileName = sourceFile.getName(); String sourceFileSimpleName = StringUtils.substringBeforeLast(sourceFileName, "."); String sourceFolderName = sourceFile.getParentFile().getName(); String sourceFolderSimpleName = StringUtils.substringBeforeLast(sourceFolderName, "."); String sourceEntityName = getOptionalEntityName(sourceFileSimpleName, sourceFolderSimpleName); String properties = source.replace(projectFolderPath, velocityPlatformsTargetFolderPath) + ".properties"; String folder = StringUtils.substringBeforeLast(properties, FS); String template = StringUtils.substringAfter(target, velocityFolderPath + FS).replace(FS, "/"); String path = StringUtils.substringBeforeLast(StringUtils.substringAfter(source, projectFolderPath), FS) .replace(FS, "/").replace(project, PROJECT_ALIAS).replace("eclipse.settings", ".settings"); path = replaceAliasWithRootFolderName(path); String pack = null;/*from ww w. j a va 2 s . c o m*/ if (java || bundle) { String s1 = StringUtils.substringAfter(path, SRC); if (StringUtils.contains(s1, PROJECT_ALIAS)) { String s2 = StringUtils.substringBefore(s1, PROJECT_ALIAS); String s3 = SRC + s2; String s4 = StringUtils.substringBefore(path, s3) + s3; String s5 = StringUtils.substringAfter(s1, PROJECT_ALIAS).replace("/", "."); path = StringUtils.removeEnd(s4, "/"); pack = ROOT_PACKAGE_NAME + s5; } } path = finalisePath(path); String file = StringUtils.substringAfterLast(source, FS).replace(project, PROJECT_ALIAS) .replace("eclipse.project", ".project"); List<String> lines = new ArrayList<>(); lines.add("template = " + template); // lines.add("template-type = velocity"); lines.add("path = " + path); if (StringUtils.isNotBlank(pack)) { lines.add("package = " + pack); } lines.add("file = " + file); if (sourceFileSimpleName.equals("eclipse") || sourceFolderSimpleName.equals("eclipse") || sourceFolderSimpleName.equals("nbproject")) { lines.add("disabled = true"); } else if (sourceEntityName != null) { lines.add("disabled-when-missing = " + sourceEntityName); } if (preservable(sourceFile)) { lines.add("preserve = true"); } lines.add("dollar.string = $"); lines.add("pound.string = #"); lines.add("backslash.string = \\\\"); FilUtils.mkdirs(folder); if (write(properties, lines, WINDOWS_CHARSET)) { propertiesFilesCreated++; } }
From source file:edu.monash.merc.system.parser.xml.HPAWSXmlParser.java
public List<HPAEntryBean> parseHPAXml(String fileName, XMLInputFactory2 factory2) { xmlif2 = factory2;//from w w w.ja v a 2s .c o m logger.info("Starting to parse " + fileName); List<HPAEntryBean> hpaEntryBeans = new ArrayList<HPAEntryBean>(); XMLEventReader2 xmlEventReader = null; try { xmlEventReader = (XMLEventReader2) xmlif2.createXMLEventReader(new FileInputStream(fileName)); QName entryQN = new QName(ELE_ENTRY); QName versionQN = new QName(ATTR_VERSION); QName urlQN = new QName(ATTR_URL); QName nameQN = new QName(ELE_NAME); QName identiferQN = new QName(ELE_IDENTIFIER); QName idQN = new QName(ATTR_ID); QName xrefQN = new QName(ELE_XREF); QName dbQN = new QName(ATTR_DB); QName tissueExpQN = new QName(ELE_TISSUE_EXPRESSION); QName typeQN = new QName(ATTR_TYPE); QName verificationQN = new QName(ELE_VERIFICATION); QName dataQN = new QName(ELE_DATA); QName tissueQN = new QName(ELE_TISSUE); QName statusQN = new QName(ATTR_STATUS); QName cellTypeQN = new QName(ELE_CELLTYPE); QName levelQN = new QName(ELE_LEVEL); QName antibodyQN = new QName(ELE_ANTIBODY); String version = null; String url = null; String geneName = null; String geneAccession = null; String dbNameForIdentifier = null; String xrefAc = null; String xrefDb = null; boolean tissueExpressionPresent = false; boolean antibodyPresent = false; String tissueStatus = null; String tissue = null; String cellType = null; String levelType = null; String level = null; String verificationType = null; String verification = null; HPAEntryBean hpaEntryBean = null; GeneBean geneBean = null; List<DbSourceAcEntryBean> dbSourceAcEntryBeans = new ArrayList<DbSourceAcEntryBean>(); List<PEEvidenceBean> peAntiIHCNormEvidenceBeans = new ArrayList<PEEvidenceBean>(); PEEvidenceBean antiIHCNormEvidenceBean = null; AccessionBean identifiedAcBean = null; while (xmlEventReader.hasNextEvent()) { //eventType = reader.next(); XMLEvent event = xmlEventReader.nextEvent(); if (event.isStartElement()) { StartElement element = event.asStartElement(); //hpa entry if (element.getName().equals(entryQN)) { //start to create a hpaEntryBean hpaEntryBean = new HPAEntryBean(); //create a GeneBean geneBean = new GeneBean(); //create a list of DbSourceAcEntryBean to store all DbSource and Ac dbSourceAcEntryBeans = new ArrayList<DbSourceAcEntryBean>(); //create a list of PEEvidenceBean to store all antibody evidencs for the current gene peAntiIHCNormEvidenceBeans = new ArrayList<PEEvidenceBean>(); //get the version attribute Attribute versionAttr = element.getAttributeByName(versionQN); if (versionAttr != null) { version = versionAttr.getValue(); } //get the url attribute Attribute urlAttr = element.getAttributeByName(urlQN); if (urlAttr != null) { url = urlAttr.getValue(); } } //parse the gene name in the name element if (element.getName().equals(nameQN)) { if (xmlEventReader.peek().isCharacters()) { event = xmlEventReader.nextEvent(); Characters geneCharacters = event.asCharacters(); if (geneCharacters != null) { geneName = geneCharacters.getData(); } } } //parse the ensg accession and db in the identifier element if (element.getName().equals(identiferQN)) { Attribute idAttr = element.getAttributeByName(idQN); if (idAttr != null) { geneAccession = idAttr.getValue(); } Attribute dbAttr = element.getAttributeByName(dbQN); if (dbAttr != null) { dbNameForIdentifier = dbAttr.getValue(); } } //parse all db and accession pair in xref element if (element.getName().equals(xrefQN)) { Attribute idAttr = element.getAttributeByName(idQN); if (idAttr != null) { xrefAc = idAttr.getValue(); } Attribute dbAttr = element.getAttributeByName(dbQN); if (dbAttr != null) { xrefDb = dbAttr.getValue(); } } //parse tissueExpression if (element.getName().equals(tissueExpQN)) { //we only focus on the tissueExpression element in the path /entry/tissueExpression if (!antibodyPresent) { //set the tissueExpression present flag into true; tissueExpressionPresent = true; //create a list of PEEvidenceBean to store the PEEvidence for antibody peAntiIHCNormEvidenceBeans = new ArrayList<PEEvidenceBean>(); } } //parse the verification element to get reliability or validation value if (element.getName().equals(verificationQN)) { //we only focus on the verification element in the path /entry/tissueExpression/verification if (!antibodyPresent && tissueExpressionPresent) { Attribute verifAttr = element.getAttributeByName(typeQN); if (verifAttr != null) { verificationType = element.getAttributeByName(typeQN).getValue(); } if (xmlEventReader.peek().isCharacters()) { event = xmlEventReader.nextEvent(); verification = event.asCharacters().getData(); } } } //start of the data element if (element.getName().equals(dataQN)) { //we only focus on the data element in the path /entry/tissueExpression/data if (!antibodyPresent && tissueExpressionPresent) { antiIHCNormEvidenceBean = new PEEvidenceBean(); TPBDataTypeBean dataTypeBean = createTPBDataTypeBeanForPEANTIIHCNORM(); antiIHCNormEvidenceBean.setTpbDataTypeBean(dataTypeBean); } } //start of tissue if (element.getName().equals(tissueQN)) { //we only focus on the tissue element in the path /entry/tissueExpression/data/tissue if (!antibodyPresent && tissueExpressionPresent) { Attribute tissueStatusAttr = element.getAttributeByName(statusQN); if (tissueStatusAttr != null) { tissueStatus = tissueStatusAttr.getValue(); } if (xmlEventReader.peek().isCharacters()) { event = xmlEventReader.nextEvent(); tissue = event.asCharacters().getData(); } } } //start of cellType if (element.getName().equals(cellTypeQN)) { //we only focus on the cellType element in the path /entry/tissueExpression/data/cellType if (!antibodyPresent && tissueExpressionPresent) { if (xmlEventReader.peek().isCharacters()) { event = xmlEventReader.nextEvent(); cellType = event.asCharacters().getData(); } } } //start of level if (element.getName().equals(levelQN)) { //we only focus on the level element in the path /entry/tissueExpression/data/level if (!antibodyPresent && tissueExpressionPresent) { Attribute typeAttr = element.getAttributeByName(typeQN); if (typeAttr != null) { levelType = typeAttr.getValue(); } if (xmlEventReader.peek().isCharacters()) { event = xmlEventReader.nextEvent(); level = event.asCharacters().getData(); } } } //start of antibody element if (element.getName().equals(antibodyQN)) { //we have to setup antibodyPresent flag as true antibodyPresent = true; } } //End of element if (event.isEndElement()) { EndElement endElement = event.asEndElement(); //hpa entry end if (endElement.getName().equals(entryQN)) { //set hpa version hpaEntryBean.setHpaVersion(version); //hpaEntryBean set gene bean hpaEntryBean.setGeneBean(geneBean); //create the primary dbsource bean DBSourceBean primaryDbSourceBean = createPrimaryDBSourceBeanForHPA(); //set the primary DBSourceBean hpaEntryBean.setPrimaryDbSourceBean(primaryDbSourceBean); //set the identified accesion bean hpaEntryBean.setIdentifiedAccessionBean(identifiedAcBean); //set DbSourceAcEntryBean list hpaEntryBean.setDbSourceAcEntryBeans(dbSourceAcEntryBeans); //set all the PeAntiIHCBody evidences if (peAntiIHCNormEvidenceBeans.size() == 0) { peAntiIHCNormEvidenceBeans.add(createNonePEEvidence(url)); } hpaEntryBean.setPeAntiIHCNormEvidencesBeans(peAntiIHCNormEvidenceBeans); //add the current hpa entry bean into list hpaEntryBeans.add(hpaEntryBean); //reset version and url version = null; url = null; identifiedAcBean = null; } //end of gene name, populate the gene name if (endElement.getName().equals(nameQN)) { //set gene name geneBean.setDisplayName(geneName); } //end of identifier, populating for gene accession, db and accessions if any if (endElement.getName().equals(identiferQN)) { //set the gene accession geneBean.setEnsgAccession(geneAccession); identifiedAcBean = createIdentifiedAcBean(geneAccession, dbNameForIdentifier); //create a DbSourceAcEntryBean based on the identifier element DbSourceAcEntryBean dbSourceAcEntryBean = createDbSourceAcEntry(dbNameForIdentifier, geneAccession); //add this DbSourceAcEntryBean into list dbSourceAcEntryBeans.add(dbSourceAcEntryBean); } //end of xref element. populate for db and accessions if any if (endElement.getName().equals(xrefQN)) { //create a DbSourceAcEntryBean based on the xref element DbSourceAcEntryBean dbSourceAcEntryBean = createDbSourceAcEntry(xrefDb, xrefAc); //add this DbSoureAcEntryBean into list dbSourceAcEntryBeans.add(dbSourceAcEntryBean); //set rest of db and accession values xrefDb = null; xrefAc = null; } //end of the tissueExpression if (endElement.getName().equals(tissueExpQN)) { //we only focus on the tissueExpression element in the path /entry/tissueExpression if (!antibodyPresent) { //the tissueExpression is end. we have to reset tissueExpressionPresent, //verificationType and verification values under the tissueExpression element level //reset tissueExpression present flag into false tissueExpressionPresent = false; //reset verification type verificationType = null; //reset verification value verification = null; } } //end of data element if (endElement.getName().equals(dataQN)) { //we only focus on the data element in the path /entry/tissueExpression/data if (!antibodyPresent && tissueExpressionPresent) { //we only consider the tissue status is normal one if (StringUtils.endsWithIgnoreCase(tissueStatus, TISSUE_STATUS_NORMAL)) { setAntiEvidence(antiIHCNormEvidenceBean, url, verification, tissue, cellType, level, levelType); //add anti evidence peAntiIHCNormEvidenceBeans.add(antiIHCNormEvidenceBean); } //the data element is end. we have to reset the tissueStatus, tissue, cellType and level values under the data element level tissueStatus = null; tissue = null; cellType = null; level = null; levelType = null; } } //end of antibody if (endElement.getName().equals(antibodyQN)) { //we have to reset antibodyPresent flag as false antibodyPresent = false; } } //End of XML document if (event.isEndDocument()) { // finished to parse the whole document; break; } } } catch (Exception ex) { logger.error(ex); throw new DMXMLParserException(ex); } finally { if (xmlEventReader != null) { try { xmlEventReader.close(); } catch (Exception e) { //ignore whatever caught. } } } return hpaEntryBeans; }
From source file:com.taobao.android.builder.tools.classinject.CodeInjectByJavassist.java
/** * jar?/* w w w. j a v a 2 s. c o m*/ * * @param inJar * @param outJar * @throws IOException * @throws NotFoundException * @throws CannotCompileException */ public static List<String> inject(ClassPool pool, File inJar, File outJar, InjectParam injectParam) throws Exception { List<String> errorFiles = new ArrayList<String>(); JarFile jarFile = newJarFile(inJar); outJar.getParentFile().mkdirs(); FileOutputStream fileOutputStream = new FileOutputStream(outJar); JarOutputStream jos = new JarOutputStream(new BufferedOutputStream(fileOutputStream)); Enumeration<JarEntry> jarFileEntries = jarFile.entries(); JarEntry jarEntry = null; while (jarFileEntries.hasMoreElements()) { jarEntry = jarFileEntries.nextElement(); String name = jarEntry.getName(); String className = StringUtils.replace(name, File.separator, "/"); className = StringUtils.replace(className, "/", "."); className = StringUtils.substring(className, 0, className.length() - 6); if (!StringUtils.endsWithIgnoreCase(name, ".class")) { InputStream inputStream = jarFile.getInputStream(jarEntry); copyStreamToJar(inputStream, jos, name, jarEntry.getTime(), jarEntry); IOUtils.closeQuietly(inputStream); } else { byte[] codes; codes = inject(pool, className, injectParam); InputStream classInstream = new ByteArrayInputStream(codes); copyStreamToJar(classInstream, jos, name, jarEntry.getTime(), jarEntry); } } jarFile.close(); IOUtils.closeQuietly(jos); return errorFiles; }
From source file:adalid.util.meta.sql.MetaPlatformSql.java
/** * Adds .string, .class, .instance, .programmer and .wrapper properties to the velocity context * *//* w ww . j a v a 2 s . c o m*/ @SuppressWarnings("unchecked") // unchecked cast private void putProperties(VelocityContext context, File propertiesFile) { String hint = HINT + "check property \"{0}\" at file \"{1}\""; String pattern1 = "failed to load {2}" + hint; String pattern2 = "failed to initialise {2}" + hint; String pattern3 = "{2} does not implement {3}" + hint; String pattern4 = "{2} is not a valid wrapper for {3}" + hint; String string1; String string2; String message; String argument; Object object2; Class<?> clazz1; Class<?> clazz2; Class<? extends Wrapper> wrapperClass; Class<? extends Wrappable> wrappableClass; Class<?> parameterType; String velocityKey; Properties properties = PropertiesHandler.loadProperties(propertiesFile); Set<String> stringPropertyNames = properties.stringPropertyNames(); for (String name : stringPropertyNames) { checkPropertyName(name, propertiesFile); if (StringUtils.endsWithIgnoreCase(name, DOT_STRING)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_STRING); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, string2); } else if (StringUtils.endsWithIgnoreCase(name, DOT_CLASS)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_CLASS); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern1, name, propertiesFile, string2); object2 = getClassForName(string2, message); if (object2 != null) { velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, object2); continue; } throw new RuntimeException(message, new IllegalArgumentException(string2)); } } }
From source file:com.sfs.whichdoctor.isb.publisher.PersonIsbXmlWriter.java
/** * Builds the membership role map.//from w ww . j av a 2 s .c o m * * @param person the person * @return the map */ private Map<String, String> buildMembershipRoleMap(final PersonBean person) { Map<String, String> roleMap = new HashMap<String, String>(); Collection<MembershipBean> memberships = new ArrayList<MembershipBean>(); if (person != null && person.getMembershipDetails() != null) { memberships = person.getMembershipDetails(); } String prefix = ""; for (MembershipBean role : memberships) { final String roleClass = role.getMembershipClass(); final String roleType = role.getMembershipType(); StringBuffer roleDN = new StringBuffer(); if (StringUtils.equalsIgnoreCase(roleClass, "RACP") && StringUtils.isBlank(roleType)) { // The default membership type ObjectTypeBean div = role.getObjectTypeField("Division"); ObjectTypeBean type = role.getObjectTypeField("Membership Type"); if (type != null && StringUtils.isNotBlank(type.getLdapMapping(1))) { roleDN.append(type.getLdapMapping(1)); } if (div != null && StringUtils.isNotBlank(div.getLdapMapping(1))) { prefix = div.getLdapMapping(1); } if (StringUtils.isNotBlank(roleDN.toString()) && StringUtils.isNotBlank(prefix)) { roleDN.insert(0, ","); roleDN.insert(0, prefix); } } if (StringUtils.equalsIgnoreCase(roleClass, "RACP") && StringUtils.endsWithIgnoreCase(roleType, "Affiliation")) { ObjectTypeBean type = role.getObjectTypeField("Affiliation"); if (type != null && StringUtils.isNotBlank(type.getLdapMapping(1))) { roleDN.append(type.getLdapMapping(1)); } } if (StringUtils.isNotBlank(roleDN.toString())) { roleMap.put(String.valueOf(role.getGUID()), roleDN.toString().trim()); } } // Process the training status to see if it has a mapping if (person != null && StringUtils.isNotBlank(person.getTrainingStatusMapping())) { StringBuffer roleDN = new StringBuffer(); roleDN.append(person.getTrainingStatusMapping()); if (StringUtils.isNotBlank(prefix)) { roleDN.insert(0, ","); roleDN.insert(0, prefix); } roleMap.put(String.valueOf(person.getGUID()), roleDN.toString().trim()); } return roleMap; }
From source file:adalid.commons.velocity.Writer.java
/** * Adds .string, .class, .instance, .programmer and .wrapper properties to the velocity context * *//*w w w . j a va 2 s.co m*/ @SuppressWarnings("unchecked") // unchecked cast private void putProperties(VelocityContext context, File propertiesFile) { String hint = HINT + "check property \"{0}\" at file \"{1}\""; String pattern1 = "failed to load {2}" + hint; String pattern2 = "failed to initialise {2}" + hint; String pattern3 = "{2} does not implement {3}" + hint; String pattern4 = "{2} is not a valid wrapper for {3}" + hint; String string1; String string2; String message; String argument; // Object object1; Object object2; Class<?> clazz1; Class<?> clazz2; Class<? extends Wrapper> wrapperClass; Class<? extends Wrappable> wrappableClass; Class<?> parameterType; String velocityKey; Properties properties = PropertiesHandler.loadProperties(propertiesFile); Set<String> stringPropertyNames = properties.stringPropertyNames(); for (String name : stringPropertyNames) { checkPropertyName(name, propertiesFile); if (StringUtils.endsWithIgnoreCase(name, DOT_STRING)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_STRING); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, string2); } else if (StringUtils.endsWithIgnoreCase(name, DOT_CLASS)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_CLASS); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern1, name, propertiesFile, string2); object2 = getClassForName(string2, message); if (object2 != null) { velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, object2); continue; } throw new RuntimeException(message, new IllegalArgumentException(string2)); } else if (StringUtils.endsWithIgnoreCase(name, DOT_INSTANCE)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_INSTANCE); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern2, name, propertiesFile, string2); object2 = getNewInstanceForName(string2, message); if (object2 != null) { velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, object2); continue; } throw new RuntimeException(message, new IllegalArgumentException(string2)); } else if (StringUtils.endsWithIgnoreCase(name, DOT_PROGRAMMER)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_PROGRAMMER); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern2, name, propertiesFile, string2); object2 = getNewInstanceForName(string2, message); if (object2 != null) { if (object2 instanceof Programmer) { velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, object2); TLB.setProgrammer(velocityKey, (Programmer) object2); continue; } else { message = MessageFormat.format(pattern3, name, propertiesFile, string2, Programmer.class); } } throw new RuntimeException(message, new IllegalArgumentException(string2)); } else if (StringUtils.endsWithIgnoreCase(name, DOT_WRAPPER)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_WRAPPER); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); message = MessageFormat.format(pattern1, name, propertiesFile, string1); argument = string1; clazz1 = getClassForName(string1, message); if (clazz1 != null) { if (Wrappable.class.isAssignableFrom(clazz1)) { message = MessageFormat.format(pattern1, name, propertiesFile, string2); argument = string2; clazz2 = getClassForName(string2, message); if (clazz2 != null) { if (Wrapper.class.isAssignableFrom(clazz2)) { wrapperClass = (Class<? extends Wrapper>) clazz2; // unchecked cast wrappableClass = (Class<? extends Wrappable>) clazz1; // unchecked cast parameterType = getConstructorParameterType(wrapperClass, wrappableClass); if (parameterType != null) { TLB.setWrapperClass(wrappableClass, wrapperClass); continue; } else { message = MessageFormat.format(pattern4, name, propertiesFile, wrapperClass, wrappableClass); } } else { message = MessageFormat.format(pattern3, name, propertiesFile, string2, Wrapper.class); } } } else { message = MessageFormat.format(pattern3, name, propertiesFile, string1, Wrappable.class); } } throw new RuntimeException(message, new IllegalArgumentException(argument)); } } }
From source file:com.gemstone.gemfire.management.internal.cli.GfshParser.java
/** * *///from w w w . j a va 2 s . com public ParseResult parse(String userInput) { GfshParseResult parseResult = null; // First remove the trailing white spaces userInput = StringUtils.stripEnd(userInput, null); if ((ParserUtils.contains(userInput, SyntaxConstants.COMMAND_DELIMITER) && StringUtils.endsWithIgnoreCase(userInput, SyntaxConstants.COMMAND_DELIMITER))) { userInput = StringUtils.removeEnd(userInput, SyntaxConstants.COMMAND_DELIMITER); } try { boolean error = false; CliCommandOptionException coe = null; List<CommandTarget> targets = locateTargets(ParserUtils.trimBeginning(userInput), false); if (targets.size() > 1) { if (userInput.length() > 0) { handleCondition(CliStrings.format( CliStrings.GFSHPARSER__MSG__AMBIGIOUS_COMMAND_0_FOR_ASSISTANCE_USE_1_OR_HINT_HELP, new Object[] { userInput, AbstractShell.completionKeys }), CommandProcessingException.COMMAND_NAME_AMBIGUOUS, userInput); } } else { if (targets.size() == 1) { OptionSet parse = null; List<MethodParameter> parameters = new ArrayList<MethodParameter>(); Map<String, String> paramValMap = new HashMap<String, String>(); CommandTarget commandTarget = targets.get(0); GfshMethodTarget gfshMethodTarget = commandTarget.getGfshMethodTarget(); preConfigureConverters(commandTarget); try { parse = commandTarget.getOptionParser().parse(gfshMethodTarget.getRemainingBuffer()); } catch (CliException ce) { if (ce instanceof CliCommandOptionException) { coe = (CliCommandOptionException) ce; coe.setCommandTarget(commandTarget); parse = coe.getOptionSet(); error = true; } } try { checkOptionSetForValidCommandModes(parse, commandTarget); } catch (CliCommandMultiModeOptionException ce) { error = true; coe = ce; } error = processArguments(parse, commandTarget, paramValMap, parameters, error); error = processOptions(parse, commandTarget, paramValMap, parameters, error); if (!error) { Object[] methodParameters = new Object[parameters.size()]; for (MethodParameter parameter : parameters) { methodParameters[parameter.getParameterNo()] = parameter.getParameter(); } parseResult = new GfshParseResult(gfshMethodTarget.getMethod(), gfshMethodTarget.getTarget(), methodParameters, userInput, commandTarget.getCommandName(), paramValMap); } else { if (coe != null) { logWrapper.fine("Handling exception: " + coe.getMessage()); ExceptionHandler.handleException(coe); // ExceptionHandler.handleException() only logs it on console. // When on member, we need to handle this. if (!CliUtil.isGfshVM()) { handleCondition( CliStrings.format(CliStrings.GFSHPARSER__MSG__INVALID_COMMAND_STRING_0, userInput), coe, CommandProcessingException.COMMAND_INVALID, userInput); } } } } else { String message = CliStrings.format(CliStrings.GFSHPARSER__MSG__COMMAND_0_IS_NOT_VALID, userInput); CommandTarget commandTarget = locateExactMatchingTarget(userInput); if (commandTarget != null) { String commandName = commandTarget.getCommandName(); AvailabilityTarget availabilityIndicator = commandTarget.getAvailabilityIndicator(); message = CliStrings.format(CliStrings.GFSHPARSER__MSG__0_IS_NOT_AVAILABLE_REASON_1, new Object[] { commandName, availabilityIndicator.getAvailabilityDescription() }); } handleCondition(message, CommandProcessingException.COMMAND_INVALID_OR_UNAVAILABLE, userInput); } } } catch (IllegalArgumentException e1) { logWrapper.warning(CliUtil.stackTraceAsString(e1)); } catch (IllegalAccessException e1) { logWrapper.warning(CliUtil.stackTraceAsString(e1)); } catch (InvocationTargetException e1) { logWrapper.warning(CliUtil.stackTraceAsString(e1)); } return parseResult; }
From source file:adalid.commons.velocity.Writer.java
private void putStrings(VelocityContext context, Properties properties) { String string1;/* ww w . j a v a2 s. c o m*/ String string2; String velocityKey; Set<String> stringPropertyNames = properties.stringPropertyNames(); for (String name : stringPropertyNames) { if (StringUtils.endsWithIgnoreCase(name, DOT_STRING)) { string1 = StringUtils.removeEndIgnoreCase(name, DOT_STRING); string2 = StringUtils.trimToEmpty(properties.getProperty(name)); velocityKey = StrUtils.getCamelCase(string1, true); context.put(velocityKey, string2); } } }
From source file:hydrograph.ui.parametergrid.dialog.MultiParameterFileDialog.java
private boolean importParamterFileToProject(String[] listOfFilesToBeImported, String source, String destination, ParamterFileTypes paramterFileTypes) { for (String fileName : listOfFilesToBeImported) { String absoluteFileName = source + fileName; IPath destinationIPath = new Path(destination); destinationIPath = destinationIPath.append(fileName); File destinationFile = destinationIPath.toFile(); try {/*from w ww . ja v a 2s . co m*/ if (!ifDuplicate(listOfFilesToBeImported, paramterFileTypes)) { if (StringUtils.equalsIgnoreCase(absoluteFileName, destinationFile.toString())) { return true; } else if (destinationFile.exists()) { int returnCode = doUserConfirmsToOverRide(); if (returnCode == SWT.YES) { FileUtils.copyFileToDirectory(new File(absoluteFileName), new File(destination)); } else if (returnCode == SWT.NO) { return true; } else { return false; } } else { FileUtils.copyFileToDirectory(new File(absoluteFileName), new File(destination)); } } } catch (IOException e1) { if (StringUtils.endsWithIgnoreCase(e1.getMessage(), ErrorMessages.IO_EXCEPTION_MESSAGE_FOR_SAME_FILE)) { return true; } MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK); messageBox.setText(MessageType.ERROR.messageType()); messageBox.setMessage(ErrorMessages.UNABLE_TO_POPULATE_PARAM_FILE + " " + e1.getMessage()); messageBox.open(); logger.error("Unable to copy prameter file in current project work space"); return false; } } return true; }
From source file:adalid.core.programmers.AbstractSqlProgrammer.java
private boolean isCase(String string) { if (StringUtils.isBlank(string)) { return false; }/* www .j a v a 2s . c o m*/ String case$ = getCase() + SPC$; String end$ = SPC$ + getEnd(); String s = StringUtils.trimToEmpty(string); return StringUtils.startsWithIgnoreCase(s, case$) && StringUtils.endsWithIgnoreCase(s, end$); }