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


Java ArrayUtils.toString方法代码示例

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


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

示例1: createFeatureType

import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
private static SimpleFeatureType createFeatureType(Class geomClass,AttributesGeometry attr) {

        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
        builder.setName("Location");
        builder.setCRS(DefaultGeographicCRS.WGS84); // <- Coordinate reference system

        // add attributes in order
        builder.add(geomClass.getSimpleName(), geomClass);
        builder.length(15).add("Name", String.class); // <- 15 chars width for name field
        builder.add("Number", Integer.class);

        //aggiungo tutti gli altri attributi allo schema
        if(attr!=null){
	        String[]schema= attr.getSchema();
	        for(int i=0;i<schema.length;i++){
	        	Object val=attr.get(schema[i]);
	        	if(val!=null){
		        	if(val.getClass().isArray()){
		        		String valArray=ArrayUtils.toString(val);
		        		builder.add(schema[i],valArray.getClass());
		        	}else{
		        		builder.add(schema[i],val.getClass());
		        	}
	        	}	
	        }
        }

        // build the type
        final SimpleFeatureType ft = builder.buildFeatureType();

        return ft;
    }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:33,代码来源:SimpleShapefile.java

示例2: checkPerms

import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
public boolean checkPerms(String userId, String locationId, String[] perms) {
    // NOTE: we needed to put this here to allow permissions checks from the kaltura API service
    if (perms == null || perms.length <= 0) {
        throw new IllegalArgumentException("perms ("+ArrayUtils.toString(perms)+") must be set");
    }
    if (userId == null || "".equals(userId)) {
        userId = getCurrentUserId();
        if (userId == null || "".equals(userId)) {
            throw new IllegalArgumentException("userId ("+userId+") must be set");
        }
    }
    if (locationId == null || "".equals(locationId)) {
        locationId = getCurrentLocationId();
        if (locationId == null || "".equals(locationId)) {
            throw new IllegalArgumentException("location ("+locationId+") must be set");
        }
    }
    boolean allowed = false;
    if ( isUserAdmin(userId) ) {
        // the system super user can do anything
        allowed = true;
    } else {
        for (int i = 0; i < perms.length; i++) {
            if (perms[i] != null && isUserAllowedInLocation(userId, perms[i], locationId)) {
                allowed = true;
                break;
            }
        }
    }
    return allowed;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:32,代码来源:SakaiExternalLogicImpl.java

示例3: checkPermsOrException

import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
 * Checks the permissions for the current user and returns the current user id
 * @param perms the permissions to check
 * @param locationId the location id (null for current location)
 * @return the current user ID
 * @throws SecurityException if the user is not allowed
 * @throws IllegalArgumentException if perm or location are null
 */
private String checkPermsOrException(String[] perms, String locationId) {
    String userId = external.getCurrentUserId();
    if (locationId == null || "".equals(locationId)) {
        locationId = external.getCurrentLocationId();
    }
    if (! external.checkPerms(userId, locationId, perms) ) {
        throw new SecurityException("user ("+userId+") is not allowed for ("+ArrayUtils.toString(perms)+") in location ("+locationId+")");
    }
    return userId;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:19,代码来源:MediaService.java

示例4: getPlaylistsInCategoryIds

import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
 * Get all playlists associated with given category ids
 * 
 * @param categoryIds category IDs in which to search for playlists
 * @return ArrayList of KalturaPlaylist objects or empty if no playlists are found
 * @throws IllegalArgumentException if category ids is null or empty
 * @throws RuntimeException if there is a failure looking up the playlists
 */
protected List<KalturaPlaylist> getPlaylistsInCategoryIds(String... categoryIds) {
    if (categoryIds == null || categoryIds.length <= 0) {
        throw new IllegalArgumentException("category ids must be set and contain at least one category id");
    }
    if (log.isDebugEnabled()) log.debug("getPlaylistsInCategoryIds(categoryIds="+ArrayUtils.toString(categoryIds)+")");
    List<KalturaPlaylist> kalturaPlaylists = new ArrayList<KalturaPlaylist>(0);
    if (isOfflineMode()) {
        // generate 4 fake playlists
        kalturaPlaylists.add( makeSampleKP(1111+"", 4) );
        kalturaPlaylists.add( makeSampleKP(2222+"", 0) );
        kalturaPlaylists.add( makeSampleKP(3333+"", 3) );
        kalturaPlaylists.add( makeSampleKP(4444+"", 1) );
    } else {
        KalturaClient kc = getKalturaClient(KS_PERM_ADMIN);
        KalturaPlaylistService playlistService = kc.getPlaylistService();
        KalturaPlaylistFilter filter = new KalturaPlaylistFilter();
        // create comma-separated string of category IDs from ArrayList
        String categoriesIds = StringUtils.join(categoryIds, ",");
        filter.categoriesIdsMatchOr = categoriesIds;
        try {
            KalturaFilterPager pager = new KalturaFilterPager();
            pager.pageSize = MAX_ENTRIES_PER_REQUEST; // max items returned is 30 without a pager
            KalturaPlaylistListResponse listResponse = playlistService.list(filter, pager);
            kalturaPlaylists = listResponse.objects;
        } catch (Exception e) {
            String msg = "An error occurred while searching for playlists in categories: " + ArrayUtils.toString(categoryIds) + ": "+e;
            log.error(msg, e);
            throw new RuntimeException(msg, e);
        }
    }
    return kalturaPlaylists;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:41,代码来源:KalturaAPIService.java

示例5: exportGeometriesToShapeFile

import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
/**
 *
 * @param geoms
 * @param fileOutput
 * @param geomType
 * @param transform
 * @throws IOException
 * @throws SchemaException
 */
public static void exportGeometriesToShapeFile(final List<Geometry> geoms,
	 File fileOutput,String geomType,GeoTransform transform,
	 SimpleFeatureType featureType) throws IOException, SchemaException{

 FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory();
 //Map map = Collections.singletonMap( "url", fileOutput.toURI().toURL() );
 DataStore data = factory.createDataStore( fileOutput.toURI().toURL() );
 boolean addAttr=true;
 if(featureType==null){
	 featureType=DataUtilities.createType( "the_geom", "geom:"+geomType+",name:String,age:Integer,description:String" );
	 addAttr=false;
 }
 data.createSchema( featureType );

 Transaction transaction = new DefaultTransaction();
    FeatureWriter<SimpleFeatureType, SimpleFeature> writer = data.getFeatureWriterAppend(data.getTypeNames()[0], transaction);

    SimpleFeatureBuilder featureBuilder=new SimpleFeatureBuilder(featureType);
    GeometryFactory gb=new GeometryFactory();
    try {
     int fid=0;
     for(final Geometry g:geoms){
    	 Geometry clone=gb.createGeometry(g);
    	 if(transform!=null)
    		 clone=transform.transformGeometryGeoFromPixel(clone);

    	 featureBuilder.add("the_geom");
    	 featureBuilder.add(clone);
    	 SimpleFeature sf=featureBuilder.buildFeature(""+fid++);
    	 SimpleFeature sfout=writer.next();
    	 sfout.setAttributes( sf.getAttributes() );
         //setting attributes geometry
       	 AttributesGeometry att=(AttributesGeometry) g.getUserData();
       	 try{
        	 if(att!=null&&addAttr){
         	 String sch[]=att.getSchema();
         	 for(int i=0;i<sch.length;i++){
         		 Object val=att.get(sch[i]);
         		 if(val.getClass().isArray()){
         			 Object o=ArrayUtils.toString(val);
         			 sfout.setAttribute(sch[i], o);
         		 }else{
         			 sfout.setAttribute(sch[i], val);
         		 }
         	 }
        	 }
       	 }catch(Exception e ){
       		 logger.warn("Error adding attributes to geometry:"+e.getMessage());
       	 }

         sfout.setDefaultGeometry( clone);
    	 writer.write();
	 }
     transaction.commit();
     logger.info("Export to shapefile complete:"+ fileOutput.getAbsolutePath());
    } catch (Exception problem) {
        problem.printStackTrace();
        transaction.rollback();
        logger.error("Export to shapefile failed",problem );
    } finally {
        writer.close();
        transaction.close();
        data.dispose();
    }

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:76,代码来源:SimpleShapefile.java

示例6: run

import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
void run(String[] arguments) throws Exception
{

    String migrationSystemName = ConfigurationUtil.getRequiredParam("migration.systemname",
            System.getProperties(), arguments, 0);
    String migrationSettings = ConfigurationUtil.getOptionalParam("migration.settings", System
            .getProperties(), arguments, 1);

    boolean isRollback = false;
    int[] rollbackLevels = new int[]{};
    boolean forceRollback = false;

    for (int i = 0; i < arguments.length; i++)
    {
        String argument1 = arguments[i];

        if (ROLLBACK.equals(argument1))
        {
            isRollback = true;

            if (i + 2 <= arguments.length)
            {
                String argument2 = arguments[i + 1];

                if (argument2 != null)
                {
                    try
                    {
                        rollbackLevels = getRollbackLevels(argument2);
                    }
                    catch (NumberFormatException nfe)
                    {
                        throw new MigrationException("The rollbacklevels should be integers separated by a comma");
                    }
                }
            }

            if (rollbackLevels.length == 0)
            {
                // this indicates that the rollback level has not been set
                throw new MigrationException(
                        "The rollback flag requires a following integer parameter or a list of integer parameters separated by comma to indicate the rollback level(s).");
            }
        }

        if (FORCE_ROLLBACK.equals(argument1))
        {
            forceRollback = true;
        }

    }

    // The MigrationLauncher is responsible for handling the interaction
    // between the PatchTable and the underlying MigrationTasks; as each
    // task is executed, the patch level is incremented, etc.
    try
    {

        if (isRollback)
        {
            String infoMessage = "Found rollback flag. AutoPatch will attempt to rollback the system to patch level(s) "
                    + ArrayUtils.toString(rollbackLevels) + ".";
            log.info(infoMessage);

            migrationUtil.doRollbacks(migrationSystemName, migrationSettings, rollbackLevels, forceRollback);
        }
        else
        {
            migrationUtil.doMigrations(migrationSystemName, migrationSettings);
        }
    }
    catch (Exception e)
    {
        log.error(e);
        throw e;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:78,代码来源:StandaloneMigrationLauncher.java

示例7: selectMockRuleResults

import org.apache.commons.lang.ArrayUtils; //导入方法依赖的package包/类
@ResponseBody
@RequestMapping(value = "/selectMockRuleResults")
public String selectMockRuleResults(HttpServletRequest arg0, Boolean selectFlag) throws Exception {
    JSONObject object = new JSONObject();
    object.put("result", "success");
    String method = null;
    String result = null;
    try {
        Map<String, String> context = Maps.newLinkedHashMap();
        String serviceId = arg0.getParameter("serviceId");
        String mockTestIds = arg0.getParameter("mockTestIds");
        String[] mocks = mockTestIds.split(",");
        Integer[] integers = new Integer[mocks.length];
        for (int i = 0; i < mocks.length; i++) {
            integers[i] = Integer.valueOf(mocks[i]);
        }
        String mockRules = arg0.getParameter("mockRules");
        mockRules = URLDecoder.decode(mockRules, Charset.defaultCharset().toString());
        String[] params = mockRules.split("&");
        List<String> mockKeys = Lists.newArrayList();
        List<String> mockValus = Lists.newArrayList();
        List<String> mockTypes = Lists.newArrayList();
        for (int i = 0; i < params.length; i++) {
            String[] param = params[i].split("=");
            if (param[0].equals("mockTestKey")) {
                if (i > 0 && ArrayUtils.contains(intelChars, param[1])) {
                    throw new RuntimeException("KEY命名不能包含以下关键字:" + ArrayUtils.toString(intelChars));
                }
                mockKeys.add(param[1]);
            }
            if (param[0].equals("mockTestValue")) {
                mockValus.add(param[1]);
            }
            if (param[0].equals("mockTestType")) {
                mockTypes.add(param[1]);
            }
        }
        for (int i = 0; i < mockKeys.size(); i++) {
            context.put(mockKeys.get(i), mockValus.get(i));
        }
        method = context.remove("methodName");
        result = mockTestServiceImpl.testMockService(Integer.valueOf(serviceId), method, context, integers);
    } catch (Exception e) {
        object.put("result", "error");
        result = e.getMessage();
        e.printStackTrace();
    }
    object.put("context", result);
    return object.toJSONString();
}
 
开发者ID:tonyruiyu,项目名称:dubbo-mock,代码行数:51,代码来源:MockOperDefineController.java


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