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:com.swtxml.swt.types.FormAttachmentType.java
public FormAttachment convert(String value) { FormAttachment attachment = new FormAttachment(); List<String> parts = new ArrayList<String>(); int start = 0; for (int i = 0; i < value.length(); i++) { char charAt = value.charAt(i); if (charAt == '-' || charAt == '+') { parts.add(value.substring(start, i).trim()); start = i;// w w w. ja v a2 s.c om } } parts.add(value.substring(start, value.length()).trim()); for (String part : parts) { if (part.endsWith("%")) { if (part.startsWith("+")) { part = part.substring(1); } attachment.numerator = Integer.parseInt(part.substring(0, part.length() - 1)); } else { try { if (part.startsWith("+")) { part = part.substring(1); } attachment.offset = Integer.parseInt(part); } catch (NumberFormatException e) { String[] controlString = StringUtils.split(part, "."); if (controlString.length >= 1) { String id = controlString[0].trim(); IIdResolver idResolver = Context.adaptTo(IIdResolver.class); if (idResolver == null) { throw new ParseException("No IDs available in current context"); } Control control = idResolver.getById(id, Control.class); if (control == null) { throw new ParseException("Control with id \"" + id + "\" not found"); } attachment.control = control; } if (controlString.length >= 2) { String align = controlString[1].trim(); attachment.alignment = CONSTANTS_ALIGN.getIntValue(align); } } } } return attachment; }
From source file:com.hangum.tadpole.manager.core.export.SystemDBDataManager.java
/** * ? import .// w w w .j a va 2 s . c o m * */ public static void importUserDB(String strSource) throws Exception { Gson gson = new Gson(); String[] strUserdb = StringUtils.split(strSource, PublicTadpoleDefine.LINE_SEPARATOR); if (!StringUtils.startsWith(strUserdb[0], SystemDefine.NAME)) { throw new RuntimeException(Messages.get().SystemDBDataManager_8); } // int 1? ? . for (int i = 3; i < strUserdb.length; i++) { UserDBDAO userDBDAO = gson.fromJson(strUserdb[i], UserDBDAO.class); TadpoleSystem_UserDBQuery.newUserDB(userDBDAO, SessionManager.getUserSeq()); } // google analytic AnalyticCaller.track("import user DB"); }
From source file:com.github.bluetiger9.nosql.benchmarking.clients.document.mongodb.MongoDBClient.java
@Override public void connect() throws ClientException { try {// w ww .j a v a2 s .c om for (String server : StringUtils .split(properties.getProperty(CommonClientProperties.PROPERTY_SERVERS, DEFAULT_SERVERS), ',')) { servers.add(getServerAddress(server)); } client = new MongoClient(servers); db = client.getDB(dbName); dbCollection = db.getCollection(collection); } catch (Exception e) { throw new ClientException("connection error", e); } }
From source file:com.netflix.simianarmy.aws.janitor.ELBJanitor.java
@Override protected void cleanup(Resource resource) { LOGGER.info(String.format("Deleting ELB %s", resource.getId())); awsClient.deleteElasticLoadBalancer(resource.getId()); // delete any DNS records attached to this ELB String dnsNames = resource.getAdditionalField("referencedDNS"); String dnsTypes = resource.getAdditionalField("referencedDNSTypes"); String dnsZones = resource.getAdditionalField("referencedDNSZones"); if (StringUtils.isNotBlank(dnsNames) && StringUtils.isNotBlank(dnsTypes) && StringUtils.isNotBlank(dnsZones)) { String[] dnsNamesSplit = StringUtils.split(dnsNames, ','); String[] dnsTypesSplit = StringUtils.split(dnsTypes, ','); String[] dnsZonesSplit = StringUtils.split(dnsZones, ','); if (dnsNamesSplit.length != dnsTypesSplit.length) { LOGGER.error(/*from w w w. jav a2s.com*/ String.format( "DNS Name count does not match DNS Type count, aborting DNS delete for ELB %s"), resource.getId()); LOGGER.error(String.format("DNS Names found but not deleted: %s for ELB %s"), dnsNames, resource.getId()); return; } if (dnsNamesSplit.length != dnsZonesSplit.length) { LOGGER.error( String.format( "DNS Name count does not match DNS Zone count, aborting DNS delete for ELB %s"), resource.getId()); LOGGER.error(String.format("DNS Names found but not deleted: %s for ELB %s"), dnsNames, resource.getId()); return; } for (int i = 0; i < dnsNamesSplit.length; i++) { LOGGER.info(String.format("Deleting DNS Record %s for ELB %s of type %s in zone %s", dnsNamesSplit[i], resource.getId(), dnsTypesSplit[i], dnsZonesSplit[i])); awsClient.deleteDNSRecord(dnsNamesSplit[i], dnsTypesSplit[i], dnsZonesSplit[i]); } } }
From source file:com.neusoft.mid.clwapi.threadwork.PhotoSendWorkThread.java
public void run() { if (null != msgInfo) { logger.info("VINS?:" + msgInfo.getVin()); String[] vinArray = StringUtils.split(StringUtils.strip(msgInfo.getVin()), "|"); logger.info("???" + vinArray.length + ""); logger.info("??:" + msgInfo.getType()); String[] channelArray = StringUtils.split(StringUtils.strip(msgInfo.getType()), "|"); logger.info("???" + channelArray.length + "?"); // ?.//from w ww. j a v a 2 s . c om String batchId = UUID.randomUUID().toString().replaceAll("-", ""); for (String vinTemp : vinArray) { String vin = StringUtils.strip(vinTemp); // ???? try { logger.info("vin:" + vin + ""); TerminalViBean terminalInfo = (TerminalViBean) msgMapper.getRealVehcileByVin(vin); // ???? if (isPicPassable(vin, terminalInfo)) { logger.info("VIN:" + vin + "??????"); for (String channelTemp : channelArray) { String msgId = createMsgId(); MDC.put("SUB_ID", "[" + msgId + "]"); String channel = StringUtils.strip(channelTemp); SendCommandInfo info = initPicCommandInfo(vin, channel, terminalInfo.getSimCardNum(), batchId, usrInfo, msgId); if (null != info) { // ????? DeliverMsgResult respResult = sendDeliverMsgService.sendCommandToCoreService(info); // ?????. if (null != respResult && "0".equals(respResult.getCode())) { logger.info("VIN:" + vin + ",channel:" + channel + "???"); } else { logger.error("?VIN:" + vin + ",channel:" + channel + "?"); } } else { logger.error("?VIN:" + vin + ",channel:" + channel + "??"); } } } else { logger.info("VIN:" + vin + "????"); } } catch (DataAccessException e) { logger.error("??vin:" + vin + "?", e); } catch (Exception e) { logger.error("vin:" + vin + "??", e); } } } }
From source file:com.qualogy.qafe.web.css.util.CssProvider.java
private CssProvider() { Properties p = new Properties(); try {/*from w ww . j a va 2 s .c om*/ p.load(this.getClass().getResourceAsStream("supported-style-rendering.properties")); } catch (IOException e1) { throw new RuntimeException(e1); } String value = p.getProperty("styles"); String[] supportedStyles = StringUtils.split(value, ','); if (supportedStyles == null || supportedStyles.length == 0) { throw new RuntimeException("There is no supported styles defined."); } for (int i = 0; i < supportedStyles.length; i++) { Map<String, String> translationMap = new HashMap<String, String>(); styleRenderers.put(supportedStyles[i].toLowerCase(), translationMap); Properties styleProperties = new Properties(); try { styleProperties.load(this.getClass() .getResourceAsStream("qafe-style-rendering-" + supportedStyles[i] + ".properties")); translationMap.put("prefixed", styleProperties.getProperty("prefixed")); } catch (IOException e) { throw new RuntimeException(e); } } logger.fine(""); }
From source file:es.emergya.ui.gis.GeometryConverter.java
/** * <p>/* ww w . j a v a2 s.co m*/ * Ejemplos de sintaxis: * </p> * <ul> * <li>Punto: POINT(30 50)</li> * <li>Linea: LINESTRING(1 1, 5 5, 10 10, 20 20)</li> * <li>Multilinea: LINESTRING( (1 1, 5 5, 10 10, 20 20),(20 30, 10 15, 40 * 5))</li> * <li>Poligono simple: POLYGON (0 0, 10 0, 10 10, 0 0)</li> * <li>Varios poligono en una sola geometria (multipoligono): POLYGON ( (0 * 0, 10 0, 10 10, 0 10, 0 0),( 20 20, 20 40, 40 40, 40 20, 20 20) )</li> * <li>Geometrias de distinto tipo en un solo elemento: * GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))</li> * <li>Punto vacio: POINT EMPTY</li> * <li>Multipoligono vacio: MULTIPOLYGON EMPTY</li> * </ul> * * @param geometry * @return */ public static OsmPrimitive wktToOsmPrimitive(String geometry) { OsmPrimitive resultado = null; if (geometry != null) { log.trace("Vamos a convertir " + geometry); String[] componentes = StringUtils.split(geometry, "("); String tipo = componentes[0]; GeometryType type = null; if (tipo.equals("LINESTRING")) type = GeometryType.LINESTRING; else if (tipo.equals("MULTILINESTRING")) type = GeometryType.MULTILINESTRING; else if (tipo.equals("POINT")) type = GeometryType.POINT; else if (tipo.equals("MULTIPOINT")) type = GeometryType.MULTIPOINT; else if (tipo.equals("POLYGON")) type = GeometryType.POLYGON; else if (tipo.equals("MULTIPOLYGON")) type = GeometryType.MULTIPOLYGON; else type = GeometryType.UNKNOWN; switch (type) { case LINESTRING: log.trace("Reconocido a LINESTRING"); resultado = new Way(); if (componentes[1].length() < 1) { log.error("componentes erroneas"); } else { String[] coordenadas = StringUtils .split(componentes[1].substring(0, componentes[1].length() - 1), ","); if (coordenadas.length == 0) log.trace("No hay coordenadas, geometria vacia?"); long id = 0l; for (String coordenada : coordenadas) { log.trace("coordenadas: " + coordenada); String[] numeros = StringUtils.split(coordenada, " "); if (numeros.length != 2) log.error("Numero de dimensiones incorrecto: " + numeros.length); else { try { LatLon latlon = extractLatLon(numeros); log.trace(latlon); Node n = new Node(id++); n.setCoor(latlon); ((Way) resultado).addNode(n); } catch (Exception e) { log.error("Error calculando el nodo", e); } } } } break; case POINT: log.trace("Reconocido a POINT"); if (componentes[1].length() < 1) { log.error("componentes erroneas"); } else { String coordenada = componentes[1].substring(0, componentes[1].length() - 1); if (coordenada.length() == 0) log.trace("No hay coordenadas, geometria vacia?"); log.trace("coordenadas: " + coordenada); String[] numeros = StringUtils.split(coordenada, " "); if (numeros.length != 2) log.error("Numero de dimensiones incorrecto: " + numeros.length); else { try { LatLon latlon = extractLatLon(numeros); resultado = new Node(latlon); } catch (Exception e) { log.error("Error calculando el nodo", e); e.printStackTrace(); } } } break; default: throw new NotImplementedException("Aun no tenemos implementado este tipo de geometria: " + tipo); } } resultado.incomplete = false; return resultado; }
From source file:cn.hxh.springside.orm.PageRequest.java
/** * ???.// w w w . ja va 2s. c o m * * @param orderDir ?descasc,?','. */ public void setOrderDir(final String orderDir) { String lowcaseOrderDir = StringUtils.lowerCase(orderDir); //order? String[] orderDirs = StringUtils.split(lowcaseOrderDir, ','); for (String orderDirStr : orderDirs) { if (!StringUtils.equals(Sort.DESC, orderDirStr) && !StringUtils.equals(Sort.ASC, orderDirStr)) { throw new IllegalArgumentException("??" + orderDirStr + "??"); } } this.orderDir = lowcaseOrderDir; }
From source file:com.adguard.compiler.LocaleUtils.java
public static void updateExtensionNameForChromeLocales(File dest, String extensionNamePostfix) throws IOException { if (StringUtils.isEmpty(extensionNamePostfix)) { return;/* ww w .j av a 2 s. c o m*/ } File chromeLocalesDir = new File(dest, "_locales"); for (File file : chromeLocalesDir.listFiles()) { File chromeLocaleFile = new File(file, "messages.json"); StringBuilder sb = new StringBuilder(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(chromeLocaleFile)); String line; while ((line = reader.readLine()) != null) { sb.append(line).append("\r\n"); if (line.trim().startsWith("\"name\":") || line.trim().startsWith("\"short_name\":")) { line = reader.readLine(); String[] parts = StringUtils.split(line, ":"); String message = StringUtils.removeEnd(parts[1].trim(), "\"") + extensionNamePostfix + "\""; sb.append("\t\"message\": ").append(message).append("\r\n"); } } } finally { IOUtils.closeQuietly(reader); } FileUtils.writeStringToFile(chromeLocaleFile, sb.toString()); } }
From source file:mitm.common.util.InetNetworkFilter.java
/** * @param filterSpec comma separated networks * @throws UnknownHostException //w w w . j a v a 2 s . c o m */ public InetNetworkFilter(String filterSpec) throws UnknownHostException { Check.notNull(filterSpec, "filterSpec"); String[] filterSpecs = StringUtils.split(filterSpec, ','); for (String spec : filterSpecs) { if (spec != null) { networks.add(InetNetwork.getFromString(spec.trim())); } } }