當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject類代碼示例

本文整理匯總了Java中com.esri.arcgis.server.json.JSONObject的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject類的具體用法?Java JSONObject怎麽用?Java JSONObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JSONObject類屬於com.esri.arcgis.server.json包,在下文中一共展示了JSONObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSchema

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
@Override
public String getSchema() throws IOException, AutomationException {
    try {
        JSONObject mySOE = ServerUtilities.createResource(
                "My SOE", "A simple template server object extension", false, false);
        JSONArray subResourcesArray = new JSONArray();
        subResourcesArray.put(ServerUtilities.createResource("hello",
                "Hello resource", false, false));
        mySOE.put("resources", subResourcesArray);
        return mySOE.toString();
    } catch (JSONException e) {
        getLogger().debug(e.getMessage());
        return ServerUtilities.sendError(500,
                "Exception occurred: " + e.getMessage(), null);
    }
}
 
開發者ID:Esri,項目名稱:server-extension-java,代碼行數:17,代碼來源:MyServerObjectExtension.java

示例2: encodeResult

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
private static JSONArray encodeResult(MultiMeasureResult result)
{
    JSONArray jsonArray = new JSONArray();
    
    List<MeasureResult> resultValues = result.getValue();
    
    for (MeasureResult measureResult : resultValues) {
        JSONObject valueObject = new JSONObject();
        valueObject.put("StartTime", measureResult.getDateTimeBegin());
        valueObject.put("EndTime", measureResult.getDateTimeEnd());
        valueObject.put("Verification", measureResult.getVerification());
        valueObject.put("Validity", measureResult.getValidity());
        valueObject.put("Value", measureResult.getValue());
        jsonArray.put(valueObject);
    }

    return jsonArray;
}
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:19,代碼來源:JSONObservationEncoder.java

示例3: getSchema

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
/**
     * This method returns the resource hierarchy of a REST based SOE in JSON
     * format.
     */
    @Override
    public String getSchema() throws IOException, AutomationException
    {
        LOGGER.verbose("getSchema() is called...");

        JSONObject arcGisSos = ServerUtilities.createResource("DB_Analyzer_for_ArcGIS_SOS_Extension", "A_DBAnalyzer_for_the_SOS_extension_for_ArcGIS_Server", false, false);

        JSONArray operationArray = new JSONArray();
        
        JSONObject tableNamesObject = ServerUtilities.createResource("ReadTableNamesFromDB", "reads all table names from DB", false, false);
        JSONObject analyzeProcedureTableObject = ServerUtilities.createResource("AnalyzeTableUsingProperties", "analyzes a specified table", false, false);
        
//        operationArray.put(ServerUtilities.createOperation("ReadTableNamesFromDB", "db", "json", false));
        operationArray.put(ServerUtilities.createOperation("AnalyzeTable", "tableName", "json", false));
//        operationArray.put(ServerUtilities.createOperation("AnalyzeProcedureTable", "bla", "json", false));

        JSONArray resourceArray = new JSONArray();
        resourceArray.put(tableNamesObject);
        resourceArray.put(analyzeProcedureTableObject);

        arcGisSos.put("resources", resourceArray);
//        arcGisSos.put("operations", operationArray);

        return arcGisSos.toString();
    }
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:30,代碼來源:DBInspector.java

示例4: invokeProcedureQueryOperation

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
protected byte[] invokeProcedureQueryOperation(JSONObject inputObject) throws IOException
{
    LOGGER.info("Start procedures query.");

    JSONObject json = null;

    String[] procedures = null;
    if (inputObject.has("procedure")) {
        procedures = inputObject.getString("procedure").split(",");
    }
    Collection<Procedure> proceduresColl = this.geoDB.getProcedureAccess().getProceduresWithIdAndResource(procedures);

    if (json == null) {
        json = JSONEncoder.encodeProcedures(proceduresColl);
    }

    return json.toString().getBytes("utf-8");
}
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:19,代碼來源:SosSoe.java

示例5: invokeOGCOperation

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
public byte[] invokeOGCOperation(AccessGDB geoDB, JSONObject inputObject,
        String[] responseProperties) throws ExceptionReport
{
	LOGGER.debug("Start " + getOperationName() + " query.");
    
	if (responseProperties == null || responseProperties.length == 0){
		responseProperties = new String[1];
	}
	
    responseProperties[0] = DEFAULT_RESPONSE_PROPERTIES;
    
    if (inputObject == null) {
        throw new MissingParameterValueException("Error, no parameters specified.");
    }
    
    // check 'service' parameter:
    checkMandatoryParameter(inputObject, SERVICE_KEY, SERVICE);
    
    // check 'request' parameter:
    checkMandatoryParameter(inputObject, REQUEST_KEY, getOperationName());
    
    return null;
}
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:24,代碼來源:OGCOperationRequestHandler.java

