當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。