/**验证是否重复 * @param table * @param key * @param value * @param exceptId 不包含id * @throws Exception */ public static void verifyRepeat(String table, String key, Object value, long exceptId) throws Exception { if (key == null || value == null) { Log.e(TAG, "verifyRepeat key == null || value == null >> return;"); return; } if (value instanceof JSON) { throw new UnsupportedDataTypeException(key + ":value 中value的类型不能为JSON!"); } JSONRequest request = new JSONRequest(key, value); if (exceptId > 0) {//允许修改自己的属性为该属性原来的值 request.put(JSONRequest.KEY_ID + "!", exceptId); } // JSONObject repeat = new AbstractParser(HEAD, true).parseResponse( // new JSONRequest(table, request) // ); // repeat = repeat == null ? null : repeat.getJSONObject(table); // if (repeat == null) { // throw new Exception("服务器内部错误 verifyRepeat repeat == null"); // } // if (repeat.getIntValue(JSONResponse.KEY_COUNT) > 0) { // throw new ConflictException(key + ": " + value + " 已经存在,不能重复!"); // } }
/**验证是否重复 * @param table * @param key * @param value * @param exceptId 不包含id * @throws Exception */ @Override public void verifyRepeat(String table, String key, Object value, long exceptId) throws Exception { if (key == null || value == null) { Log.e(TAG, "verifyRepeat key == null || value == null >> return;"); return; } if (value instanceof JSON) { throw new UnsupportedDataTypeException(key + ":value 中value的类型不能为JSON!"); } JSONRequest request = new JSONRequest(key, value); if (exceptId > 0) {//允许修改自己的属性为该属性原来的值 request.put(JSONRequest.KEY_ID + "!", exceptId); } JSONObject repeat = createParser().setMethod(HEAD).setNoVerify(true).parseResponse( new JSONRequest(table, request) ); repeat = repeat == null ? null : repeat.getJSONObject(table); if (repeat == null) { throw new Exception("服务器内部错误 verifyRepeat repeat == null"); } if (repeat.getIntValue(JSONResponse.KEY_COUNT) > 0) { throw new ConflictException(key + ": " + value + " 已经存在,不能重复!"); } }
/**验证是否重复 * @param table * @param key * @param value * @param exceptId 不包含id * @throws Exception */ public static void verifyRepeat(String table, String key, Object value, long exceptId) throws Exception { if (key == null || value == null) { Log.e(TAG, "verifyRepeat key == null || value == null >> return;"); return; } if (value instanceof JSON) { throw new UnsupportedDataTypeException(key + ":value 中value的类型不能为JSON!"); } JSONRequest request = new JSONRequest(key, value); if (exceptId > 0) {//允许修改自己的属性为该属性原来的值 request.put(JSONRequest.KEY_ID + "!", exceptId); } JSONObject repeat = new Parser(HEAD, true).parseResponse( new JSONRequest(table, request) ); repeat = repeat == null ? null : repeat.getJSONObject(table); if (repeat == null) { throw new Exception("服务器内部错误 verifyRepeat repeat == null"); } if (repeat.getIntValue(JSONResponse.KEY_COUNT) > 0) { throw new ConflictException(key + ": " + value + " 已经存在,不能重复!"); } }
private static MethodSpec makeGetMethod(boolean singleton, String fieldName, PreferenceField field) throws UnsupportedDataTypeException { MethodSpec.Builder builder ; if(Constants.BOOLEAN_TYPE.equals(field.getType())){ builder = makeGenericMethod(singleton, "is" + field.getMethodName()); } else { builder = makeGenericMethod(singleton, "get" + field.getMethodName()); } String type = field.getType(); TypeName typeName = typeNameOf(type); builder.returns(typeName); builder.addStatement("return $T.get$L($S, $L)", ANNOPREF, methodNameOfType(type), fieldName, field.getSerializedDefaultValue() ); return builder.build(); }
private static MethodSpec makeGetWithDefaultMethod(boolean singleton, String fieldName, PreferenceField field) throws UnsupportedDataTypeException { MethodSpec.Builder builder ; if(Constants.BOOLEAN_TYPE.equals(field.getType())){ builder = makeGenericMethod(singleton, "is" + field.getMethodName()); } else { builder = makeGenericMethod(singleton, "get" + field.getMethodName()); } String type = field.getType(); TypeName typeName = typeNameOf(type); if (typeName != null) { builder.addParameter(typeName, "defaultValue"); builder.returns(typeName); builder.addStatement("return $T.get$L($S, $L)", ANNOPREF, methodNameOfType(type), fieldName, "defaultValue" ); } return builder.build(); }
private static MethodSpec makeSetMethod(boolean singleton, String fieldName, PreferenceField field) throws UnsupportedDataTypeException { MethodSpec.Builder builder = makeGenericMethod(singleton, "set" + field.getMethodName()); String type = field.getType(); TypeName typeName = typeNameOf(field.getType()); builder.addParameter(typeName, field.getFieldName()); builder.addStatement("$T.put$L($S, $L)", ANNOPREF, methodNameOfType(type), fieldName, field.getFieldName() ); return builder.build(); }
private void stripFile(final String fileNameIn, final String fileNameOut, final boolean[] toStrip) throws Exception { final File fileIn = new File(fileNameIn); final long fileLength = fileIn.length(); byte[] fileData; try { final BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(fileIn)); final DataInputStream dataInputStream = new DataInputStream(inputStream); fileData = new byte[(int) fileLength]; // Allocate memory for // reading the file into // memory dataInputStream.read(fileData, 0, (int) fileLength); // Read the // data to // memory dataInputStream.close(); // Close the file after reading } catch (final Exception e) { throw new UnsupportedDataTypeException("Could not read input file."); } fileData = stripHeader(fileData, toStrip); // Strip header writeFile(fileNameOut, fileData); }
/** * Calculates the sets of sources, sinks, entry points, and callbacks methods for the given APK file. * * @param sourceSinkFile * The full path and file name of the file containing the sources and sinks * @throws IOException * Thrown if the given source/sink file could not be read. * @throws XmlPullParserException * Thrown if the Android manifest file could not be read. */ public void calculateSourcesSinksEntrypoints(String sourceSinkFile) throws IOException, XmlPullParserException { ISourceSinkDefinitionProvider parser = null; String fileExtension = sourceSinkFile.substring(sourceSinkFile.lastIndexOf(".")); fileExtension = fileExtension.toLowerCase(); if (fileExtension.equals(".xml")) parser = XMLSourceSinkParser.fromFile(sourceSinkFile); else if(fileExtension.equals(".txt")) parser = PermissionMethodParser.fromFile(sourceSinkFile); else throw new UnsupportedDataTypeException("The Inputfile isn't a .txt or .xml file."); calculateSourcesSinksEntrypoints(parser); }
@Get("json") public String doGet() throws GatewayDriverException, DatapointInvalidValueTypeException, UnknownHostException, DatapointReadonlyAccessTypeException, UnsupportedDataTypeException, DatapointWriteonlyAccessTypeException, KNXLinkClosedException, KNXTimeoutException, InterruptedException, AccessDeniedException { RestletServer.configureRestForm(getResponse()); AuthService.CheckAuthorization(getRequest().getResourceRef().getQueryAsForm()); final String gwAddress = getRequest().getAttributes().get("gateway_address").toString(); final IGatewayDriver gateway = config.findGateway(gwAddress); if (gateway == null) return toJSON(new ServiceResourceErrorException("Gateway not found.")); gateway.connect(); List<String> result = gateway.scanNetworkRouters(); gateway.disconnect(); return toJSON(result); }
public JSONObject render(Collection<Serializable[]> finalResults, DataSchema dataSchema, int offset) throws Exception { final LinkedList<JSONArray> rowEventsJSonList = new LinkedList<JSONArray>(); if (finalResults instanceof PriorityQueue<?>) { PriorityQueue<Serializable[]> queue = (PriorityQueue<Serializable[]>) finalResults; while (finalResults.size() > offset) { rowEventsJSonList.addFirst(getJSonArrayFromRow(queue.poll(), dataSchema)); } } else if (finalResults instanceof ArrayList<?>) { List<Serializable[]> list = (List<Serializable[]>) finalResults; //TODO: check if the offset is inclusive or exclusive for (int i = offset; i < list.size(); i++) { rowEventsJSonList.add(getJSonArrayFromRow(list.get(i), dataSchema)); } } else { throw new UnsupportedDataTypeException("type of results Expected: (PriorityQueue| ArrayList)) actual:" + finalResults.getClass()); } final JSONObject resultJsonObject = new JSONObject(); resultJsonObject.put("results", new JSONArray(rowEventsJSonList)); resultJsonObject.put("columns", getSelectionColumnsFromDataSchema(dataSchema)); return resultJsonObject; }
public int filterChimeras(List<E> chimeras) throws UnsupportedDataTypeException { int sizeRemoved = 0; for (E chimera : chimeras) { if (chimera instanceof DereplicatedSequence) { if (this.contains(chimera)) { int annotatedSize = ((DereplicatedSequence) chimera).getAnnotatedSize(); sizeRemoved += annotatedSize; this.remove(chimera); // MyLogger.debug("remove chimera " + chimera + ", annotated size = " + annotatedSize); } } else { throw new UnsupportedDataTypeException("Unsupported Sequence Type : " + chimera); } } chimerasRemoved = chimeras.size(); chimerasRemovedAnnotatedSize = sizeRemoved; return sizeRemoved; }
/** * Loads the options, creating a LinkedHashMap where the key is the enum name and the value is the enum class + " " + the enum name * * @since org.openntf.domino.xsp 4.5.0 */ @SuppressWarnings("unchecked") public void setOptions() { Map<String, String> opts; if (sorted) { opts = new TreeMap<String, String>(); } else { opts = new LinkedHashMap<String, String>(); } try { Class<Enum> enumClass = (Class<Enum>) Class.forName(getEnumName()); if (enumClass.isEnum()) { Enum[] enums = enumClass.getEnumConstants(); for (Enum e : enums) { opts.put(e.name(), enumClass.getName() + " " + e.name()); } } else { throw new UnsupportedDataTypeException("Value is not an Enum"); } } catch (Throwable t) { DominoUtils.handleException(t); } super.setOptions(opts); }
/** * Gets the options for the Value Picker, from the "options" property * * @return Map<String, String> of values * @since org.openntf.domino.xsp 4.5.0 */ @SuppressWarnings("unchecked") public Map<String, String> getOptions() { if (options != null) { return options; } ValueBinding vb = getValueBinding("options"); //$NON-NLS-1$ if (vb != null) { Object vbVal = vb.getValue(getFacesContext()); if (vbVal instanceof Map) { return (Map<String, String>) vbVal; } else { try { throw new UnsupportedDataTypeException("Value is not a map"); } catch (UnsupportedDataTypeException e) { e.printStackTrace(); } } } return null; }
/** * Gets the Collection from the "collection" property, throwing an error if it is not a valid Collection * * @return Collection<String> of values to use in the picker * @since org.openntf.domino.xsp 4.5.0 */ @SuppressWarnings("unchecked") public Collection<String> getCollection() { if (collection != null) { return collection; } ValueBinding vb = getValueBinding("collection"); //$NON-NLS-1$ if (vb != null) { Object vbVal = vb.getValue(getFacesContext()); if (vbVal instanceof Collection) { return (Collection<String>) vbVal; } else { try { throw new UnsupportedDataTypeException("Value is not a Collection"); } catch (UnsupportedDataTypeException e) { e.printStackTrace(); } } } return null; }
@SuppressWarnings("unused") @Get("json") public String doGet() throws GatewayDriverException, DatapointInvalidValueTypeException, UnknownHostException, DatapointReadonlyAccessTypeException, UnsupportedDataTypeException, DatapointWriteonlyAccessTypeException, InterruptedException, KNXFormatException, KNXException, AccessDeniedException { RestletServer.configureRestForm(getResponse()); AuthService.CheckAuthorization(getRequest().getResourceRef().getQueryAsForm()); final String dpointAddress = getRequest().getAttributes().get("datapointaddr").toString(); final IDatapoint dpoint = config.findDatapoint(dpointAddress.replace('.', '/')); final IGatewayDriver gateway = config.findGateway(dpoint.getGatewayAddress()); if (dpoint == null) return toJSON(new ServiceResourceErrorException("Datapoint not found.")); if (gateway == null) return toJSON(new ServiceResourceErrorException("Gateway not found.")); gateway.connect(); Boolean result = gateway.isAddressOccupied(dpointAddress); gateway.disconnect(); return toJSON(result); }
@Get("json") public String doGet() throws GatewayDriverException, DatapointInvalidValueTypeException, UnknownHostException, DatapointReadonlyAccessTypeException, UnsupportedDataTypeException, DatapointWriteonlyAccessTypeException, KNXLinkClosedException, KNXTimeoutException, InterruptedException, AccessDeniedException { RestletServer.configureRestForm(getResponse()); AuthService.CheckAuthorization(getRequest().getResourceRef().getQueryAsForm()); final String gwAddress = getRequest().getAttributes().get("gateway_address").toString(); final String area = getRequest().getAttributes().get("area").toString(); final String line = getRequest().getAttributes().get("line").toString(); final IGatewayDriver gateway = config.findGateway(gwAddress); if (gateway == null) return toJSON(new ServiceResourceErrorException("Gateway not found.")); gateway.connect(); List<String> result = gateway.scanNetworkDevices(Integer.valueOf(area), Integer.valueOf(line)); gateway.disconnect(); return toJSON(result); }
@SuppressWarnings("unused") @Get("json") public String doPut(Representation res) throws ServiceResourceErrorException, DatapointReadonlyAccessTypeException, UnknownHostException, GatewayDriverException, UnsupportedDataTypeException, DatapointInvalidValueTypeException, DatapointWriteonlyAccessTypeException, AccessDeniedException { RestletServer.configureRestForm(getResponse()); AuthService.CheckAuthorization(getRequest().getResourceRef().getQueryAsForm()); final String dpointAddress = getRequest().getAttributes().get("datapointaddr").toString(); final String dpointValue = getRequest().getAttributes().get("value").toString(); final IDatapoint dpoint = config.findDatapoint(dpointAddress.replace('.', '/')); final IGatewayDriver gateway = config.findGateway(dpoint.getGatewayAddress()); if (dpoint == null) throw new ServiceResourceErrorException("Datapoint not found."); if (gateway == null) throw new ServiceResourceErrorException("Gateway not found."); try { DatapointValue<?> value = DatapointValue.build(dpoint); value.setValue(dpointValue); gateway.connect(); gateway.write(value); gateway.disconnect(); return null; } catch (Exception e) { return toJSON(new ServiceResourceErrorException(e)); } }
@Override public DatapointValue<?> read(IDatapoint datapoint) throws GatewayDriverException, DatapointInvalidValueTypeException, DatapointWriteonlyAccessTypeException, DatapointReadonlyAccessTypeException, UnsupportedDataTypeException { if (isReconnecting) throw new GatewayConnectionLostException("Gateway Address: " + this.address); DatapointValue<?> value = DatapointValue.build(datapoint); logger.info(String.format("KNXGatewayDriver#read('%s')", value.getDatapoint().getReadAddress())); try { switch (datapoint.getDataType()) { case BIT: value.setValue(pc.readBool(new GroupAddress(datapoint.getReadAddress()))); break; case TINY_NUMBER: value.setValue(pc.readFloat(new GroupAddress(datapoint.getReadAddress()), false)); break; case NUMBER: value.setValue(pc.readFloat(new GroupAddress(datapoint.getReadAddress()), true)); break; case PERCENTAGE: value.setValue(pc.readUnsigned(new GroupAddress(datapoint.getReadAddress()), ProcessCommunicationBase.SCALING)); break; case TEXT: value.setValue(pc.readString(new GroupAddress(datapoint.getReadAddress()))); break; default: throw new GatewayDriverException("Datapoint data type unknown, please specify a valid data type."); } return value; } catch (KNXException | InterruptedException e) { throw new GatewayDriverException(e); } }
/** * Charger le contenu au format texte * * @param txSizeExpected * @param txSizeDownloaded * @return String * @throws java.io.IOException * @throws java.security.NoSuchAlgorithmException * @throws java.security.KeyManagementException */ public String asString(JTextField txSizeExpected, JTextField txSizeDownloaded) throws IOException, NoSuchAlgorithmException, KeyManagementException { BufferedReader reader = null; String html = ""; try { HttpURLConnection curl = (HttpURLConnection) open(); //Seul le format texte est accepté String contentType = curl.getContentType(); if (!contentType.startsWith("text/")) throw new UnsupportedDataTypeException("Bad format, only text can be loaded"); int sizeExpect = curl.getContentLength(); int sizeFile = 0; txSizeExpected.setText(""+sizeExpect); reader = new BufferedReader(new InputStreamReader(curl.getInputStream())); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line); sb.append(System.getProperty("line.separator")); sizeFile+=line.length(); txSizeDownloaded.setText(""+sizeFile); } html = sb.toString(); } finally { if (reader != null) reader.close(); } return html; }
/** * Creates a JavaRDD of SparkSQL rows * @param cellsRDD RDD of cells for transforming. * @return Java RDD of SparkSQL rows * @throws UnsupportedDataTypeException */ public static JavaRDD<Row> createJavaRowRDD(JavaRDD<Cells> cellsRDD) throws UnsupportedDataTypeException { JavaRDD<Row> result = cellsRDD.map(new Function<Cells, Row>() { @Override public Row call(Cells cells) throws Exception { return CellsUtils.getRowFromCells(cells); } }); return result; }
/** * Creates a JavaSchemaRDD from a DeepJobConfig and a JavaSQLContext. * @param config Specific Deep ExtractorConfig. * @return A JavaSchemaRDD built from Cells. * @throws UnsupportedDataTypeException */ public DataFrame createJavaSchemaRDD(ExtractorConfig<Cells> config) throws UnsupportedDataTypeException, UnsupportedOperationException { JavaRDD<Cells> cellsRDD = createJavaRDD(config); JavaRDD<Row> rowsRDD = DeepSparkContext.createJavaRowRDD(cellsRDD); try { Cells firstCells = cellsRDD.first(); StructType schema = CellsUtils.getStructTypeFromCells(firstCells); return sqlContext.applySchema(rowsRDD, schema); } catch(UnsupportedOperationException e) { throw new UnsupportedOperationException("Cannot infer schema from empty data RDD", e); } }
@SuppressWarnings("unchecked") public static <T> T unmarshall(final Object value, final Class<T> type) throws UnsupportedDataTypeException { final Marshaller<?> marshaller = marshallers.get(type); if (marshaller == null) { throw new UnsupportedDataTypeException("can't unmarshall type " + type.getName()); } return (T) marshaller.unmarshall(value); }
/** * Create a {@link BufferedImage} from a DXT-compressed {@link DDSImage} * * @param image * @return * @throws UnsupportedDataTypeException */ public static BufferedImage loadBufferedImage(final DDSImage image) throws UnsupportedDataTypeException { if (image.isCompressed()) return decompressTexture(image.getMipMap(0).getData(), image.getWidth(), image.getHeight(), findCompressionFormat(image)); else return loadBufferedImageFromByteBuffer( image.getMipMap(0).getData(), image.getWidth(), image.getHeight(), image); }
/** * Reads the Texture, originalImage and editedImage from the DDS-FilePath * * @param file * @throws OutOfMemoryError */ public void readTextureImageFromFile(final File file) throws OutOfMemoryError { long mem0; try { // actionController.setStatus("LOAD: Lade Textur "+textureFile.getAbsolutePath()); System.out.println("LOAD: Load Texture " + file.getAbsolutePath()); if (texture != null) texture.loadImageData(); else { // actionController.setStatus("ERROR: Textur "+file.getAbsolutePath()+" konnte nicht eingelesen werden..."); System.out.println("ERROR: Texture " + file.getAbsolutePath() + " couldn't be read..."); return; } mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); } catch (UnsupportedDataTypeException e) { // actionController.setStatus("ERROR: "+e.getMessage()); state = EditState.unsupported; System.out.println("ERROR: " + e.getMessage()); return; } catch (final OutOfMemoryError ex) { mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); throw new OutOfMemoryError( "No memory (mem0=" + mem0 + ") left, try to start the program with more memory e.g. java -Xms4096k -jar textureAttack.jar\n" + ex.getMessage()); } }
private void extractValues(Result r) { this.id = Bytes.toString(r.getRow()); if (r.isEmpty()) return; try { this.properties.addProperty(r); } catch (UnsupportedDataTypeException e) { LOG.error("proerties.addProperty failed", e); throw new RuntimeException(e); } }
@Override public void setProperty(String key, Object value) { try { this.properties.setProperty(key, value); } catch (UnsupportedDataTypeException e) { LOG.error("properties.setProperty failed", e); throw new RuntimeException(e); } }
private static void generateProperties(Put put) { Pair<byte[], byte[]> pair = null; for(Map.Entry<String, Object> entry : DEFAULT_PROPERTY_KVS.entrySet()) { try { pair = Properties.keyValueToBytes(entry.getKey(), entry.getValue()); put.add(COLFAM_PROPERTY_NAME, pair.key, pair.value); } catch (UnsupportedDataTypeException e) { LOG.error("generate property pair failed", e); throw new RuntimeException(e); } } }
/** * Set new property * @param key * @param value * @return old property * @throws UnsupportedDataTypeException */ public Object setProperty(String key, Object value) throws UnsupportedDataTypeException { Validate.notEmpty(key, "key shall always not be empty or null"); Validate.notNull(value, "value shall always not be null"); Object oldValue = this.removeProperty(key); @SuppressWarnings("rawtypes") Pair<Class, Object> pair = keyValueToPair(key, value, new TypeClassPairStrategy()); this.keyValueMap.put(key, value); this.keyValueTypeMap.put(key, pair.key); return oldValue; }
/** * transfer value to <code>K, V</code> generic types, based on its <code>PairStrategy</code> object. * @param key * @param value * @param strategy a <code>PairStrategy</code> object * @return a <code>Pair</code> with generic types * @throws UnsupportedDataTypeException */ static<K, V> Pair<K, V> keyValueToPair(String key, Object value, PairStrategy<K, V> strategy) throws UnsupportedDataTypeException { if(null == key || null == value) return null; Validate.notNull(strategy, "strategy shall always not be null"); Pair<K, V> pair = null; if(value instanceof String) { pair = strategy.getStringPair(key, value.toString()); } else if(value instanceof Integer) { pair = strategy.getIntPair(key, (Integer) value); } else if(value instanceof Long) { pair = strategy.getLongPair(key, (Long) value); } else if(value instanceof Float) { pair = strategy.getFloatPair(key, (Float) value); } else if(value instanceof Double) { pair = strategy.getDoublePair(key, (Double) value); } else if(value instanceof Boolean) { pair = strategy.getBooleanPair(key, (Boolean) value); } else if(value instanceof Short) { pair = strategy.getShortPair(key, (Short) value); } else if(value instanceof BigDecimal) { pair = strategy.getBigDecimalPair(key, (BigDecimal) value); } else { throw new UnsupportedDataTypeException("Not support data type for value:" + value); } return pair; }
/** * * @param message * @param headerOs * @param bodyOs * @param ignoreList * @throws MessagingException * @throws IOException * @throws UnsupportedDataTypeException */ public static void writeToInternal(MimeMessage message, OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws MessagingException, IOException, UnsupportedDataTypeException { if (message.getMessageID() == null) { message.saveChanges(); } writeHeadersTo(message, headerOs, ignoreList); // Write the body to the output stream writeMessageBodyTo(message, bodyOs); }
@Test(enabled=false) public void executePACE_PIN() throws UnsupportedDataTypeException, JAXBException, SAXException, WSMarshallerException { IFD ifd = new IFD(); ifd.setGUI(new SwingUserConsent(new SwingDialogWrapper())); EstablishContext eCtx = new EstablishContext(); byte[] ctxHandle = ifd.establishContext(eCtx).getContextHandle(); ListIFDs listIFDs = new ListIFDs(); listIFDs.setContextHandle(ctxHandle); String ifdName = ifd.listIFDs(listIFDs).getIFDName().get(0); Connect connect = new Connect(); connect.setContextHandle(ctxHandle); connect.setIFDName(ifdName); connect.setSlot(BigInteger.ZERO); byte[] slotHandle = ifd.connect(connect).getSlotHandle(); // prepare pace call String xmlCall = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<iso:EstablishChannel xmlns:iso=\"urn:iso:std:iso-iec:24727:tech:schema\">\n" + " <iso:SlotHandle>" + ByteUtils.toHexString(slotHandle) + "</iso:SlotHandle>\n" + " <iso:AuthenticationProtocolData Protocol=\"urn:oid:0.4.0.127.0.7.2.2.4\">\n" + " <iso:PinID>03</iso:PinID>\n" + " </iso:AuthenticationProtocolData>\n" + "</iso:EstablishChannel>"; WSMarshaller m = WSMarshallerFactory.createInstance(); EstablishChannel eCh = (EstablishChannel) m.unmarshal(m.str2doc(xmlCall)); // send pace call EstablishChannelResponse eChR = ifd.establishChannel(eCh); }
/**新建错误状态内容 * @param e * @return */ public static JSONObject newErrorResult(Exception e) { if (e != null) { e.printStackTrace(); int code; if (e instanceof UnsupportedEncodingException) { code = JSONResponse.CODE_UNSUPPORTED_ENCODING; } else if (e instanceof IllegalAccessException) { code = JSONResponse.CODE_ILLEGAL_ACCESS; } else if (e instanceof UnsupportedOperationException) { code = JSONResponse.CODE_UNSUPPORTED_OPERATION; } else if (e instanceof NotExistException) { code = JSONResponse.CODE_NOT_FOUND; } else if (e instanceof IllegalArgumentException) { code = JSONResponse.CODE_ILLEGAL_ARGUMENT; } else if (e instanceof NotLoggedInException) { code = JSONResponse.CODE_NOT_LOGGED_IN; } else if (e instanceof TimeoutException) { code = JSONResponse.CODE_TIME_OUT; } else if (e instanceof ConflictException) { code = JSONResponse.CODE_CONFLICT; } else if (e instanceof ConditionErrorException) { code = JSONResponse.CODE_CONDITION_ERROR; } else if (e instanceof UnsupportedDataTypeException) { code = JSONResponse.CODE_UNSUPPORTED_TYPE; } else if (e instanceof OutOfRangeException) { code = JSONResponse.CODE_OUT_OF_RANGE; } else if (e instanceof NullPointerException) { code = JSONResponse.CODE_NULL_POINTER; } else { code = JSONResponse.CODE_SERVER_ERROR; } return newResult(code, e.getMessage()); } return newResult(JSONResponse.CODE_SERVER_ERROR, JSONResponse.MSG_SERVER_ERROR); }
private static TypeName typeNameOf(String type) throws UnsupportedDataTypeException { TypeName result = Constants.TYPENAME_OF_TYPE.get(type); if (result == null) throw new UnsupportedDataTypeException(); return result; }