本文整理汇总了Java中com.ibm.commons.util.StringUtil类的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtil类属于com.ibm.commons.util包,在下文中一共展示了StringUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
/**
* Send PUT request with authorization header
* @param url - The url of the POST request
* @param auth - String for authorization header
* @param putData - The body of the PUT
*/
public Response put(String url, String auth, JsonJavaObject putData) throws URISyntaxException, IOException, JsonException {
URI normUri = new URI(url).normalize();
Request putRequest = Request.Put(normUri);
//Add auth header
if(StringUtil.isNotEmpty(auth)) {
putRequest.addHeader("Authorization", auth);
}
//Add put data
String putDataString = JsonGenerator.toJson(JsonJavaFactory.instanceEx, putData);
if(putData != null) {
putRequest = putRequest.bodyString(putDataString, ContentType.APPLICATION_JSON);
}
Response response = executor.execute(putRequest);
return response;
}
示例2: post
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
/**
* Send POST request with authorization header and additional headers
* @param url - The url of the POST request
* @param auth - String for authorization header
* @param headers - Hashmap of headers to add to the request
* @param postData - The body of the POST
* @return the Response to the POST request
*/
public Response post(String url, String auth, HashMap<String, String> headers, JsonJavaObject postData) throws JsonException, IOException, URISyntaxException {
URI normUri = new URI(url).normalize();
Request postRequest = Request.Post(normUri);
//Add all headers
if(StringUtil.isNotEmpty(auth)) {
postRequest.addHeader("Authorization", auth);
}
if(headers != null && headers.size() > 0){
for (Map.Entry<String, String> entry : headers.entrySet()) {
postRequest.addHeader(entry.getKey(), entry.getValue());
}
}
String postDataString = JsonGenerator.toJson(JsonJavaFactory.instanceEx, postData);
Response response = executor.execute(postRequest.bodyString(postDataString, ContentType.APPLICATION_JSON));
return response;
}
示例3: preRenderTree
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
@Override
protected void preRenderTree(final FacesContext context, final ResponseWriter writer, final TreeContextImpl tree) throws IOException {
// Add the JS support if necessary
if(isExpandable()) {
UIViewRootEx rootEx = (UIViewRootEx) context.getViewRoot();
rootEx.setDojoTheme(true);
//ExtLibResources.addEncodeResource(rootEx, BootstrapResources.bootstrapNavigator);
// Specific dojo effects
String effect = getExpandEffect();
if(StringUtil.isNotEmpty(effect)) {
rootEx.addEncodeResource(ExtLibResources.dojoFx);
ExtLibResources.addEncodeResource(rootEx, ExtLibResources.dojoFx);
}
}
super.preRenderTree(context, writer, tree);
}
示例4: initProject
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
public void initProject() {
props = (XSPAllProperties)leftComposite.getDataNode().getCurrentObject();
overrideNotes.setSelection((props.getThemeNotes().length() > 0));
overrideWeb.setSelection((props.getThemeWeb().length() > 0));
themeNotesCombo.setEnabled(overrideNotes.getSelection());
themeWebCombo.setEnabled(overrideWeb.getSelection());
String mobilePrefix = props.getMobilePrefix();
if(StringUtil.isEmpty(mobilePrefix)){
setMobileControlsState(false, true);
} else {
setMobileControlsState(true, true);
}
getDataNode().notifyInvalidate(null);
enableOptions();
enableErrorOptions();
}
示例5: installResources
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
public void installResources(Bundle bundle, String resPath) throws IOException {
// getEntry() do not look into fragment....
//URL url = bundle.getEntry(resPath);
URL url = FileLocator.find(bundle, new Path(resPath), null);
if(url==null) {
throw new IOException(StringUtil.format("Cannot find resources entry {0}",resPath)); // $NLX-ResourceInstaller.Cannotfindresourcesentry0-1$
}
ZipInputStream zin = new ZipInputStream(url.openStream());
for( ZipEntry ze=zin.getNextEntry(); ze!=null; ze=zin.getNextEntry() ) {
if(!ze.isDirectory()) {
//System.out.println("Copying resouce: "+ze.getName());
copyResource(zin,ze);
zin.closeEntry();
}
}
zin.close();
}
示例6: writeAuthorMeta
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
@Override
protected void writeAuthorMeta(final FacesContext context, final ResponseWriter w, final UIForumPost c, final UIComponent facet) throws IOException {
w.startElement("div", null); // div.name
String styleClass = (String)getProperty(PROP_AUTHORMETACLASS);
if(StringUtil.isNotEmpty(styleClass)) {
w.writeAttribute("class", styleClass, null);
}
String style = (String)getProperty(PROP_AUTHORMETASTYLE);
if(StringUtil.isNotEmpty(style)) {
w.writeAttribute("style", style, null);
}
FacesUtil.renderComponent(context, facet);
w.endElement("div");
}
示例7: generateImageURL
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
/**
* The only XSP tag that currently supports rendering an Image when used in a visualization is the xp:image tag.
* It has custom code to look for images from the library that contains the node being visualized, instead of
* looking in the Designer Project.
*
* For controls that need to display images (like buttons with specified images etc..) we need to give them a custom
* URL so that they can be found when the visualization is being displayed.
*
* The URL needs to take the format xsp://libraryId~~imageURL
* This will tell Designer to use the library with the given libraryID to find the image at the given imageURL.
*
* This method used the node being visualized to find the library associated with that Node, and uses that to
* generate the complete URL.
*
* @param node
* @param registry
* @param imageName
* @param imagesFolderLocation
* @return A complete URL in the form xsp://libraryId~~imageURL
*/
public String generateImageURL(Node node, FacesRegistry registry, String imageName, String imagesFolderLocation){
String id = "";
String imageURL = "";
if(null != registry && null != node){
FacesComponentDefinition def = registry.findComponent(node.getNamespaceURI(), node.getLocalName());
if(null != def){
FacesLibraryFragment fragment = def.getFile();
if(null != fragment){
FacesProject proj = fragment.getProject();
if(null != proj){
id = proj.getId();
}
}
}
}
if(StringUtil.isNotEmpty(id)){
imageURL = LIB_URL_START_STRING + id + LIB_URL_END_STRING + getURLForImage(imageName, imagesFolderLocation);
}
if(StringUtil.isNotEmpty(imageURL)){
return imageURL;
}
return getURLForImage(imageName, imagesFolderLocation);
}
示例8: writeSearchBox
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
protected void writeSearchBox(FacesContext context, ResponseWriter w, UIApplicationLayout c, BasicApplicationConfigurationImpl configuration, SearchBar searchBar, ITree tree, boolean options) throws IOException {
String cid = c.getClientId(context) + "_search"; // $NON-NLS-1$
w.startElement("input", c); // $NON-NLS-1$
w.writeAttribute("id", cid, null); // $NON-NLS-1$
w.writeAttribute("name", cid, null); // $NON-NLS-1$
w.writeAttribute("type", "text", null); // $NON-NLS-1$ $NON-NLS-2$
w.writeAttribute("class", "form-control search-query", null); // $NON-NLS-1$ $NON-NLS-2$
String inputTitle = searchBar.getInputTitle();
if (StringUtil.isNotEmpty(inputTitle)) {
w.writeAttribute("title", inputTitle, null); // $NON-NLS-1$
}
String inactiveText = searchBar.getInactiveText();
if (StringUtil.isNotEmpty(inactiveText)) {
w.writeAttribute("placeHolder", inactiveText, null); // $NON-NLS-1$
}
String submitSearch = "_xspAppSearchSubmit"; // $NON-NLS-1$
w.writeAttribute("onkeypress", "javascript:var kc=event.keyCode?event.keyCode:event.which;if(kc==13){"+submitSearch+"(); return false}",null); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
w.endElement("input"); // $NON-NLS-1$
newLine(w);
}
示例9: isToggleAction
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
private boolean isToggleAction(FacesContext context, UIDataSourceIterator component, String submitterId){
// The id must be an expand/collapse action
if (StringUtil.isNotEmpty(submitterId)) {
if( submitterId.contains(EXPAND_DELIMITER)
|| submitterId.contains(SHRINK_DELIMITER)
|| submitterId.contains(SHOW_DELIMITER)
|| submitterId.contains(HIDE_DELIMITER)
|| submitterId.contains(SORT_DELIMITER)) {
String parentId = component.getClientId(context);
if (submitterId.startsWith(parentId)) {
return true;
}
}
}
return false;
}
示例10: copyResource
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
private void copyResource(ZipInputStream zin, ZipEntry ze) throws IOException {
String resourcePath = ze.getName();
String targetFileName = StringUtil.replace(resourcePath, '/', File.separatorChar);
File targetFile = new File(installDirectory,targetFileName);
File targetDir = targetFile.getParentFile();
targetDir.mkdirs();
// Add it to the file list
writer.write(resourcePath);
writer.newLine();
OutputStream os = new FileOutputStream(targetFile);
try {
StreamUtil.copyStream(zin, os);
} finally {
os.close();
}
}
示例11: writeSlideHeading
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
public void writeSlideHeading(FacesContext context, ResponseWriter w, UICarousel c, SlideNode slide, String headingText) throws IOException {
if(StringUtil.isNotEmpty(headingText)) {
String headingStyle = slide.getHeadingStyle();
String headingClass = slide.getHeadingStyleClass();
String headingTag = slide.getHeadingTag();
String tag = StringUtil.isNotEmpty(headingTag) ? headingTag : (String)getProperty(PROP_SLIDE_HEADING_TAG);
w.startElement(tag, c);
String classMixin = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_SLIDE_HEADING_CLASS), headingClass);
if(StringUtil.isNotEmpty(classMixin)) {
w.writeAttribute("class", classMixin, null); // $NON-NLS-1$
}
String styleMixin = ExtLibUtil.concatStyleClasses((String)getProperty(PROP_SLIDE_HEADING_STYLE), headingStyle);
if(StringUtil.isNotEmpty(styleMixin)) {
w.writeAttribute("style", styleMixin, null); // $NON-NLS-1$
}
//write the heading text
w.writeText(headingText, null);
// end img tag
w.endElement(tag);
}
}
示例12: writeFormRowHelp
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
@Override
protected void writeFormRowHelp(FacesContext context, ResponseWriter w, FormLayout c, UIFormLayoutRow row, UIInput edit) throws IOException {
String helpId = row.getHelpId();
String helpStyle = (String)getProperty(PROP_HELPROWSTYLE);
if(StringUtil.isNotEmpty(helpStyle)) {
w.writeAttribute("style", helpStyle, null); // $NON-NLS-1$
}
if(StringUtil.isNotEmpty(helpId)) {
String forClientId = null;
UIComponent forComponent = FacesUtil.getComponentFor(c, helpId);
if(forComponent == null) {
UIComponent p = (UIComponent)FacesUtil.getNamingContainer(c);
if(p!=null) {
forClientId = p.getClientId(context)+":"+helpId;
}
} else {
forClientId = forComponent.getClientId(context);
}
writeFormRowDataHelp(context, w, c, row, edit, forClientId);
} else {
UIComponent facet = row.getFacet(UIFormLayoutRow.FACET_HELP);
if(facet!=null) {
writeFormRowDataHelpFacet(context, w, c, row, edit, facet);
}
}
}
示例13: loadView
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
protected void loadView() throws NotesException {
ViewParameters parameters = getParameters();
Database db = getDatabase(parameters);
String viewName = parameters.getViewName();
if(StringUtil.isEmpty(viewName)) {
if(defaultView==null) {
throw new IllegalStateException("No default view assigned to the service"); // $NLX-RestViewService.Nodefaultviewassignedtotheservice-1$
}
this.view = defaultView;
this.view.setAutoUpdate(false);
this.shouldRecycleView = false;
return;
}
this.view = db.getView(viewName);
if(view==null) {
throw new NotesException(0,StringUtil.format("Unknown view {0} in database {1}",viewName,db.getFileName())); // $NLX-RestViewService.Unknownview0indatabase1-1$
}
this.view.setAutoUpdate(false);
this.shouldRecycleView = true;
}
示例14: checkForExternalChange
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
private void checkForExternalChange() {
// Check has the file been externally modified
if (_bean.externallyModified()) {
// Only do this once per change
_bean.resetModifiedTime();
// Ask the reload question
String msg = "The file '{0}' has been changed on the file system. Do you wish to replace the editor contents with these changes?"; // $NLX-ManifestMultiPageEditor.Thefile0hasbeenchangedonthefilesy-1$
if (MessageDialog.openQuestion(null, "File changed", StringUtil.format(msg, _bean.getFileName()))) { // $NLX-ManifestMultiPageEditor.Filechanged-1$
// Reload the file
_srcEditor.doRevertToSaved();
// Make sure the contents are reflected in the editor
pageChange(getActivePage());
} else {
// User has chosen not to reload - show editor as "dirty"
_srcEditor.setExternallyModified(true);
firePropertyChange(IEditorPart.PROP_DIRTY);
}
}
}
示例15: findConnection
import com.ibm.commons.util.StringUtil; //导入依赖的package包/类
protected Connection findConnection() throws SQLException {
if(StringUtil.isNotEmpty(connectionUrl)) {
return DriverManager.getConnection(connectionUrl);
}
if(StringUtil.isNotEmpty(connectionName)) {
return JdbcUtil.createNamedConnection(FacesContext.getCurrentInstance(), connectionName);
}
if(StringUtil.isNotEmpty(connectionManager)) {
return JdbcUtil.createManagedConnection(FacesContext.getCurrentInstance(),getDataSource()!=null?getDataSource().getComponent():null,connectionManager);
}
// Note, this resource key is used in other places in this plugin
String msg = "No \"connectionManager\", \"connectionName\" or \"connectionUrl\" is provided"; // $NLX-JdbcDataBlockAccessor.No01or2isprovided-1$
// "No \"connectionManager\", \"connectionName\" or \"connectionUrl\" is provided"
//String msg = com.ibm.xsp.extlib.relational.ResourceHandler.getSpecialAudienceString("JdbcDataBlockAccessor.No01or2isprovided"); //$NON-NLS-1$
throw new SQLException(msg);
}