List of usage examples for org.apache.commons.lang StringUtils substring
public static String substring(String str, int start, int end)
Gets a substring from the specified String avoiding exceptions.
From source file:com.inktomi.wxmetar.MetarParser.java
static boolean parsePresentWeather(String token, final Metar metar) { boolean rval = Boolean.FALSE; String qualifier = null;/*from w w w . j av a 2s .co m*/ String weather = token.replace("+", "").replace("-", ""); // Strip off the qualifier if the length == 4 if (weather.length() == 4) { qualifier = StringUtils.substring(weather, 0, 2); weather = StringUtils.substring(weather, 2, 4); } // Strip off any possible modifier, and try to find a match PresentWeather presentWeather = null; try { presentWeather = PresentWeather.valueOf(weather); } catch (IllegalArgumentException e) { return rval; } if (null != presentWeather) { // Check for a modifier presentWeather.setIntensity(PresentWeather.Intensity.MODERATE); if (StringUtils.startsWith(token, "+")) { presentWeather.setIntensity(PresentWeather.Intensity.HEAVY); } if (StringUtils.startsWith(token, "-")) { presentWeather.setIntensity(PresentWeather.Intensity.LIGHT); } if (null != qualifier) { presentWeather.setQualifier(PresentWeather.Qualifier.valueOf(qualifier)); } metar.presentWeather = presentWeather; rval = Boolean.TRUE; } return rval; }
From source file:com.ge.research.semtk.edc.client.ResultsClient.java
/** * Store Table. fullResult is csv. sample is shorter csv. * @param contents//from w w w . j av a2 s.com * @throws Exception */ @SuppressWarnings("unchecked") public void execStoreTableResults(String jobId, Table table) throws ConnectException, EndpointNotFoundException, Exception { // chunk up the table by size and then send all the chunks. // hopefully, this will avoid sending anything too large to the results service int tableRowsDone = 0; int totalRows = table.getNumRows(); int segment = 0; long startTime = 0, endTime = 0; double prepSec = 0.0; double sendSec = 0.0; boolean timerFlag = false; Thread thread = null; if (totalRows == 0) { // just create and send the header row. StringBuilder resultsSoFar = new StringBuilder(); for (int i1 = 0; i1 < table.getNumColumns(); i1 += 1) { resultsSoFar.append((table.getColumnNames())[i1]); if (i1 < table.getNumColumns() - 1) { resultsSoFar.append(","); } } resultsSoFar.append("\n"); conf.setServiceEndpoint("results/storeIncrementalCsvResults"); this.parametersJSON.put("contents", resultsSoFar.toString()); this.parametersJSON.put("jobId", jobId); this.parametersJSON.put("segmentNumber", segment); thread = new Thread(this); thread.run(); } else { // write out all the results, y'know? while (tableRowsDone < totalRows) { if (timerFlag) { startTime = System.nanoTime(); } int tableRowsAtStart = tableRowsDone; // get the next few rows. StringBuilder resultsSoFar = new StringBuilder(); //String lastResults = ""; // get the next allocation of rows. for (int i = 0; i < this.ROWS_TO_PROCESS; i += 1) { try { // Make sure we include a header row. if (tableRowsDone == 0) { // first record... for (int i1 = 0; i1 < table.getNumColumns(); i1 += 1) { resultsSoFar.append((table.getColumnNames())[i1]); if (i1 < table.getNumColumns() - 1) { resultsSoFar.append(","); } } } // get the next row into a comma separated string. String curr = new StringBuilder(table.getRow(tableRowsDone).toString()).toString(); // ArrayList.toString() is fast // but if any element contained commas, then can't use ArrayList.toString() if (StringUtils.countMatches(curr, ",") != (table.getNumColumns() - 1)) { // escape double quotes (using "" for csv files), then enclose each element in double quotes curr = table .getRow(tableRowsDone).stream().map(s -> (new StringBuilder()).append("\"") .append(s.replace("\"", "\"\"")).append("\"").toString()) .collect(Collectors.joining(",")); } else { // ArrayList.toString() added surrounding brackets and spaces after each comma - remove these curr = StringUtils.substring(curr, 1, curr.length() - 1); curr = StringUtils.replace(curr, ", ", ","); } tableRowsDone += 1; // add to the existing results we want to send. //lastResults = resultsSoFar.toString(); // PEC changed resultsSoFar.append("\n"); resultsSoFar.append(curr); // TODO when this was using +=, it would have triggered the batch-too-big behavior, but now that it's a StringBuilder, not sure } catch (IndexOutOfBoundsException eek) { // we have run out of rows. the remaining rows were fewer than the block size. just note this and move on. i = this.ROWS_TO_PROCESS; } // TODO review with Justin. Removing the "revert to slightly smaller batch size" for now because saving the lastBatch after every row // was slowing the performance. We can reintroduce it in a better way later. For now, let any exceptions flow up // catch(Exception eee){ // // the send size would have been too large. // tableRowsDone = tableRowsDone - 1; // // System.out.println("*** caught an exception trying to process a result: " + tableRowsDone); // System.out.println(eee.getMessage()); // // i = this.ROWS_TO_PROCESS; // remove the one that broke things. this way, we reprocess it // //resultsSoFar = new StringBuilder(lastResults); // reset the values. // } } // fail if tableRowsDone has not changed. this implies that even the first result was too large. if ((tableRowsDone == tableRowsAtStart) && (tableRowsDone < totalRows)) { throw new Exception( "unable to write results. there is a row size which is too large. row number was " + tableRowsDone + " of a total " + totalRows + "."); } if (timerFlag) { endTime = System.nanoTime(); prepSec += ((endTime - startTime) / 1000000000.0); System.err.println(String.format("tot prep=%.2f sec", prepSec)); startTime = endTime; } // take care of last run if (thread != null) { thread.join(); ((SimpleResultSet) this.getRunRes()).throwExceptionIfUnsuccessful(); if (this.getRunException() != null) { throw this.getRunException(); } segment += 1; conf.setServiceEndpoint(null); this.parametersJSON.remove("contents"); this.parametersJSON.remove("jobId"); } // send the current one: conf.setServiceEndpoint("results/storeIncrementalCsvResults"); this.parametersJSON.put("contents", resultsSoFar.toString()); this.parametersJSON.put("jobId", jobId); this.parametersJSON.put("segmentNumber", segment); thread = new Thread(this); thread.run(); if (timerFlag) { endTime = System.nanoTime(); sendSec += ((endTime - startTime) / 1000000000.0); System.err.println(String.format("tot send=%.2f sec", sendSec)); startTime = endTime; } } // end of while loop. } // cleanup // take care of last run if (thread != null) { thread.join(); ((SimpleResultSet) this.getRunRes()).throwExceptionIfUnsuccessful(); if (this.getRunException() != null) { throw this.getRunException(); } } if (timerFlag) { System.err.println(String.format("prep=%.2f sec send=%.2f sec", prepSec, sendSec)); } return; }
From source file:com.greenline.guahao.web.module.home.controllers.json.area.JsonAreaController.java
private Map<String, String> areaPosition(String position) { Map<String, String> dataMap = new HashMap<String, String>(); String provinceName = StringUtils.EMPTY; String cityName = StringUtils.EMPTY; if (StringUtils.isNotBlank(position)) { if (StringUtils.contains(position, LOCATION_PROVINCE_SUFFIX)) { String[] positionArr = StringUtils.split(position, LOCATION_PROVINCE_SUFFIX); provinceName = positionArr[0]; if (positionArr.length > 1) { cityName = positionArr[1]; if (StringUtils.contains(cityName, LOCATION_CITY_SUFFIX)) { cityName = StringUtils.substring(cityName, 0, cityName.length() - 1); }/*from w w w. j a va2 s . com*/ } } else { if (StringUtils.contains(position, LOCATION_CITY_SUFFIX)) { String[] positionArr = StringUtils.split(position, LOCATION_CITY_SUFFIX); provinceName = positionArr[0]; if (positionArr.length > 1) { cityName = positionArr[1]; } } } } if (StringUtils.isNotBlank(provinceName)) { dataMap.put("provice", provinceName); } if (StringUtils.isNotBlank(cityName)) { dataMap.put("city", cityName); } return dataMap; }
From source file:com.hangum.tadpole.rdb.core.editors.main.utils.ExtMakeContentAssistUtil.java
/** * /*from w ww . j a va 2 s . co m*/ * @param userDB * @param strQuery * @param strCursor */ private String getTableColumnAlias(final UserDBDAO userDB, final String strQuery, final String strCursor) { List<String> listName = new ArrayList<>(); TadpoleMetaData dbMetaData = TadpoleSQLManager.getDbMetadata(userDB); String strQuote = dbMetaData.getIdentifierQuoteString(); String strSeparator = "."; String strAlias = ""; if (StringUtils.indexOf(strCursor, strSeparator) != -1) { strAlias = StringUtils.substring(strCursor, 0, StringUtils.indexOf(strCursor, strSeparator)); } if (logger.isDebugEnabled()) { logger.debug("query is [" + strQuery + "]"); logger.debug("[quote]" + strQuote + " [alias]" + strAlias); } String tableNamePattern = "((?:" + strQuote + "(?:[.[^" + strQuote + "]]+)" + strQuote + ")|(?:[\\w" + Pattern.quote(strSeparator) + "]+))"; String structNamePattern; if (StringUtils.isEmpty(strAlias)) { structNamePattern = "(?:from|update|join|into)\\s*" + tableNamePattern; } else { structNamePattern = tableNamePattern + "(?:\\s*\\.\\s*" + tableNamePattern + ")?" + "\\s+(?:(?:AS)\\s)?" + strAlias + "[\\s,]+"; } try { Pattern aliasPattern = Pattern.compile(structNamePattern, Pattern.CASE_INSENSITIVE); Matcher matcher = aliasPattern.matcher(strQuery); if (!matcher.find()) { if (logger.isDebugEnabled()) logger.debug("=====> Not found match"); return ""; } if (matcher.groupCount() > 0) { for (int i = 1; i <= matcher.groupCount(); i++) { listName.add(matcher.group(i)); } } else { if (logger.isDebugEnabled()) logger.debug("=====> Not found object name"); return ""; } } catch (PatternSyntaxException e) { if (logger.isDebugEnabled()) logger.error("=====> find pattern exception"); return ""; } // find object column StringBuffer strColumnList = new StringBuffer(); for (String tblName : listName) { strColumnList.append(getAssistColumnList(userDB, tblName)).append(_PRE_GROUP); } return strColumnList.toString(); }
From source file:de.iai.ilcd.model.flowproperty.FlowProperty.java
/** * Apply cache fields for flow property, those are: * <ul>/*from w ww. j ava 2 s . c om*/ * <li>{@link #getDefaultUnit()}</li> * <li>{@link #getUnitGroupName()}</li> * </ul> */ @Override @PrePersist protected void applyDataSetCache() { super.applyDataSetCache(); IMultiLangString tmp = this.getUnitGroupName(); if (tmp != null) { this.defaultUnitGroupCache = StringUtils.substring(tmp.getDefaultValue(), 0, 20); } else { this.defaultUnitGroupCache = null; } this.defaultUnitCache = StringUtils.substring(this.getDefaultUnit(), 0, 10); }
From source file:com.prowidesoftware.swift.model.MtSwiftMessage.java
private void updateAttributes(final SwiftMessage model, final String fin) { setFileFormat(FileFormat.FIN);// ww w. jav a 2 s .co m if (model.isSystemMessage()) { /* * sebastian agosto 2016 * esto ahora queda redundante con la factory, sacar o dejar por las dudas * para uso en core sin sdk? no jode dejarlo, pero es codigo redundante */ if (model.isAck()) { super.identifier = "ACK"; } else if (model.isNack()) { super.identifier = "NAK"; } setDirection(MessageIOType.incoming); } else { super.identifier = model.getMtId().id(); super.sender = StringUtils.substring(model.getSender(), 0, 8); super.receiver = StringUtils.substring(model.getReceiver(), 0, 8); setDirection(model.getDirection()); } setChecksum(SwiftMessageUtils.calculateChecksum(model)); setPde(model.getPDE()); setPdm(model.getPDM()); setMir(model.getMIR()); setMur(model.getMUR()); setUuid(model.getUUID()); setReference(SwiftMessageUtils.reference(model)); setLastModified(Calendar.getInstance()); }
From source file:edu.sampleu.kim.api.identity.IdentityPersonLookUpEditAftBase.java
public void testIdentityPersonLookUpEdit() throws Exception { String randomSalary = RandomStringUtils.randomNumeric(6); String randomMiddleName = RandomStringUtils.randomAlphabetic(6); ;/* w ww .jav a 2 s. co m*/ String randomAddress = RandomStringUtils.randomNumeric(6); ; String randomExtension = RandomStringUtils.randomNumeric(6); ; String randomEmail = RandomStringUtils.randomAlphabetic(6); ; selectFrameIframePortlet(); waitAndTypeByName("principalName", "fran"); waitAndClickSearchSecond(); selectFrameIframePortlet(); waitAndClickByXpath("//a[@title='edit Person withPrincipal ID=fran ']"); waitAndTypeByName("document.documentHeader.documentDescription", "Test description of person"); // Add new information if it is not present. Otherwise, edit the existing information. if (isElementPresentByName("document.affiliations[0].campusCode")) { clearTextByName("document.affiliations[0].empInfos[0].baseSalaryAmount"); waitAndTypeByName("document.affiliations[0].empInfos[0].baseSalaryAmount", "1" + randomSalary); } else { selectByName("newAffln.affiliationTypeCode", "Staff"); selectByName("newAffln.campusCode", "BL - BLOOMINGTON"); waitAndClickByName("newAffln.dflt"); waitAndClickByName("methodToCall.addAffln.anchor"); waitAndTypeByName("document.affiliations[0].newEmpInfo.employeeId", "9999999999"); waitAndClickByName("document.affiliations[0].newEmpInfo.primary"); selectByName("document.affiliations[0].newEmpInfo.employmentStatusCode", "Active"); selectByName("document.affiliations[0].newEmpInfo.employmentTypeCode", "Professional"); waitAndTypeByName("document.affiliations[0].newEmpInfo.baseSalaryAmount", "1" + randomSalary); waitAndTypeByXpath("//*[@id='document.affiliations[0].newEmpInfo.primaryDepartmentCode']", "BL-BUS"); waitAndClickByName("methodToCall.addEmpInfo.line0.anchor"); } waitAndClickByName("methodToCall.showAllTabs"); // Add nick name or edit the existing one if (isTextPresent("CrazyNickName")) { clearTextByName("document.names[1].middleName"); waitAndTypeByName("document.names[1].middleName", randomMiddleName); } else { waitAndTypeByName("newName.firstName", "CrazyNickName"); waitAndTypeByName("newName.middleName", randomMiddleName); waitAndTypeByName("newName.lastName", "fran"); waitAndClickByName("methodToCall.addName.anchor"); } // Add address or edit the existing one if (isTextPresent("CrazyHomeAddress")) { clearTextByName("document.addrs[0].line1"); waitAndTypeByName("document.addrs[0].line1", randomAddress + " Main St"); } else { waitAndTypeByName("newAddress.line1", randomAddress + " Main St"); waitAndTypeByName("newAddress.line2", "CrazyHomeAddress"); waitAndTypeByName("newAddress.city", "Bloomington"); selectByName("newAddress.stateProvinceCode", "ALASKA"); waitAndTypeByName("newAddress.postalCode", "61821"); selectByName("newAddress.countryCode", "United States"); waitAndClickByName("newAddress.dflt"); waitAndClickByName("methodToCall.addAddress.anchor"); } // Add phone number or edit the existing one if (isTextPresent("555-555-5555")) { clearTextByName("document.phones[0].extensionNumber"); waitAndTypeByName("document.phones[0].extensionNumber", randomExtension); } else { waitAndTypeByName("newPhone.phoneNumber", "555-555-5555"); waitAndTypeByName("newPhone.extensionNumber", randomExtension); selectByName("newPhone.countryCode", "United States"); waitAndClickByName("newPhone.dflt"); waitAndClickByName("methodToCall.addPhone.anchor"); } // Add home email or edit the existing one if (isTextPresent("@gmailCrazy.com")) { clearTextByName("document.emails[1].emailAddress"); waitAndTypeByName("document.emails[1].emailAddress", randomEmail + "@gmailCrazy.com"); } else { waitAndTypeByName("newEmail.emailAddress", randomEmail + "@gmailCrazy.com"); waitAndClickByName("methodToCall.addEmail.anchor"); } waitAndClickByName("methodToCall.route"); waitForTextPresent("Document was successfully submitted."); selectTopFrame(); waitAndClickAdministration(); waitAndClickByLinkText("Person"); selectFrameIframePortlet(); waitAndTypeByName("principalName", "fran"); waitAndClickSearchSecond(); selectFrameIframePortlet(); waitAndClickByXpath("//a[@title='edit Person withPrincipal ID=fran ']"); waitAndClickByName("methodToCall.showAllTabs"); waitForTextPresent("1," + StringUtils.substring(randomSalary, 0, 3) + "," + StringUtils.substring(randomSalary, 3, 6) + ".00"); assertTextPresent(randomMiddleName); assertTextPresent(randomAddress); assertTextPresent(randomExtension); assertTextPresent(randomEmail); testCancelConfirmation(); }
From source file:edu.stanford.base.batch.RawCollectionsExample.java
/** * @param subcat//from w ww . j a va 2 s. com * @throws IOException * @throws HttpException * @throws JsonParseException * @throws URISyntaxException */ public static void pullSearsProducts(String subcat) throws IOException, HttpException, JsonParseException, URISyntaxException { StringBuffer reponse = new StringBuffer(); //http://api.developer.sears.com/v1/productsearch?apikey=09b9aeb25ff985a9c85d877f8a9c4dd9&store=Sears&verticalName=Appliances&categoryName=Refrigerators&searchType=category&productsOnly=1&contentType=json //String request = "http://api.developer.sears.com/v1/productsearch?apikey=09b9aeb25ff985a9c85d877f8a9c4dd9&store=Sears&verticalName=Appliances&categoryName=Refrigerators&subCategoryName=Side-by-Side+Refrigerators&searchType=subcategory&productsOnly=1&endIndex=1000&startIndex=1&contentType=json"; String request = "http://api.developer.sears.com/v1/productsearch?apikey=09b9aeb25ff985a9c85d877f8a9c4dd9&store=Sears&verticalName=Appliances&categoryName=Refrigerators&subCategoryName=" + subcat + "&searchType=subcategory&productsOnly=1&contentType=json&endIndex=1000&startIndex=1"; URI uri = new URI(request); URL url = uri.toURL(); //Compact+Refrigerators System.out.println(url); HttpClient client = new HttpClient(); GetMethod method = new GetMethod(request); // Send GET request int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { System.err.println("Method failed: " + method.getStatusLine()); } InputStream rstream = null; // Get the response body rstream = method.getResponseBodyAsStream(); // Process the response from Yahoo! Web Services BufferedReader br = new BufferedReader(new InputStreamReader(rstream)); String line; while ((line = br.readLine()) != null) { reponse.append(line); System.out.println(line); } br.close(); Gson gson = new Gson(); /* // gson.registerTypeAdapter(Event.class, new MyInstanceCreator()); Collection collection = new ArrayList(); collection.add("hello"); collection.add(5); collection.add(new Event("GREETINGS", "guest")); String json2 = gson.toJson(collection); System.out.println("Using Gson.toJson() on a raw collection: " + json2);*/ JsonParser parser = new JsonParser(); //JsonArray array = parser.parse(json1).getAsJsonArray(); String products = StringUtils.remove(reponse.toString(), "{\"mercadoresult\":{\"products\":{\"product\":[true,"); //System.out.println(products); String productsList = StringUtils.substring(products, 0, StringUtils.indexOf(products, "productcount") - 3); // System.out.println(productsList); productsList = "[" + StringUtils.replaceOnce(productsList, "}}]]", "}]]"); //System.out.println(productsList); List<SearsProduct> prodList = new ArrayList<SearsProduct>(); // Reader reader = new InputStreamReader(productsList); Gson gson1 = new GsonBuilder().create(); JsonArray array1 = parser.parse(productsList).getAsJsonArray(); JsonArray prodArray = (JsonArray) array1.get(0); // prodList= gson1.fromJson(array1.get(2), ArrayList.class); for (JsonElement jsonElement : prodArray) { prodList.add(gson.fromJson(jsonElement, SearsProduct.class)); //System.out.println(gson.fromJson(jsonElement, SearsProduct.class)); } PullSearsProductsDAO pullSearsProductsDAO = new PullSearsProductsDAO(); try { pullSearsProductsDAO.pullAllProducts(prodList); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:info.magnolia.cms.taglibs.util.SearchResultSnippetTag.java
/** * Extract a collection of snippets from any paragraph in the given page. * @return a collection of Strings./*from w w w. ja v a 2 s . com*/ * @todo avoid overlapping snippets (use regexp insted of simple indexOfs) * @todo only extract snippets from user-configured properties * @todo abbreviate on whitespace and puntuation, detect start of sentences * @todo replace ampersand in regexp * @todo break methods and write junits */ public Collection getSnippets() { if (log.isDebugEnabled()) { log.debug("collecting snippets"); //$NON-NLS-1$ } Collection snippets = new ArrayList(); String[] searchTerms = StringUtils.split(this.query); Collection paragraphCollections = this.page.getChildren(ItemType.CONTENTNODE); Iterator iterator = paragraphCollections.iterator(); outer: while (iterator.hasNext()) { Content paragraphCollection = (Content) iterator.next(); Collection paragraphs = paragraphCollection.getChildren(); Iterator parIterator = paragraphs.iterator(); while (parIterator.hasNext()) { Content paragraph = (Content) parIterator.next(); if (log.isDebugEnabled()) { log.debug("Iterating on paragraph " + paragraph); //$NON-NLS-1$ } Collection properties = paragraph.getNodeDataCollection(); Iterator dataIterator = properties.iterator(); while (dataIterator.hasNext()) { NodeData property = (NodeData) dataIterator.next(); if (property.getType() != PropertyType.BINARY) { String resultString = property.getString(); if (log.isDebugEnabled()) { log.debug("Iterating on property " + property.getName()); //$NON-NLS-1$ log.debug("Property value is " + resultString); //$NON-NLS-1$ } // a quick and buggy way to avoid configuration properties, we should allow the user to // configure a list of nodeData to search for... if (resultString.length() < 20) { continue; } for (int j = 0; j < searchTerms.length; j++) { String searchTerm = StringUtils.lowerCase(searchTerms[j]); // exclude keywords and words with less than 2 chars if (!ArrayUtils.contains(SimpleSearchTag.KEYWORDS, searchTerm) && searchTerm.length() > 2) { if (log.isDebugEnabled()) { log.debug("Looking for search term [" + searchTerm + "] in [" + resultString //$NON-NLS-1$//$NON-NLS-2$ + "]"); //$NON-NLS-1$ } // first check, avoid using heavy string replaceAll operations if the search term is not // there if (!StringUtils.contains(resultString.toLowerCase(), searchTerm)) { continue; } // strips out html tags using a regexp resultString = resultString.replaceAll("\\<.*?\\>", ""); //$NON-NLS-1$ //$NON-NLS-2$ // only get first matching keyword int pos = resultString.toLowerCase().indexOf(searchTerm); if (pos > -1) { int posEnd = pos + searchTerm.length(); int from = (pos - chars / 2); if (from < 0) { from = 0; } int to = from + chars; if (to > resultString.length()) { to = resultString.length(); } StringBuffer snippet = new StringBuffer(); snippet.append(StringUtils.substring(resultString, from, pos)); snippet.append("<strong>"); //$NON-NLS-1$ snippet.append(StringUtils.substring(resultString, pos, posEnd)); snippet.append("</strong>"); //$NON-NLS-1$ snippet.append(StringUtils.substring(resultString, posEnd, to)); if (from > 0) { snippet.insert(0, "... "); //$NON-NLS-1$ } if (to < resultString.length()) { snippet.append("... "); //$NON-NLS-1$ } if (log.isDebugEnabled()) { log.debug("Search term found, adding snippet " + snippet); //$NON-NLS-1$ } snippets.add(snippet); if (snippets.size() >= this.maxSnippets) { if (log.isDebugEnabled()) { log.debug("Maximum number of snippets (" //$NON-NLS-1$ + this.maxSnippets + ") reached, exiting"); //$NON-NLS-1$ } break outer; } } } } } } } } return snippets; }
From source file:com.inktomi.wxmetar.MetarParser.java
static boolean parseClouds(String token, final Metar metar) { boolean rval = Boolean.FALSE; // Try to see if the first three characters match a Cloud.Type Cloud.Type cloudType = null;//from w ww.j a v a 2 s. co m try { cloudType = Cloud.Type.valueOf(StringUtils.substring(token, 0, 3)); } catch (IllegalArgumentException e) { return rval; } if (null != cloudType) { rval = Boolean.TRUE; Cloud c = new Cloud(); c.cloudType = cloudType; if (!cloudType.equals(Cloud.Type.CLR)) { c.altitude = Integer.parseInt(StringUtils.substring(token, 3, token.length())) * 100; } metar.clouds.add(c); } return rval; }