/** * get an array containing all the MimeType handled by this object * * @return return a string array of handled MimeType */ public static String[] getSupportedTypes() { if (isJsonpEnabled()) return new String[] {json, simple_json, jsonp}; else return new String[] {json, simple_json}; }
@Override public boolean exclude(String beanId, Object bean) { return !JSONType.isJsonpEnabled() && super.exclude(beanId, bean); } }
/** * Check if the passed MimeType is a valid jsonp and if jsonp is enabled * * @param type the MimeType string representation to check * @return true if type is equalsIgnoreCase to {@link #jsonp} and jsonp is enabled * @see {@link JSONType#isJsonMimeType(String)} */ public static boolean useJsonp(String type) { return JSONType.isJsonpEnabled() && JSONType.isJsonpMimeType(type); }
private void handleException() { start("Exception"); for (String exceptionFormat : GetCapabilitiesTransformer.EXCEPTION_FORMATS) { element("Format", exceptionFormat); } if (JSONType.isJsonpEnabled()) { element("Format", JSONType.jsonp); } end("Exception"); }
private void handleException() { start("Exception"); for (String exceptionFormat : EXCEPTION_FORMATS) { element("Format", exceptionFormat); } if (JSONType.isJsonpEnabled()) { element("Format", "JSONP"); } end("Exception"); }
@Test public void testExceptions() throws Exception { Document doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.1.1", true); XpathEngine xpath = XMLUnit.newXpathEngine(); assertTrue( xpath.evaluate("//Exception/Format[1]", doc).equals("application/vnd.ogc.se_xml")); assertTrue( xpath.evaluate("//Exception/Format[2]", doc) .equals("application/vnd.ogc.se_inimage")); assertTrue( xpath.evaluate("//Exception/Format[3]", doc) .equals("application/vnd.ogc.se_blank")); assertTrue(xpath.evaluate("//Exception/Format[4]", doc).equals("application/json")); assertTrue(xpath.getMatchingNodes("//Exception/Format", doc).getLength() >= 4); boolean jsonpOriginal = JSONType.isJsonpEnabled(); try { JSONType.setJsonpEnabled(true); doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.1.1", true); assertTrue(xpath.evaluate("//Exception/Format[5]", doc).equals("text/javascript")); assertTrue(xpath.getMatchingNodes("//Exception/Format", doc).getLength() == 5); JSONType.setJsonpEnabled(false); doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.1.1", true); assertTrue(xpath.getMatchingNodes("//Exception/Format", doc).getLength() == 4); } finally { JSONType.setJsonpEnabled(jsonpOriginal); } }
"JSON", "wms:WMS_Capabilities/wms:Capability/wms:Exception/wms:Format[4]", doc); boolean jsonpOriginal = JSONType.isJsonpEnabled(); try { JSONType.setJsonpEnabled(true);