List of usage examples for java.lang String subSequence
public CharSequence subSequence(int beginIndex, int endIndex)
From source file:com.bluexml.xforms.generator.forms.renderable.classes.RenderableLayout.java
/** * Compute layout./*w ww .j av a2s . c o m*/ * * @param layout * the layout */ private void computeLayout(String layout) { List<String> alines = new ArrayList<String>(); parseLines(layout, alines); for (String string : alines) { List<String> rcolumns = new ArrayList<String>(); String[] columns = string.split(","); for (String column : columns) { String realColumn = column.subSequence(1, column.length() - 1).toString(); rcolumns.add(realColumn); } allNames.addAll(rcolumns); lines.add(rcolumns); } }
From source file:org.dataconservancy.dcs.util.KeyDigestPathAlgorithm.java
private String appendDirectories(String fileName) { StringBuilder path = new StringBuilder(); int length = 2 * directoryWidth; for (int depth = 0; depth < directoryDepth; depth++) { int start = 2 * directoryWidth * depth; path.append(fileName.subSequence(start, start + length)); if (length > 0) { path.append(File.separator); }// ww w .j a v a2 s . c o m } path.append(fileName); return path.toString(); }
From source file:org.apache.syncope.client.console.topology.TopologyNodePanel.java
@Override public void onEvent(final IEvent<?> event) { if (event.getPayload() instanceof UpdateEvent) { final UpdateEvent updateEvent = UpdateEvent.class.cast(event.getPayload()); final String key = updateEvent.getKey(); final AjaxRequestTarget target = updateEvent.getTarget(); if (node.getKind() == Kind.CONNECTOR && key.equalsIgnoreCase(node.getKey())) { ConnInstanceTO conn = new ConnectorRestClient().read(key); String displayName = // [SYNCOPE-1233] StringUtils.isBlank(conn.getDisplayName()) ? conn.getBundleName() : conn.getDisplayName(); final String resourceName = displayName.length() > 14 ? displayName.subSequence(0, 10) + "..." : displayName;//from w ww. j av a 2 s.c o m label.setDefaultModelObject(resourceName); target.add(label); node.setDisplayName(displayName); } } }
From source file:model.manager.SearchManager.java
public static List<PatientIdentifier> getPatientIdentifiersByName(Session session, String patientId, boolean includeInactivePatients, List<IdentifierType> types) throws HibernateException { String jsonString;//from w w w . java 2 s. com String[] resourceArray; String nid; Date theDate; Date _theDate; List<PatientIdentifier> patientIdentifiers = new ArrayList<PatientIdentifier>(); RestClient restClient = new RestClient(); String resource = restClient.getOpenMRSResource("patient?q=" + StringUtils.replace(patientId, " ", "%20")); String _resource = (String) resource.subSequence(11, resource.length()); _resource = _resource.substring(0, _resource.length() - 1); JSONArray jsonArray = new JSONArray(_resource); for (int i = 0; i < JsonHelper.toList(jsonArray).size(); i++) { PatientIdentifier identifier = new PatientIdentifier(); patient = new Patient(); jsonString = JsonHelper.toList(jsonArray).get(i).toString().replaceAll("display=", "") .replaceAll("uuid=", ""); jsonString = jsonString.substring(1, jsonString.length() - 1); resourceArray = jsonString.split(iDartProperties.ARRAY_SPLIT); String nameNid = (resourceArray[0].replaceAll(resourceArray[0].substring(0, 18), " ")).trim(); List<String> fullName = RestUtils.splitName(nameNid); patient.setFirstNames((fullName.get(0) + iDartProperties.SPACE + fullName.get(1)) .replaceAll(iDartProperties.HIFEN, iDartProperties.SPACE).trim()); patient.setLastname(fullName.get(2).replaceAll("-", " ").trim()); nid = restClient.getOpenMRSResource(iDartProperties.REST_GET_PATIENT_GENERIC + resourceArray[3].trim()); JSONObject jsonObject = new JSONObject(nid); nid = String.valueOf(jsonObject.get("display")); nid = nid.substring(0, nid.indexOf("-")).trim(); String strBirthdate = jsonObject.getJSONObject("person").getString("birthdate"); char gender = jsonObject.getJSONObject("person").getString("gender").charAt(0); String year = strBirthdate.substring(0, 4); String month = new DateFormatSymbols(Locale.ENGLISH) .getMonths()[Integer.valueOf(strBirthdate.substring(5, 7)) - 1]; Integer day = Integer.valueOf(strBirthdate.substring(8, 10)); SimpleDateFormat _sdf = new SimpleDateFormat("d-MMMM-yyyy", Locale.ENGLISH); String dataInicioTarv = restClient.getOpenMRSResource(iDartProperties.REST_OBS_PATIENT + resourceArray[3].trim() + iDartProperties.CONCEPT_DATA_INICIO_TARV); if (dataInicioTarv.length() > 14) { dataInicioTarv = dataInicioTarv.substring(94); dataInicioTarv = dataInicioTarv.substring(0, 10); String _year = dataInicioTarv.substring(6, 10); String _month = new DateFormatSymbols(Locale.ENGLISH) .getMonths()[Integer.valueOf(dataInicioTarv.substring(3, 5)) - 1]; Integer _day = Integer.valueOf(dataInicioTarv.substring(0, 2)); _theDate = null;//Data de Inicio Tarv try { _theDate = _sdf.parse(_day.toString() + "-" + _month + "-" + _year); } catch (ParseException e1) { System.out.println(e1.getMessage()); } patient.setAttributeValue(PatientAttribute.ARV_START_DATE, _theDate); } SimpleDateFormat sdf = new SimpleDateFormat("d-MMMM-yyyy", Locale.ENGLISH); theDate = null;//Data de Nascimento try { theDate = sdf.parse(day.toString() + "-" + month + "-" + year); } catch (ParseException e1) { System.out.println(e1.getMessage()); } patient.setDateOfBirth(theDate); patient.setPatientId(nid); patient.setSex(gender); identifier.setType(types.get(0)); identifier.setValueEdit(null); identifier.setValue(nid); identifier.setPatient(patient); patientIdentifiers.add(identifier); } return patientIdentifiers; }
From source file:org.kuali.kra.award.maintenance.AwardTemplateMaintainableImpl.java
@Override public void processBeforeAddLine(String colName, Class colClass, BusinessObject addBO) { if (colName.contains("[") && colName.contains("]")) { String numString = (String) colName.subSequence(colName.indexOf("[") + 1, colName.indexOf("]")); try {// w w w .java2s . c om this.columnNumber = Integer.parseInt(numString); } catch (Exception e) { //wasn't a number } } super.processBeforeAddLine(colName, colClass, addBO); }
From source file:com.zia.freshdocs.cmis.CMIS.java
protected String buildRelativeURI(String path) { StringBuilder uri = new StringBuilder(); String rootURI = _prefs.getWebappRoot(); if (!path.startsWith(rootURI)) { if (rootURI.endsWith("/")) { uri.append(rootURI.subSequence(0, rootURI.length() - 2)); } else {/*from ww w . j ava 2s .c o m*/ uri.append(rootURI); } } uri.append(path); if (_ticket != null) { uri.append("?alf_ticket=").append(_ticket); } return uri.toString(); }
From source file:org.apache.james.jdkim.tagvalue.SignatureRecordImpl.java
/** * @see org.apache.james.jdkim.api.SignatureRecord#getIdentityLocalPart() *///from www . ja v a2s.com public CharSequence getIdentityLocalPart() { String identity = getIdentity().toString(); int pAt = identity.indexOf('@'); return identity.subSequence(0, pAt); }
From source file:com.jmstoolkit.pipeline.plugin.XMLTransform.java
/** * Implementation of JMS <code>MessageListener</code> interface. Performs * the work when a message is received.//from w w w. ja v a 2 s.c o m * * @param message The JMS Message received. */ @Override public final void onMessage(final Message message) { String messageId = "xxx"; try { messageId = message.getJMSMessageID(); } catch (JMSException ex) { LOGGER.log(Level.SEVERE, "Failed to get message id", ex); } try { if (message instanceof TextMessage) { final String body = trim(((TextMessage) message).getText()); try { System.out.println("############################################"); System.out.println("Transform input message received by " + getName() + ":"); System.out.println(body.subSequence(0, 78)); System.out.println("############################################"); LOGGER.log(Level.INFO, "{0} Transform performed by service: {1}", new Object[] { messageId, getName() }); getJmsTemplate().convertAndSend(getXslt().transform(body)); this.setOperationCount(this.getOperationCount() + 1); } catch (XSLTransformerException ex) { LOGGER.log(Level.SEVERE, messageId + " XSL Transform failed: ", ex); } } } catch (JMSException ex) { LOGGER.log(Level.SEVERE, messageId + " Failed to get message text: ", ex); } }
From source file:edu.harvard.i2b2.fhir.FhirUtil.java
public static Object getChild(Resource r, String pathStr) // is dot separated path throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { Class c = FhirUtil.getResourceClass(r); String returnStr = null;/*ww w . ja v a2 s . co m*/ String suffix = null; String prefix = pathStr; logger.trace("pathStr:" + pathStr); if (pathStr.indexOf('.') > -1) { suffix = pathStr.substring(pathStr.indexOf('.') + 1); prefix = pathStr.substring(0, pathStr.indexOf('.')); } String methodName = prefix.substring(0, 1).toUpperCase() + prefix.subSequence(1, prefix.length()); Method method = c.getMethod("get" + methodName, null); if (suffix == null) { Object o = method.invoke(c.cast(r)); if (Reference.class.isInstance(o)) { return o; } else { return o; } } else { return getChild(r, suffix); } }
From source file:android.databinding.ViewDataBinding.java
private static int findIncludeIndex(String tag, int minInclude, IncludedLayouts included, int includedIndex) { final int slashIndex = tag.indexOf('/'); final CharSequence layoutName = tag.subSequence(slashIndex + 1, tag.length() - 2); final String[] layouts = included.layouts[includedIndex]; final int length = layouts.length; for (int i = minInclude; i < length; i++) { final String layout = layouts[i]; if (TextUtils.equals(layoutName, layout)) { return i; }// www. j a v a 2 s.c o m } return -1; }