当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.abbreviate方法代码示例

本文整理汇总了Java中org.apache.commons.lang.StringUtils.abbreviate方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.abbreviate方法的具体用法?Java StringUtils.abbreviate怎么用?Java StringUtils.abbreviate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.StringUtils的用法示例。


在下文中一共展示了StringUtils.abbreviate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addCollection

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Add a new collection to the location (site) indicated
 * 
 * @param title the title for this collection
 * @param locationId the unique id of the location to place this collection in
 * @return the newly created media collection
 * @throws IllegalArgumentException  if the params are invalid
 * @throws SecurityException if the user does not have permissions
 */
public MediaCollection addCollection(String title, String locationId) {
    if (locationId == null) {
        locationId = external.getCurrentLocationId();
    }
    if (StringUtils.isBlank(locationId)) {
        throw new IllegalArgumentException("location must be set");
    }
    String ownerId = checkPermOrException(ExternalLogic.PERM_ADMIN, locationId);
    if (StringUtils.isBlank(ownerId)) {
        throw new IllegalArgumentException("ownerId must be set");
    }
    if (StringUtils.isBlank(title)) {
        throw new IllegalArgumentException("title must be set");
    }
    if (log.isDebugEnabled()) log.debug("addCollection(title=" + title + ", locationId=" + locationId + ")");
    title = StringUtils.abbreviate(title, 250); // max length 255
    MediaCollection mc = new MediaCollection(title, null, "1", null);
    Map<String, String> metadata = mc.extractMetadataMap();
    KalturaCategory siteCat = kalturaAPIService.getSiteCategory(locationId);
    KalturaPlaylist kp = kalturaAPIService.getOrAddKalturaPlaylist(siteCat.id, title, metadata);
    mc = new MediaCollection(kp, locationId, metadata);
    mc.setItems( new ArrayList<MediaItem>(0) );
    log.info("User ("+external.getCurrentUserId()+") added collection ("+mc.getId()+", "+mc.getTitle()+") to location ("+mc.getLocationId()+"): " + mc);
    return mc;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:35,代码来源:MediaService.java

示例2: makeSafePlaylistName

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * creates a playlist name that is <= 150 characters and is unique
 * 
 * @param playlistName the name of the playlist
 * @return the safe playlist name
 * @throws IllegalArgumentException if playlist name is invalid
 */
@NoProfile
protected String makeSafePlaylistName(String playlistName) {
    playlistName = StringUtils.trimToNull(playlistName);
    if (playlistName == null) {
        throw new IllegalArgumentException("playlistName cannot be null");
    }
    if (playlistName.length() > PLAYLIST_MAX_LENGTH) {
        playlistName = StringUtils.abbreviate(playlistName, CATEGORY_MAX_LENGTH);
        playlistName = playlistName.substring(0, CATEGORY_MAX_LENGTH-3) + RandomStringUtils.randomAlphanumeric(3);
    }
    return playlistName;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:20,代码来源:KalturaAPIService.java

示例3: populateDescription

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private DeviceDescription populateDescription(ISnmpSession session, Device device) {
    NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
                                                    session.getAddress().getHostAddress());
    try {
        session.walkDevice(networkDevice, Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(
                System.class)));

        com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System systemTree =
                (com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System)
                        networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
                                com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class));
        if (systemTree != null) {
            // TODO SNMP sys-contacts may be verbose; ONOS-GUI doesn't abbreviate fields neatly;
            // so cut it here until supported in prop displayer
            String manufacturer = StringUtils.abbreviate(systemTree.getSysContact(), 20);
            return new DefaultDeviceDescription(device.id().uri(), device.type(),
                                                manufacturer, UNKNOWN, UNKNOWN, UNKNOWN,
                                                device.chassisId(), (SparseAnnotations) device.annotations());
        }
    } catch (IOException ex) {
        throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:NetSnmpDeviceDescriptor.java

示例4: createProjectElement

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private Element createProjectElement(Document document, MobileApplication mobileApplication, String projectName) {
	Element projectElement = document.createElement("project");
	
	Element eProjectName = document.createElement("name");
	eProjectName.setTextContent(projectName);
	projectElement.appendChild(eProjectName);
	
	Element eApp = document.createElement("application");
	
	Element eAppName = document.createElement("name");
	String appName = mobileApplication.getApplicationName();
	if (appName.equals("")) {
		appName = projectName;
	}
	eAppName.setTextContent(appName);
	eApp.appendChild(eAppName);
	
	Element eAppDescr = document.createElement("descr");
	String descr = StringUtils.abbreviate(mobileApplication.getApplicationDescription(), 100);
	eAppDescr.setTextContent(descr);
	eApp.appendChild(eAppDescr);
	eApp.appendChild(document.createElement("platforms"));
	
	projectElement.appendChild(eApp);
	
	return projectElement;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:28,代码来源:GetStoreContent.java

示例5: makeSafeCategoryName

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * creates a category name that is <= 50 characters and is unique
 * 
 * @param categoryName the name of the category
 * @return the safe category name
 * @throws IllegalArgumentException if playlist name is invalid
 */
@NoProfile
protected String makeSafeCategoryName(String categoryName) {
    categoryName = StringUtils.trimToNull(categoryName);
    if (categoryName == null) {
        throw new IllegalArgumentException("categoryName cannot be null");
    }
    if (categoryName.length() > CATEGORY_MAX_LENGTH) {
        categoryName = StringUtils.abbreviate(categoryName, CATEGORY_MAX_LENGTH);
        categoryName = categoryName.substring(0, CATEGORY_MAX_LENGTH-3) + RandomStringUtils.randomAlphanumeric(3);
    }
    return categoryName;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:20,代码来源:KalturaAPIService.java

示例6: getCurrentGraphName

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private  String getCurrentGraphName()
{
	String graphName= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput().getName();
	graphName = StringUtils.remove(graphName, Constants.JOB_EXTENSION);
	graphName = StringUtils.abbreviate(graphName, 20);
	return graphName;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:8,代码来源:GraphPropertiesHandler.java


注:本文中的org.apache.commons.lang.StringUtils.abbreviate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。