List of usage examples for org.apache.commons.lang StringUtils trimToNull
public static String trimToNull(String str)
Removes control characters (char <= 32) from both ends of this String returning null
if the String is empty ("") after the trim or if it is null
.
From source file:com.bluexml.xforms.actions.AbstractAction.java
/** * Sets useful properties.//from w ww .j a v a2 s. c om * * @param controller * the controller * @param uri * the uri */ public void setProperties(AlfrescoController controller, String uri) { URI realUri; try { realUri = new URI(uri); } catch (URISyntaxException e) { throw new RuntimeException(e); } String[] fragments = realUri.getSchemeSpecificPart().split("/"); getRequestParameters(fragments, realUri); this.controller = controller; this.uri = uri; this.transaction = new AlfrescoTransaction(controller, transactionLogin); this.transaction.setPage(navigationPath.peekCurrentPage()); if (StringUtils.trimToNull(transactionLogin) == null) { // no CAS receipt was available Map<String, String> initParams = transaction.getPage().getInitParams(); transaction.setLogin(controller.getParamUserName(initParams)); } }
From source file:com.opengamma.core.historicaltimeseries.impl.NonVersionedRedisHistoricalTimeSeriesSource.java
protected String toRedisKey(UniqueId uniqueId, LocalDate simulationExecutionDate) { StringBuilder sb = new StringBuilder(); String redisPrefix = StringUtils.trimToNull(getRedisPrefix()); if (redisPrefix != null) { sb.append(getRedisPrefix());//ww w . j av a 2s. c o m sb.append(':'); } sb.append(LocalDateDoubleTimeSeries.class.getSimpleName()); sb.append(':'); sb.append(uniqueId); if (simulationExecutionDate != null) { sb.append(':'); sb.append(simulationExecutionDate.toString()); } return sb.toString(); }
From source file:mitm.application.djigzo.impl.DLPPropertiesImpl.java
@Override public String[] getDLPManagers() throws HierarchicalPropertiesException { String[] emails = null;// w ww.jav a 2 s . co m String list = StringUtils.trimToNull(getProperty(getFullPropertyName(DLP_MANAGERS), PropertyRegistry.getInstance().isEncrypted(getFullPropertyName(DLP_MANAGERS)))); if (list != null) { emails = StringUtils.split(list, ','); } return emails; }
From source file:de.willuhn.jameica.hbci.passports.pintan.Controller.java
/** * Liefert eine Auswahl verfuegbarer Kartenleser-Bezeichnungen. * @return eine Auswahl verfuegbaren Kartenleser-Bezeichnungen. * @throws RemoteException//from ww w. ja v a 2 s . c om */ public SelectInput getCardReaders() throws RemoteException { if (this.cardReaders != null) return this.cardReaders; List<String> available = new ArrayList<String>(); // Erste Zeile Leerer Eintrag. // Damit das Feld auch dann leer bleiben kann, wenn der User nur einen // Kartenleser hat. Der sollte dann nicht automatisch vorselektiert // werden, da dessen Bezeichnung sonst unnoetigerweise hart gespeichert wird available.add(""); try { TerminalFactory terminalFactory = TerminalFactory.getDefault(); CardTerminals terminals = terminalFactory.terminals(); if (terminals != null) { List<CardTerminal> list = terminals.list(); if (list != null && list.size() > 0) { for (CardTerminal t : list) { String name = StringUtils.trimToNull(t.getName()); if (name != null) available.add(name); } } } } catch (Throwable t) { Logger.info("unable to determine card reader list: " + t.getMessage()); Logger.write(Level.DEBUG, "stacktrace for debugging purpose", t); } this.cardReaders = new SelectInput(available, this.getConfig().getCardReader()); this.cardReaders.setEditable(true); this.cardReaders.setComment(i18n.tr("nur ntig, wenn mehrere Leser vorhanden")); this.cardReaders.setName(i18n.tr("Identifier des PC/SC-Kartenlesers")); return this.cardReaders; }
From source file:com.edgenius.wiki.service.impl.RenderServiceImpl.java
@Override public List<RenderPiece> renderHTML(String target, String hostAppURL, AbstractPage page) { long s = 0;/*from w w w .jav a2 s.c o m*/ if (log.isDebugEnabled()) { s = System.currentTimeMillis(); } String spaceUname = page.getSpace().getUnixName(); //???does any case should check a special user? if so, need a User as input parameter for this page? boolean allowCreate = false; //indexing page - pure text is not necessary to fill security permission. if (spaceUname != null && !RenderContext.RENDER_TARGET_INDEX.equals(target)) { //if spaceUname must not be null in this case, but pageUuid could be null, but it will fill space security option only in this case. securityService.fillPageWikiOperations(WikiUtil.getUser(userReadingService), page); List<WikiOPERATIONS> perms = page.getWikiOperations(); for (WikiOPERATIONS wikiOPERATIONS : perms) { if (OPERATIONS.WRITE.equals(wikiOPERATIONS.operation)) { allowCreate = true; break; } } } if (log.isDebugEnabled()) { log.debug("Render service fill page security takes :" + (System.currentTimeMillis() - s) + "ms"); } String wikiText = ""; boolean phaseRender = false; if (page.getPhaseContent() != null) { //phase part content render phaseRender = true; wikiText = page.getPhaseContent(); } else { if (page instanceof Page) { wikiText = ((Page) page).getContent().getContent(); } else if (page instanceof Draft) { wikiText = ((Draft) page).getContent().getContent(); } else if (page instanceof History) { wikiText = ((History) page).getContent().getContent(); } } if (wikiText == null) wikiText = ""; //if whole page content render - need embed it into theme - it is not suitable for phase part render... if (spaceUname != null && !phaseRender) { //get out space Theme content, and merge with page render markup Theme theme = themeService.getPageTheme(page, WikiUtil.isHomepage(page) ? PageTheme.SCOPE_HOME : PageTheme.SCOPE_DEFAULT); String body = theme.getCurrentPageTheme().getBodyMarkup(); if (!StringUtils.isBlank(body)) { if (body.indexOf(Theme.BODY_PLACEHOLDER) != -1) { wikiText = body.replace(Theme.BODY_PLACEHOLDER, wikiText); } else { //if missing Theme.BODY_PLACEHOLDER, then just append page render markup after body wikiText = body + wikiText; } } } //initial render context for this time render call RenderContext renderContext = new RenderContextImpl(); ((RenderContextImpl) renderContext).setRenderEngine(renderEngine); ((RenderContextImpl) renderContext).setPage(page); ((RenderContextImpl) renderContext).setPageContent(wikiText); ((RenderContextImpl) renderContext).setSpaceUname(spaceUname); ((RenderContextImpl) renderContext).setPageTitle(page.getTitle()); ((RenderContextImpl) renderContext).setPageUuid(page.getPageUuid()); ((RenderContextImpl) renderContext).setTarget(target); hostAppURL = StringUtils.trimToNull(hostAppURL); if (hostAppURL != null && !hostAppURL.endsWith("/")) hostAppURL += "/"; ((RenderContextImpl) renderContext).setHostAppURL(hostAppURL); ((RenderContextImpl) renderContext).setPageVisibleAttachments(page.getVisibleAttachmentNodeList()); //initial wiki page link engine LinkRenderHelper linkRenderHelper = new LinkRenderHelperImpl(); linkRenderHelper.initialize(renderContext, spaceDAO, pageDAO); linkRenderHelper.setSpaceUname(spaceUname); linkRenderHelper.setAllowCreate(allowCreate); ((RenderContextImpl) renderContext).setLinkRenderHelper(linkRenderHelper); //start render List<RenderPiece> pieces = renderEngine.render(wikiText, renderContext); //set Piece to page: It is not good practice, but it is easy to save time... page.setRenderPieces(pieces); if (log.isDebugEnabled()) { log.debug("Render service complete takes :" + (System.currentTimeMillis() - s) + "ms"); } return pieces; }
From source file:com.thihy.jacoco.data.BundleCoverageDataReader.java
private IClassCoverage readClassCoverage(String packageName) { try {/* www . j av a 2s. c o m*/ // byte blocktype; // if ((blocktype = in.readByte()) != BundleCoverageDataWriter.BLOCK_CLASS_COVERAGE_DATA) { // throw new IOException(format("Unknown block type %x.", Byte.valueOf(blocktype))); // } ISourceNode sourceNode = readSourceNode(); long id = in.readLong(); String signature = StringUtils.trimToNull(in.readUTF()); String superName = StringUtils.trimToNull(in.readUTF()); int interfaceNamesLength = in.readVarInt(); String[] interfaceNames = new String[interfaceNamesLength]; for (int i = 0; i < interfaceNamesLength; ++i) { interfaceNames[i] = in.readUTF(); } if (false) { // String packageName = in.readUTF(); } String sourceFileName = in.readUTF(); int methodCoveragesSize = in.readVarInt(); Collection<IMethodCoverage> methodCoverages = new ArrayList<IMethodCoverage>(methodCoveragesSize); for (int i = 0; i < methodCoveragesSize; ++i) { methodCoverages.add(readMethodCoverage()); } return new ClassCoverage(sourceNode, packageName, id, signature, superName, interfaceNames, methodCoverages, sourceFileName); } catch (final IOException e) { throw new RuntimeException(e); } }
From source file:com.bluexml.xforms.controller.navigation.NavigationManager.java
/** * Adds the actions.//from ww w . ja v a 2s . c o m * * @param actionsDocument * the actions document * @param classes * the classes * @deprecated */ @Deprecated @SuppressWarnings("unused") private void addActions(Document actionsDocument, List<Class<?>> classes) { NodeList actionNodes = actionsDocument.getDocumentElement().getChildNodes(); for (int i = 0; i < actionNodes.getLength(); i++) { Node item = actionNodes.item(i); if (item instanceof Element) { Element action = (Element) item; if (action.getTagName().equals("action")) { String className = null; NodeList childNodes = action.getChildNodes(); for (int j = 0; j < childNodes.getLength(); j++) { Node childNode = childNodes.item(j); if (childNode instanceof Element) { Element subElement = (Element) childNode; if (subElement.getTagName().equals("class")) { className = StringUtils.trimToNull(subElement.getTextContent()); } } } if (className != null) { try { Class<?> actionClassName = Class.forName(className); classes.add(actionClassName); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error(e); } } } } } } }
From source file:$.MessageLogParser.java
@Nullable private String getRequestId(String line) { // 2013-05-23 20:22:36,754 [MACHINE_IS_UNDEFINED, ajp-bio-8009-exec-19, /esb/ws/account/v1, 10.10.0.95:72cab819:13ecdbd371c:-7eff, ] DEBUG String logHeader = StringUtils.substringBetween(line, "[", "]"); if (logHeader == null) { // no match - the line doesn't contain [] return null; }/* w ww. j a v a 2 s. c o m*/ String[] headerParts = StringUtils.split(logHeader, ","); String requestId = StringUtils.trim(headerParts[3]); // note: if request starts from scheduled job, then there is request ID information // 2013-05-27 16:37:25,633 [MACHINE_IS_UNDEFINED, DefaultQuartzScheduler-camelContext_Worker-8, , , ] // WARN c.c.c.i.c.a.d.RepairMessageServiceDbImpl${symbol_dollar}2 - The message (msg_id = 372, correlationId = ... return StringUtils.trimToNull(requestId); }
From source file:com.opengamma.web.region.WebRegionResource.java
@PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces(MediaType.APPLICATION_JSON)//from ww w . j a va 2 s . co m public Response putJSON(@FormParam("name") String name, @FormParam("fullname") String fullName, @FormParam("classification") String classification, @FormParam("country") String countryISO, @FormParam("currency") String currencyISO, @FormParam("timezone") String timeZoneId) { if (data().getRegion().isLatest() == false) { // TODO: idempotent return Response.status(Status.FORBIDDEN).entity(getHTML()).build(); } name = StringUtils.trimToNull(name); fullName = StringUtils.trimToNull(fullName); countryISO = StringUtils.trimToNull(countryISO); currencyISO = StringUtils.trimToNull(currencyISO); timeZoneId = StringUtils.trimToNull(timeZoneId); RegionClassification regionClassification = safeValueOf(RegionClassification.class, classification); if (name == null || regionClassification == null) { return Response.status(Status.BAD_REQUEST).build(); } if (fullName == null) { fullName = name; } updateRegion(name, fullName, regionClassification, countryISO, currencyISO, timeZoneId); return Response.ok().build(); }
From source file:com.bluexml.side.Workflow.modeler.diagram.dialogs.ActionEditDialog.java
protected TabItem createScriptTab(TabFolder parent) { // Create tab item and add it composite that fills it final TabItem scriptItem = new TabItem(parent, SWT.NONE); scriptItem.setText("General"); Composite composite = new Composite(parent, SWT.NONE); scriptItem.setControl(composite);// w w w . ja va 2 s . com composite.setLayout(new GridLayout(1, false)); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); if (inEnterpriseVersion()) { javaClass = new Combo(composite, SWT.NULL); javaClass.setItems(defaultsJavaClasses.toArray(new String[] {})); javaClass.setText(javaClassTxt); } scriptButton = new Button(composite, SWT.CHECK); scriptButton.setText("script ?"); scriptButton.setSelection(script); scriptButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (scriptButton.getSelection()) { script = true; createAttributesTabItem(tabFolder); } else { script = false; if (secondItem != null) { secondItem.dispose(); secondItem = null; } } } public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); scriptTxt = new Text(composite, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER); scriptTxt.setLayoutData(new GridData(GridData.FILL_BOTH)); if (StringUtils.trimToNull(expression) != null) { scriptTxt.setText(expression); } return scriptItem; }