示例6: invokeOGCOperation

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
/**
     * 
     * @param inputObject
     * @return
     * @throws IOException 
     * @throws NoApplicableCodeException 
     * @throws Exception
     */
    public byte[] invokeOGCOperation(AccessGDB geoDB, JSONObject inputObject, String[] responseProperties) throws ExceptionReport
    {
        super.invokeOGCOperation(geoDB, inputObject, responseProperties);
        
//        String[] acceptVersions = null;
//        if (inputObject.has("AcceptVersions")) {
//            acceptVersions = inputObject.getString("AcceptVersions").split(",");
//        }
        try {
	        ServiceDescription serviceDesc = geoDB.getServiceDescription();
	//        Collection<ObservationOffering> obsOfferings = geoDB.getOfferingAccess().getNetworksAsObservationOfferings();
	        
	        Collection<ObservationOffering> obsOfferings;
			
			obsOfferings = ObservationOfferingCache.instance().getEntityCollection(geoDB).values();
	        
	        String capabilitiesDocument = new OGCCapabilitiesEncoder().encodeCapabilities(serviceDesc, obsOfferings, operationsMetadataProviders);
	                
	        // sending the Capabilities document:
	        LOGGER.info("Returning capabilities document.");
	        return capabilitiesDocument.getBytes("utf-8");
		} catch (CacheException | CacheNotYetAvailableException | IOException e) {
			throw new NoApplicableCodeException(e);
		}
    }
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:34,代碼來源:GetCapabilitiesOperationHandler.java

示例7: queryFeatureIDsForSpatialFilter

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
/**
   * 
   * @param spatialFilter
   * @return
   * @throws Exception
   */
  protected Collection<String> queryFeatureIDsForSpatialFilter(String spatialFilter) throws IOException
  {
      IGeometry geometry;
try {
	geometry = ServerUtilities.getGeometryFromJSON(new JSONObject(spatialFilter));
} catch (Exception e) {
	throw new IOException(e);
}
      IFeatureClass features = workspaceWrapper.getWorkspace().openFeatureClass(Table.FEATUREOFINTEREST);
      ISpatialFilter spatialQuery = new SpatialFilter();
      spatialQuery.setGeometryByRef(geometry);
      spatialQuery.setGeometryField(features.getShapeFieldName());
      spatialQuery.setSpatialRel(esriSpatialRelEnum.esriSpatialRelIntersects);
      spatialQuery.setSubFields(SubField.FEATUREOFINTEREST_ID);
      IFeatureCursor featureCursor = features.search(spatialQuery, true);

      IFeature feature = featureCursor.nextFeature();
      List<String> featureList = new ArrayList<String>();
      while (feature != null) {
          featureList.add((String)feature.getValue(0));
          feature = featureCursor.nextFeature();
      }

      return featureList;
  }
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:32,代碼來源:AccessGDBImpl.java

示例8: analyzeTable

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
/**
 * @throws IOException 
 * @throws AutomationException 
 * 
 */
public JSONObject analyzeTable (String tableName, String primaryKeyColumn) throws AutomationException, IOException {
    
    
    JSONObject json = new JSONObject();

    try {
        ICursor cursor = DatabaseUtils.evaluateQuery(tableName, "", "COUNT(" + primaryKeyColumn + ")",
        		workspace);
        
        json.append("Reading count of table:", tableName);
        IRow row;
        if ((row = cursor.nextRow()) != null) {
            Object count = row.getValue(0);
            String countAsString = count.toString();
            
            json.append("Table count:", countAsString);
        }
    } catch (Exception e) {
        LOGGER.severe(e.getLocalizedMessage(), e);
        throw new IOException(e);
    }
    
    return json;
}
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:30,代碼來源:AccessGdbForAnalysisImpl.java

示例9: analyzeProcedureTable

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
/**
 * @throws IOException 
 * @throws AutomationException 
 * 
 */
public JSONObject analyzeProcedureTable () throws AutomationException, IOException {
    
    JSONObject json = new JSONObject();
    json.append("This function: ", "...checks the availability of a table as specified in the properties of this SOE (configure in ArcGIS Server Manager).");
    json.append("This function: ", "...and presents the count of rows contained in that table.");
    
    try {
        ICursor cursor = DatabaseUtils.evaluateQuery(soe.getTable(), "", "COUNT(" + soe.getTablePkField() + ")", workspace);
        
        json.append("Reading count of table:", soe.getTable());
        IRow row;
        if ((row = cursor.nextRow()) != null) {
            Object count = row.getValue(0);
            String countAsString = count.toString();
            
            json.append("Table count:", countAsString);
        }
    } catch (Exception e) {
        LOGGER.severe(e.getLocalizedMessage(), e);
        
        json.append("ERROR:", "while trying to read table '" + soe.getTable() + "' with specified primary key '" + soe.getTablePkField() + "'");
    }
    
    return json;
}
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:31,代碼來源:AccessGdbForAnalysisImpl.java

