List of usage examples for org.apache.commons.lang StringUtils split
public static String[] split(String str, String separatorChars)
Splits the provided text into an array, separators specified.
From source file:gov.nih.nci.cabig.caaers.domain.dto.AeMappingsDTO.java
public static AeMappingsDTO deseralize(String s) { AeMappingsDTO m = new AeMappingsDTO(); int p1 = s.indexOf("relations:[") + 11; int p2 = s.indexOf("],eRejected:"); int p3 = s.indexOf("eRejected:[") + 11; int p4 = s.indexOf("],iRejected:"); int p5 = s.indexOf("iRejected:[") + 11; int p6 = s.indexOf("]", p5); String relations = p2 - p1 > 1 ? s.substring(p1, p2) : null; String eRejections = p4 - p3 > 1 ? s.substring(p3, p4) : null; String iRejections = p6 - p5 > 1 ? s.substring(p5, p6) : null; if (relations != null) { String[] rArr = StringUtils.split(relations, "}"); List<AeMergeDTO> merges = new ArrayList<AeMergeDTO>(); for (int i = 0; i < rArr.length; i++) { merges.add(AeMergeDTO.deseralize(rArr[i])); }/* w ww.ja v a2 s . co m*/ m.setRelations(merges.toArray(new AeMergeDTO[] {})); } if (eRejections != null) { m.setRejectedExternalAeIds(AeMergeDTO.parseCommaSeperatedIntegers(eRejections)); } if (iRejections != null) { m.setRejectedInternalAeIds(AeMergeDTO.parseCommaSeperatedIntegers(iRejections)); } return m; }
From source file:com.bstek.dorado.view.config.xml.ItemsParser.java
@Override protected Object internalParse(Node node, DataParseContext context) throws Exception { Object value = super.internalParse(node, context); if (value instanceof String) { String[] items = StringUtils.split((String) value, ','); return (items != null) ? CollectionUtils.arrayToList(items) : null; } else {/*from w ww . j ava 2s. c o m*/ return value; } }
From source file:eionet.cr.web.util.FactsheetObjectId.java
/** * * @param s/*from w w w . j av a 2s . c o m*/ * @return */ public static ObjectDTO parse(String s) { if (StringUtils.isBlank(s)) { throw new IllegalArgumentException("Supplied string must not be blank"); } String[] parts = StringUtils.split(s, SEPARATOR); if (parts.length != 4) { throw new IllegalArgumentException("Supplied string has wrong format"); } long[] hashes = new long[4]; for (int i = 0; i < parts.length; i++) { try { hashes[i] = Long.parseLong(parts[i]); } catch (NumberFormatException e) { throw new IllegalArgumentException("Supplied string has wrong format"); } } return ObjectDTO.create(hashes[0], hashes[1], hashes[2], hashes[3]); }
From source file:com.swtxml.util.parser.Splitter.java
public String[] split(String value) { return StringUtils.split(value, separators); }
From source file:com.google.gdt.eclipse.designer.hosted.tdt.GWTEnvironmentUtils.java
private static String getHostName() { String hostName = ""; try {/* ww w. j a va 2s .co m*/ hostName = InetAddress.getLocalHost().getHostName(); String[] names = StringUtils.split(hostName, '.'); for (String name : names) { if (StringUtils.isNumeric(name)) { // getHostName() returned in a IP-address form return hostName; } } hostName = names[0]; } catch (UnknownHostException e) { } return hostName; }
From source file:hydrograph.ui.common.util.ParameterUtil.java
/** * Returns true if input string contains any parameter. * /*from ww w. j a va 2s . co m*/ * @param path * @param separator * @return */ public static boolean containsParameter(String path, char separator) { String pathSegments[] = StringUtils.split(path, separator); for (String input : pathSegments) { if (isParameter(input)) return true; } return false; }
From source file:com.bstek.dorado.data.entity.PropertyPathUtils.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void setValueByPath(EntityDataType dataType, Object object, String propertyPath, Object value) throws Exception { String[] paths = StringUtils.split(propertyPath, '.'); Object currentEntity = object; EntityDataType currentDataType = dataType; for (int i = 0; i < paths.length - 1; i++) { String path = paths[i];//from ww w. jav a 2 s . com Object tempEntity; boolean isMap = currentEntity instanceof Map; if (EntityUtils.isEntity(currentEntity)) { tempEntity = EntityUtils.getValue(currentEntity, path); } else if (currentEntity instanceof Map) { tempEntity = ((Map) currentEntity).get(path); } else { tempEntity = PropertyUtils.getSimpleProperty(currentEntity, path); } if (tempEntity == null) { Class<?> subEntityType = null; if (currentDataType != null) { PropertyDef propertyDef = currentDataType.getPropertyDef(path); if (propertyDef != null) { DataType propertyDataType = propertyDef.getDataType(); if (propertyDataType instanceof EntityDataType) { currentDataType = (EntityDataType) propertyDataType; subEntityType = currentDataType.getCreationType(); if (subEntityType == null) { subEntityType = currentDataType.getMatchType(); } } } } else if (isMap) { tempEntity = new HashMap(); currentDataType = null; } if (tempEntity == null) { if (subEntityType == null) { subEntityType = PropertyUtils.getPropertyType(currentEntity, path); } if (subEntityType.isAssignableFrom(Map.class)) { tempEntity = new HashMap(); } else if (!subEntityType.isInterface()) { tempEntity = subEntityType.newInstance(); } currentDataType = null; } if (tempEntity != null) { if (isMap) { ((Map) currentEntity).put(path, tempEntity); } else { PropertyUtils.setSimpleProperty(currentEntity, path, tempEntity); } } else { throw new IllegalArgumentException("Can not write value to [" + StringUtils.join(paths, '.') + "] on [" + ObjectUtils.identityToString(object) + "]."); } } currentEntity = tempEntity; } String path = paths[paths.length - 1]; if (EntityUtils.isEntity(currentEntity)) { EntityUtils.setValue(currentEntity, path, value); } else if (currentEntity instanceof Map) { ((Map) currentEntity).put(path, value); } else { PropertyUtils.setSimpleProperty(currentEntity, path, value); } }
From source file:com.bstek.dorado.view.widget.form.CustomSpinnerValueOutputter.java
public void output(Object object, OutputContext context) throws Exception { JsonBuilder jsonBuilder = context.getJsonBuilder(); jsonBuilder.array();// w w w. ja va2 s .c o m for (String section : StringUtils.split((String) object, ";, ")) { int i = 0; try { i = Integer.parseInt(section); } catch (Exception e) { // do nothing } jsonBuilder.value(i); } jsonBuilder.endArray(); }
From source file:gov.nih.nci.ispy.web.ajax.IdLookup.java
public String lookup(String ids) { String results = ""; //clean the input and validate String inputString = ids.trim().replace(" ", ""); String[] st = StringUtils.split(inputString, ","); //construct the inputlist List<String> inputList = new ArrayList<String>(); inputList = Arrays.asList(st); //pass the input list to the service List<RegistrantInfo> entries = idMapper.getMapperEntriesForIds(inputList); //process the results for return to presentation //Document document = DocumentHelper.createDocument(); //Element container = document.addElement("div"); JSONArray regs = new JSONArray(); //make an array of registrants regs.add(inputString);//w w w. ja v a 2 s. c o m //Element report = document.addElement( "table" ).addAttribute("name", inputString); for (RegistrantInfo entry : entries) { //Element reg = report.addElement( "registrant" ).addAttribute("regId", entry.getRegistrationId()); //for each registrant make an array of samples JSONArray sams = new JSONArray(); for (SampleInfo sampleInfo : entry.getAssociatedSamples()) { JSONObject sam = new JSONObject(); sam.put("regId", entry.getRegistrationId()); sam.put("labtrackId", sampleInfo.getLabtrackId()); sam.put("timePoint", String.valueOf(sampleInfo.getTimepoint())); sam.put("coreType", String.valueOf(sampleInfo.getCoreType())); sam.put("sectionInfo", String.valueOf(sampleInfo.getSectionInfo())); /* Element row = reg.addElement( "sample" ); Element cell = row.addElement( "regId" ); cell.addText(entry.getRegistrationId()); cell = null; cell = row.addElement( "labtrackId" ); cell.addText(sampleInfo.getLabtrackId()); cell = null; cell = row.addElement( "timePoint" ); cell.addText(String.valueOf(sampleInfo.getTimepoint())); cell = null; cell = row.addElement( "coreType" ); cell.addText(String.valueOf(sampleInfo.getCoreType())); cell = null; cell = row.addElement( "sectionInfo" ); cell.addText(String.valueOf(sampleInfo.getSectionInfo())); */ sams.add(sam); } regs.add(sams); } /* for (RegistrantInfo entry:entries) { results += "[\"" + entry.getRegistrationId() + "\"," ; for(SampleInfo sampleInfo : entry.getAssociatedSamples()) { } } */ //return document; return regs.toString(); }
From source file:com.github.dbourdette.otto.data.filler.TokenizeOperation.java
@Override public List<String> handle(String column) { String[] tokens = StringUtils.split(column, separator); List<String> result = new ArrayList<String>(); if (StringUtils.isEmpty(column)) { result.add(""); return result; }// w w w .ja v a 2 s . c o m for (String token : tokens) { if (!ArrayUtils.contains(stopWords, token)) { result.add(token); } } return result; }