List of usage examples for org.apache.commons.lang3 StringUtils startsWith
public static boolean startsWith(final CharSequence str, final CharSequence prefix)
Check if a CharSequence starts with a specified prefix.
null s are handled without exceptions.
From source file:org.kuali.kra.negotiations.lookup.NegotiationDaoOjb.java
@SuppressWarnings("unchecked") @Override/* w w w. ja v a 2 s. co m*/ public Collection<Negotiation> getNegotiationResults(Map<String, String> fieldValues) { Map<String, String> associationDetails = new HashMap<String, String>(); Iterator<Map.Entry<String, String>> iter = fieldValues.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, String> entry = iter.next(); if (StringUtils.startsWith(entry.getKey(), ASSOC_PREFIX)) { iter.remove(); if (!StringUtils.isEmpty(entry.getValue())) { associationDetails.put(entry.getKey().replaceFirst(ASSOC_PREFIX + ".", ""), entry.getValue()); } } } Collection<Negotiation> result = new ArrayList<Negotiation>(); if (!associationDetails.isEmpty()) { addListToList(result, getNegotiationsLinkedToAward(fieldValues, associationDetails)); addListToList(result, getNegotiationsLinkedToProposal(fieldValues, associationDetails)); addListToList(result, getNegotiationsLinkedToProposalLog(fieldValues, associationDetails)); addListToList(result, getNegotiationsUnassociated(fieldValues, associationDetails)); addListToList(result, getNegotiationsLinkedToSubAward(fieldValues, associationDetails)); } else { result = findCollectionBySearchHelper(Negotiation.class, fieldValues, false, false, null); } if (result != null && !result.isEmpty() && StringUtils.isNotBlank(fieldValues.get("negotiationAge"))) { try { result = filterByNegotiationAge(fieldValues.get("negotiationAge"), result); } catch (NumberFormatException e) { GlobalVariables.getMessageMap().putError(KRADConstants.DOCUMENT_ERRORS, RiceKeyConstants.ERROR_CUSTOM, new String[] { "Invalid Numeric Input: " + fieldValues.get("negotiationAge") }); result = new ArrayList<Negotiation>(); } } return result; }
From source file:org.kuali.kra.protocol.auth.UnitAclLoadServiceImpl.java
protected boolean isAccessListRole(Role role) { KimType type = systemAuthorizationService.getKimTypeInfoForRole(role); return (!StringUtils.startsWith(type.getName(), "Derived Role") && !StringUtils.startsWith(type.getName(), "Default")); }
From source file:org.kuali.kra.protocol.permission.PermissionsHelperBase.java
protected void addNonDerivedRoles(List<KeyValue> keyValues) { List<org.kuali.rice.kim.api.role.Role> kimRoles = getSortedKimRoles(roleType); for (org.kuali.rice.kim.api.role.Role kimRole : kimRoles) { String roleName = kimRole.getName(); if (!excludeRoles.contains(roleName) && (!displayNameMap.keySet().contains(roleName))) { KimType type = getSystemAuthorizationService().getKimTypeInfoForRole(kimRole); // filter out derived roles and default type roles if (!(StringUtils.startsWith(type.getName(), "Derived Role")) && !(StringUtils.startsWith(type.getName(), "Default"))) { KeyValue pair = new ConcreteKeyValue(roleName, roleName); keyValues.add(pair);//from ww w .ja v a 2 s . c om } } } }
From source file:org.maodian.flyingcat.netty.handler.XMLFragmentDecoder.java
@Override protected Object decode(ChannelHandlerContext ctx, String msg) throws Exception { if (StringUtils.endsWithAny(msg, INVALID_ELEMENT_TAILS)) { throw new XmppException(StreamError.RESTRICTED_XML).set("xml", msg); }//from w w w .j av a 2 s. c o m if (StringUtils.endsWith(msg, PROCESS_INSTRUCTION_TAIL) && !StringUtils.startsWith(msg, "<?xml ")) { throw new XmppException(StreamError.RESTRICTED_XML).set("xml", msg); } if (StringUtils.startsWithAny(msg, INVALID_ELEMENT_HEADS)) { throw new XmppException(StreamError.RESTRICTED_XML).set("xml", msg); } // always accept xml declaration to improve compability with some client if (StringUtils.startsWith(msg, "<?xml ")) { return msg; /*if (acceptXMLDeclaration) { acceptXMLDeclaration = false; return msg; } else { throw new XmppException("XML declaration has been already received before", StreamError.NOT_WELL_FORMED).set("xml", msg); }*/ } // deal with stream tag if (StringUtils.contains(msg, ":stream") && (StringUtils.contains(msg, "<") || StringUtils.contains(msg, "</"))) { if (depth != 0) { throw new XmppException("Stream Open/Close Tag can only be root element", StreamError.INVALID_XML); } return msg; } // deal with empty element at first level if (depth == 0 && StringUtils.endsWith(msg, "/>")) { return msg; } if (xml == null) { xml = new StringBuilder(msg); } else { xml.append(msg); } // deal with nested empty element if (StringUtils.endsWith(msg, "/>")) { return null; } if (StringUtils.contains(msg, "</")) { depth--; } else if (StringUtils.contains(msg, "<")) { depth++; } if (depth == 0) { String fragment = xml.toString(); xml = null; return fragment; } return null; }
From source file:org.maodian.flyingcat.netty.handler.XmppXMLStreamHandler.java
@Override public void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception { // discard xml declaration if (StringUtils.startsWith(msg, "<?xml ")) { return;//from ww w. j a va 2s .co m } // deal with </stream:stream> if (StringUtils.contains(msg, ":stream") && StringUtils.contains(msg, "</")) { xmppContext.destroy(); if (initCloseingStream) { log.info("Close Stream and underhood socket due to requested by server"); ctx.channel().close(); } else if (ctx.channel().isOpen()) { ctx.write("</stream:stream>").addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { log.info("Close Stream and underhood socket due to requested by client"); future.channel().close(); } }); } else { log.info( "Won't respond client's close stream request since the channel has been closed (may because ssl has been closed)"); } return; } xmppContext.parseXML(msg); }
From source file:org.metaeffekt.dcc.commons.spring.xml.CapabilityInheritanceBeanDefinitionPostProcessor.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { List<String> definitionNamesToProcess = new ArrayList<>(); String[] beanDefinitionNames = registry.getBeanDefinitionNames(); for (String definitionName : beanDefinitionNames) { if (StringUtils.startsWith(definitionName, DCCConfigurationBeanDefinitionParser.CAPABILITY_DEFINITION_NAME_PREFIX)) { definitionNamesToProcess.add(definitionName); // enrich BeanDefinition enrichBeanDefinition(registry, definitionName); }// w w w . j a va 2 s . c o m } for (String definitionNameToProcess : definitionNamesToProcess) { processInheritance(registry, definitionNameToProcess); } }
From source file:org.mitre.mpf.wfm.camel.operations.markup.MarkupStageSplitter.java
@Override public final List<Message> performSplit(TransientJob transientJob, TransientStage transientStage) throws Exception { List<Message> messages = new ArrayList<>(); int lastDetectionStageIndex = findLastDetectionStageIndex(transientJob.getPipeline()); hibernateMarkupResultDao.deleteByJobId(transientJob.getId()); for (int actionIndex = 0; actionIndex < transientStage.getActions().size(); actionIndex++) { int mediaIndex = 0; TransientAction transientAction = transientStage.getActions().get(actionIndex); for (TransientMedia transientMedia : transientJob.getMedia()) { if (transientMedia.isFailed()) { log.debug("Skipping '{}' - it is in an error state.", transientMedia.getId(), transientMedia.getLocalPath()); continue; } else if (!StringUtils.startsWith(transientMedia.getType(), "image") && !StringUtils.startsWith(transientMedia.getType(), "video")) { log.debug("Skipping Media {} - only image and video files are eligible for markup.", transientMedia.getId()); } else { List<Markup.BoundingBoxMapEntry> boundingBoxMapEntryList = createMap(transientJob.getId(), transientMedia, lastDetectionStageIndex, transientJob.getPipeline().getStages().get(lastDetectionStageIndex)) .toBoundingBoxMapEntryList(); Markup.MarkupRequest markupRequest = Markup.MarkupRequest.newBuilder().setMediaIndex(mediaIndex) .setTaskIndex(transientJob.getCurrentStage()).setActionIndex(actionIndex) .setMediaId(transientMedia.getId()) .setMediaType(Markup.MediaType.valueOf(StringUtils.upperCase( transientMedia.getType().substring(0, transientMedia.getType().indexOf('/'))))) .setRequestId(redis.getNextSequenceValue()) .setSourceUri(//from w w w . j av a 2 s. c o m new File(transientMedia.getLocalPath()).getAbsoluteFile().toURI().toString()) .setDestinationUri( boundingBoxMapEntryList.size() > 0 ? propertiesUtil .createMarkupPath(transientJob.getId(), transientMedia.getId(), getMarkedUpMediaExtensionForMediaType( transientMedia.getMediaType())) .toUri().toString() : propertiesUtil .createMarkupPath(transientJob.getId(), transientMedia.getId(), getFileExtension(transientMedia.getType())) .toUri().toString()) .addAllMapEntries(boundingBoxMapEntryList).build(); DefaultMessage message = new DefaultMessage(); // We will sort out the headers later. message.setHeader(MpfHeaders.RECIPIENT_QUEUE, String.format("jms:MPF.%s_%s_REQUEST", transientStage.getActionType(), transientAction.getAlgorithm())); message.setHeader(MpfHeaders.JMS_REPLY_TO, StringUtils.replace(MpfEndpoints.COMPLETED_MARKUP, "jms:", "")); message.setBody(markupRequest); messages.add(message); } mediaIndex++; } } return messages; }
From source file:org.nanoframework.orm.jedis.AbstractRedisClient.java
protected Map<String, String> info0(final String info) { final String[] attributes = info.split("\n"); final Map<String, String> decodeInfo = Maps.newLinkedHashMap(); for (final String attribute : attributes) { if (!StringUtils.isEmpty(StringUtils.trim(attribute)) && !StringUtils.startsWith(attribute, "#")) { final String[] keyvalue = attribute.substring(0, attribute.length() - 1).split(":"); if (keyvalue.length == 2) { final String key = keyvalue[0]; final String value = StringUtils.endsWith(keyvalue[1], "\r") ? StringUtils.substring(keyvalue[1], 0, keyvalue[1].length() - 1) : keyvalue[1];//from ww w.j av a 2 s . c o m decodeInfo.put(key, value); } else { decodeInfo.put(keyvalue[0], ""); } } } return decodeInfo; }
From source file:org.neo4art.importer.wikipedia.domain.WikipediaCategory.java
@Override public void setTitle(String title) { if (!StringUtils.startsWith(title, new Namespace().CATEGORY.getCanonicalName())) { title = new Namespace().CATEGORY.getCanonicalName() + ":" + title; }// ww w . jav a 2s . c o m super.setTitle(title); }
From source file:org.neo4art.importer.wikipedia.parser.util.WikipediaInfoboxParserUtils.java
/** * /*from w ww . ja va 2 s .com*/ * @param input * @return * @throws MalformedURLException */ public static URL parseAsURL(String input) throws MalformedURLException { URL result = null; if (!StringUtils.isBlank(input)) { String temp = input; temp = StringUtils.remove(temp, "{"); temp = StringUtils.remove(temp, "}"); if (StringUtils.indexOf(temp, "[") != -1) { temp = StringUtils.remove(temp, "["); temp = StringUtils.remove(temp, "]"); if (StringUtils.indexOf(temp, " ") != -1) { temp = StringUtils.substring(temp, 0, StringUtils.indexOf(temp, " ")); } } temp = StringUtils.remove(temp, "URL|"); temp = StringUtils.replace(temp, " ", "_"); if (!StringUtils.startsWith(temp, "http")) { if (StringUtils.startsWith(temp, "www")) { temp = "http://" + temp; } else { temp = "https://en.wikipedia.org/wiki/File:" + temp; } } temp = StringUtils.removeEnd(temp, "|"); result = new URL(temp); } return result; }