示例10: executeOGCOperation

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
/**
 * Helper method used by the subclasses to execute an OGC operation.
 */
public void executeOGCOperation(OGCOperationRequestHandler opHandler, Map<String, String> kvp, File outputFile)
{
    JSONObject inputObject = new JSONObject();
    String[] responseProperties = new String[1];
    
    // read key value pairs and put into JSONObject
    for (String key : kvp.keySet()) {
    	inputObject = inputObject.put(key, kvp.get(key));
    }
    
    // now try executing:
    try {
        String result = new String(opHandler.invokeOGCOperation(gdb, inputObject, responseProperties));
        
        //LOGGER.info(result);
        
        CommonUtilities.saveFile(outputFile, result);
        
    } catch (Exception e) {
    	LOGGER.severe(e.getLocalizedMessage());
    	e.printStackTrace();
        fail();
    }
}
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:28,代碼來源:EsriTestBase.java

示例11: handleHelloResourceRequest

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
@RequestMapping(value = {"/hello"})
public RestResponse handleHelloResourceRequest(
        RestRequest request) throws IOException {
    logger.debug("Handling hello resource request ...");

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("message", "Hello, World!");
    byte[] data = jsonObject.toString().getBytes("utf-8");

    return new RestResponse(null, data);
}
 
開發者ID:Esri,項目名稱:server-extension-java,代碼行數:12,代碼來源:HelloDelegate.java

示例12: toByteArray

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
public static byte[] toByteArray(JSONObject jsonObj) {
    if (jsonObj == null) {
        return null;
    }
    try {
        return jsonObj.toString().getBytes("utf-8");
    } catch (UnsupportedEncodingException ex) {
        throw new JSONException(ex);
    }
}
 
開發者ID:Esri,項目名稱:server-extension-java,代碼行數:11,代碼來源:JSONConverter.java

示例13: toJSONObject

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
public static JSONObject toJSONObject(Resource jsonRes) {
    if (jsonRes == null) {
        return null;
    }
    try {
        return new JSONObject(IOUtils.toString(jsonRes.getInputStream(),
                "utf-8"));
    } catch (IOException ex) {
        throw new JSONException(ex);
    }
}
 
開發者ID:Esri,項目名稱:server-extension-java,代碼行數:12,代碼來源:JSONConverter.java

示例14: resolveArgument

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
@Override
public Object resolveArgument(MethodParameter parameter,
                              RestRequest request, RestDelegate handler) throws Exception {
    Class<?> type = parameter.getParameterType();
    RequestParam annotation = parameter
            .getParameterAnnotation(RequestParam.class);
    String value = annotation.value();

    JSONObject operationInput = new JSONObject(request.getOperationInput());
    Object param = operationInput.opt(value);
    return objectMapper.readValue(param != null ? param.toString() : null,
            type);
}
 
開發者ID:Esri,項目名稱:server-extension-java,代碼行數:14,代碼來源:RequestParamArgumentResolver.java

示例15: encodeObservation

import com.esri.arcgis.server.json.JSONObject; //導入依賴的package包/類
/**
 * creates a JSON representation for a {@link MultiValueObservation}.
 */
public static JSONObject encodeObservation(MultiValueObservation obs)
{
    JSONObject json = new JSONObject();

    json.put("id", obs.getIdentifier().getIdentifierValue());

    json.put("type", obs.getName());

    // encode time
    json.put("dateTimeBegin", obs.getResult().getDateTimeBegin().toISO8601Format());
    json.put("dateTimeEnd", obs.getResult().getDateTimeEnd().toISO8601Format());
    json.put("resultTime", obs.getResultTime().toISO8601Format());

    // encode observed property
    json.put("observedProperty", obs.getObservedProperty());

    // encode observed property
    json.put("unit", obs.getUnit());
    
    // encode procedure
    json.put("procedure", obs.getProcedure());

    // encode foi
    json.put("featureOfInterest", obs.getFeatureOfInterest());

    // encode result
    json.put("result", encodeResult(obs.getResult()));

    return json;
}
 
開發者ID:52North,項目名稱:ArcGIS-Server-SOS-Extension,代碼行數:34,代碼來源:JSONObservationEncoder.java


注:本文中的com.esri.arcgis.server.json.JSONObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。