List of usage examples for org.apache.commons.lang StringUtils strip
public static String strip(String str)
Strips whitespace from the start and end of a String.
From source file:org.ojbc.intermediaries.sn.topic.chcycle.ChCycleNotificationRequest.java
public String getEventDateTimeDisplay() { boolean isNotificationEventDateInclusiveOfTime = isNotificationEventDateInclusiveOfTime(); DateTime eventDateTime = getNotificationEventDate(); String eventDate = NotificationBrokerUtils.returnFormattedNotificationEventDate(eventDateTime, isNotificationEventDateInclusiveOfTime); return StringUtils.strip(eventDate); }
From source file:org.ojbc.web.portal.controllers.SubscriptionsController.java
SubscribedPersonNames getAllPersonNamesFromRapsheet(Document rapSheetDoc) throws Exception { SubscribedPersonNames rSubscribedPersonNames = new SubscribedPersonNames(); Node rapSheetNode = XmlUtils.xPathNodeSearch(rapSheetDoc, "/ch-doc:CriminalHistory/ch-ext:RapSheet"); Node pNameNode = XmlUtils.xPathNodeSearch(rapSheetNode, "rap:Introduction/rap:RapSheetRequest/rap:RapSheetPerson/nc:PersonName"); String personOrigFullName = getNameConcatinated(pNameNode); personOrigFullName = StringUtils.strip(personOrigFullName); if (StringUtils.isNotBlank(personOrigFullName)) { rSubscribedPersonNames.setOriginalName(personOrigFullName); }//from w w w . j a v a 2 s . c o m NodeList altNameNodeList = XmlUtils.xPathNodeListSearch(rapSheetNode, "rap:RapSheetPerson/nc:PersonAlternateName"); //process the alternate names for (int i = 0; i < altNameNodeList.getLength(); i++) { Node iAltNameNode = altNameNodeList.item(i); String fullNameContinated = getNameConcatinated(iAltNameNode); if (StringUtils.isNotBlank(fullNameContinated)) { rSubscribedPersonNames.getAlternateNamesList().add(fullNameContinated); } } return rSubscribedPersonNames; }
From source file:org.openhab.binding.hdanywhere.internal.HDanywhereGenericBindingProvider.java
private void parseAndAddBindingConfig(Item item, String bindingConfigs) throws BindingConfigParseException { String bindingConfig = StringUtils.substringBefore(bindingConfigs, ","); String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ","); HDanywhereBindingConfig newConfig = new HDanywhereBindingConfig(); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig);/*from w w w . ja va 2 s. co m*/ while (StringUtils.isNotBlank(bindingConfigTail)) { bindingConfig = StringUtils.substringBefore(bindingConfigTail, ","); bindingConfig = StringUtils.strip(bindingConfig); bindingConfigTail = StringUtils.substringAfter(bindingConfig, ","); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig); } }
From source file:org.openhab.binding.irtrans.internal.IRtransGenericBindingProvider.java
/** * Parses the and add binding config.//ww w. j a v a 2 s. c om * * @param item the item * @param bindingConfigs the binding configs * @throws BindingConfigParseException the binding config parse exception */ private void parseAndAddBindingConfig(Item item, String bindingConfigs) throws BindingConfigParseException { String bindingConfig = StringUtils.substringBefore(bindingConfigs, ","); String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ","); IRtransBindingConfig newConfig = new IRtransBindingConfig(); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig); while (StringUtils.isNotBlank(bindingConfigTail)) { bindingConfig = StringUtils.substringBefore(bindingConfigTail, ","); bindingConfig = StringUtils.strip(bindingConfig); bindingConfigTail = StringUtils.substringAfter(bindingConfig, ","); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig); } }
From source file:org.openhab.binding.miele.handler.MieleApplianceHandler.java
@Override public void onApplianceStateChanged(String UID, DeviceClassObject dco) { String myUID = "hdm:ZigBee:" + (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID); String modelID = StringUtils.right(dco.DeviceClass, dco.DeviceClass.length() - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length()); if (myUID.equals(UID)) { if (modelID.equals(this.modelID)) { for (JsonElement prop : dco.Properties.getAsJsonArray()) { try { DeviceProperty dp = gson.fromJson(prop, DeviceProperty.class); dp.Value = StringUtils.trim(dp.Value); dp.Value = StringUtils.strip(dp.Value); onAppliancePropertyChanged(UID, dp); } catch (Exception p) { // Ignore - this is due to an unrecognized and not yet reverse-engineered array property }/*from w ww . ja v a 2 s . com*/ } for (JsonElement operation : dco.Operations.getAsJsonArray()) { try { DeviceOperation devop = gson.fromJson(operation, DeviceOperation.class); DeviceMetaData pmd = gson.fromJson(devop.Metadata, DeviceMetaData.class); } catch (Exception p) { // Ignore - this is due to an unrecognized and not yet reverse-engineered array property } } } } }
From source file:org.openhab.binding.miele.handler.MieleApplianceHandler.java
@Override public void onAppliancePropertyChanged(String UID, DeviceProperty dp) { String myUID = "hdm:ZigBee:" + (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID); String dpValue = StringUtils.strip(dp.Value); dpValue = StringUtils.trim(dpValue); if (myUID.equals(UID)) { try {/*from ww w . j a v a2 s .co m*/ DeviceMetaData dmd = null; if (dp.Metadata == null) { String metadata = metaDataCache.get(new StringBuilder().append(dp.Name).toString().trim()); if (metadata != null) { JsonParser parser = new JsonParser(); JsonObject jsonMetaData = (JsonObject) parser.parse(metadata); dmd = gson.fromJson(jsonMetaData, DeviceMetaData.class); // only keep the enum, if any - that's all we care for events we receive via multicast // all other fields are nulled dmd.LocalizedID = null; dmd.LocalizedValue = null; dmd.Filter = null; dmd.description = null; } } if (dp.Metadata != null) { String metadata = StringUtils.replace(dp.Metadata.toString(), "enum", "MieleEnum"); JsonParser parser = new JsonParser(); JsonObject jsonMetaData = (JsonObject) parser.parse(metadata); dmd = gson.fromJson(jsonMetaData, DeviceMetaData.class); metaDataCache.put(new StringBuilder().append(dp.Name).toString().trim(), metadata); } ApplianceChannelSelector selector = null; try { selector = getValueSelectorFromMieleID(dp.Name); } catch (Exception h) { logger.trace("{} is not a valid channel for a {}", dp.Name, modelID); } if (selector != null && !selector.isProperty()) { ChannelUID theChannelUID = new ChannelUID(getThing().getUID(), selector.getChannelID()); logger.trace("Update state of {} with '{}'", new Object[] { theChannelUID.toString(), dpValue }); if (dp.Value != null) { logger.trace("Update state of {} with getState '{}'", new Object[] { theChannelUID.toString(), selector.getState(dpValue, dmd) }); updateState(theChannelUID, selector.getState(dpValue, dmd)); } else { updateState(theChannelUID, UnDefType.UNDEF); } } else { if (selector != null && dpValue != null) { logger.debug("Updating the property '{}' of '{}' to '{}'", new Object[] { selector.getChannelID(), getThing().getUID(), selector.getState(dpValue, dmd).toString() }); Map<String, String> properties = editProperties(); properties.put(selector.getChannelID(), selector.getState(dpValue, dmd).toString()); updateProperties(properties); } } } catch (IllegalArgumentException e) { logger.error("An exception occurred while processing a changed device property :'{}'", e.getMessage()); } } }
From source file:org.openhab.binding.miele.internal.handler.MieleApplianceHandler.java
@Override public void onApplianceStateChanged(String UID, DeviceClassObject dco) { String myUID = "hdm:ZigBee:" + (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID); String modelID = StringUtils.right(dco.DeviceClass, dco.DeviceClass.length() - new String("com.miele.xgw3000.gateway.hdm.deviceclasses.Miele").length()); if (myUID.equals(UID)) { if (modelID.equals(this.modelID)) { for (JsonElement prop : dco.Properties.getAsJsonArray()) { try { DeviceProperty dp = gson.fromJson(prop, DeviceProperty.class); dp.Value = StringUtils.trim(dp.Value); dp.Value = StringUtils.strip(dp.Value); onAppliancePropertyChanged(UID, dp); } catch (Exception p) { // Ignore - this is due to an unrecognized and not yet reverse-engineered array property }//from www. java2 s . c o m } for (JsonElement operation : dco.Operations.getAsJsonArray()) { try { DeviceOperation devop = gson.fromJson(operation, DeviceOperation.class); DeviceMetaData pmd = gson.fromJson(devop.Metadata, DeviceMetaData.class); } catch (Exception p) { // Ignore - this is due to an unrecognized and not yet reverse-engineered array property } } } } }
From source file:org.openhab.binding.miele.internal.handler.MieleApplianceHandler.java
@Override public void onAppliancePropertyChanged(String UID, DeviceProperty dp) { String myUID = "hdm:ZigBee:" + (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID); if (myUID.equals(UID)) { try {// w w w . j av a2s. c o m DeviceMetaData dmd = null; if (dp.Metadata == null) { String metadata = metaDataCache.get(new StringBuilder().append(dp.Name).toString().trim()); if (metadata != null) { JsonParser parser = new JsonParser(); JsonObject jsonMetaData = (JsonObject) parser.parse(metadata); dmd = gson.fromJson(jsonMetaData, DeviceMetaData.class); // only keep the enum, if any - that's all we care for events we receive via multicast // all other fields are nulled dmd.LocalizedID = null; dmd.LocalizedValue = null; dmd.Filter = null; dmd.description = null; } } if (dp.Metadata != null) { String metadata = StringUtils.replace(dp.Metadata.toString(), "enum", "MieleEnum"); JsonParser parser = new JsonParser(); JsonObject jsonMetaData = (JsonObject) parser.parse(metadata); dmd = gson.fromJson(jsonMetaData, DeviceMetaData.class); metaDataCache.put(new StringBuilder().append(dp.Name).toString().trim(), metadata); } ApplianceChannelSelector selector = null; try { selector = getValueSelectorFromMieleID(dp.Name); } catch (Exception h) { logger.trace("{} is not a valid channel for a {}", dp.Name, modelID); } String dpValue = StringUtils.trim(StringUtils.strip(dp.Value)); if (selector != null) { if (!selector.isProperty()) { ChannelUID theChannelUID = new ChannelUID(getThing().getUID(), selector.getChannelID()); if (dp.Value != null) { logger.trace("Update state of {} with getState '{}'", theChannelUID, selector.getState(dpValue, dmd)); updateState(theChannelUID, selector.getState(dpValue, dmd)); } else { updateState(theChannelUID, UnDefType.UNDEF); } } else if (dpValue != null) { logger.debug("Updating the property '{}' of '{}' to '{}'", selector.getChannelID(), getThing().getUID(), selector.getState(dpValue, dmd).toString()); Map<String, String> properties = editProperties(); properties.put(selector.getChannelID(), selector.getState(dpValue, dmd).toString()); updateProperties(properties); } } } catch (IllegalArgumentException e) { logger.error("An exception occurred while processing a changed device property :'{}'", e.getMessage()); } } }
From source file:org.openhab.binding.plugwise.internal.PlugwiseGenericBindingProvider.java
private void parseAndAddBindingConfig(Item item, String bindingConfigs) throws BindingConfigParseException { String bindingConfig = StringUtils.substringBefore(bindingConfigs, ","); String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ","); PlugwiseBindingConfig newConfig = new PlugwiseBindingConfig(); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig);//from w w w . j a v a2s. co m while (StringUtils.isNotBlank(bindingConfigTail)) { bindingConfig = StringUtils.substringBefore(bindingConfigTail, ","); bindingConfig = StringUtils.strip(bindingConfig); bindingConfigTail = StringUtils.substringAfter(bindingConfig, ","); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig); } }
From source file:org.openhab.binding.sonos.internal.SonosGenericBindingProvider.java
private void parseAndAddBindingConfig(Item item, String bindingConfigs) throws BindingConfigParseException { String bindingConfig = StringUtils.substringBefore(bindingConfigs, ","); String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ","); SonosBindingConfig newConfig = new SonosBindingConfig(); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig);/*from w w w . j av a2s . c o m*/ while (StringUtils.isNotBlank(bindingConfigTail)) { bindingConfig = StringUtils.substringBefore(bindingConfigTail, ","); bindingConfig = StringUtils.strip(bindingConfig); bindingConfigTail = StringUtils.substringAfter(bindingConfigTail, ","); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig); } }