public SaltedSecretKey read(InputNode node) throws Exception { byte[] saltBytes = StringUtil.fromHex(node.getAttribute("salt").getValue()); byte[] keyBytes = StringUtil.fromHex(node.getAttribute("key").getValue()); return new SaltedSecretKey(new SecretKeySpec(keyBytes, CipherParams.MASTER_KEY_DERIVATION_FUNCTION), saltBytes); }
public class MapConverter implements Converter<HashMap<String, Integer>> { @Override public HashMap<String, Integer> read(InputNode inputNode) throws Exception { final HashMap<String, Integer> result = new HashMap<String, Integer>(); for (final String attributeName : inputNode.getAttributes()) { final String value = inputNode.getAttribute(attributeName).getValue(); result.put(attributeName, Integer.parseInt(value)); } return result; } @Override public void write(OutputNode outputNode, HashMap<String, Integer> stringIntegerHashMap) throws Exception { // not used } }
@Override public String read(InputNode node) throws Exception { InputNode encryptedAttribute = node.getAttribute("encrypted"); if (encryptedAttribute != null && encryptedAttribute.getValue().equals(Boolean.TRUE.toString())) { return TransferSettings.decrypt(node.getValue()); } return node.getValue(); }
static Map<String, String> getParameters(InputNode inputNode) throws ParseException { Map<String, String> parameters = Maps.newHashMap(); try { for (String name : inputNode.getAttributes()) { String value = inputNode.getAttribute(name).getValue(); parameters.put(name, value); } } catch (Exception e) { throw new ParseException(e.getMessage(), e); } return parameters; } }
@Override public T read(InputNode node) throws Exception { InputNode clazz = node.getAttribute("class"); // if (clazz == null) // clazz = new inputnod return null; }
static Map<String, String> getParameters(InputNode inputNode) throws ParseException { Map<String, String> parameters = Maps.newHashMap(); try { for (String name : inputNode.getAttributes()) { String value = inputNode.getAttribute(name).getValue(); parameters.put(name, value); } } catch (Exception e) { throw new ParseException(e.getMessage(), e); } return parameters; } }
public class UuidConverter implements Converter<UUID>{ @Override public UUID read(InputNode node) throws Exception { return UUID.fromString(node.getAttribute("id")); }
@Override public Color read(InputNode node) throws Exception { int r = Integer.parseInt(node.getAttribute("r").getValue()); int g = Integer.parseInt(node.getAttribute("g").getValue()); int b = Integer.parseInt(node.getAttribute("b").getValue()); int a = Integer.parseInt(node.getAttribute("a").getValue()); return new Color(r, g, b, a); }
private boolean isProtected(InputNode node) throws Exception { InputNode isProtectedNode = node.getAttribute("Protected"); if (isProtectedNode == null) { return false; } String value = isProtectedNode.getValue(); return value.equalsIgnoreCase("true"); }
@Override public <T> T readAttribute(InputNode input, String attribute, Class<T> type) { InputNode node = input.getAttribute(attribute); return node != null ? read(node, type) : null; }
public static String get(InputNode input, String attribute) { InputNode node = input.getAttribute(attribute); String value = null; if (node != null) { try { value = node.getValue(); } catch (Exception exception) { throw new XmlPersisterException(format("Can't get value of %s", node), exception); } } return value; }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then the node is considered as null and is valid. * * @param node this is the node to read the key value from * @param key this is the name of the attribute used by the key * * @return this returns the value deserialized from the node */ private boolean validateAttribute(InputNode node, String key) throws Exception { String name = style.getElement(key); InputNode child = node.getAttribute(name); if(child == null) { return true; } return root.validate(child); }
/** * This method is used to read the text value from the node. The * value read from the node is resolved using the template filter. * If the value value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the value object from * @param name this is the name of the value XML attribute, if any * * @return this returns the value deserialized from the node */ private Object readAttribute(InputNode node, String name) throws Exception { if(name != null) { name = style.getAttribute(name); node = node.getAttribute(name); } if(node == null) { return null; } return root.read(node); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then an null is assumed and returned. * * @param node this is the node to read the key value from * @param key this is the name of the attribute used by the key * * @return this returns the value deserialized from the node */ private Object readAttribute(InputNode node, String key) throws Exception { String name = style.getAttribute(key); InputNode child = node.getAttribute(name); if(child == null) { return null; } return root.read(child); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then the node is considered as null and is valid. * * @param node this is the node to read the key value from * @param key this is the name of the attribute used by the key * * @return this returns the value deserialized from the node */ private boolean validateAttribute(InputNode node, String key) throws Exception { String name = style.getElement(key); InputNode child = node.getAttribute(name); if(child == null) { return true; } return root.validate(child); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then an null is assumed and returned. * * @param node this is the node to read the key value from * @param key this is the name of the attribute used by the key * * @return this returns the value deserialized from the node */ private Object readAttribute(InputNode node, String key) throws Exception { String name = style.getAttribute(key); InputNode child = node.getAttribute(name); if(child == null) { return null; } return root.read(child); }
/** * This method is used to read the text value from the node. The * value read from the node is resolved using the template filter. * If the value value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the value object from * @param name this is the name of the value XML attribute, if any * * @return this returns the value deserialized from the node */ private Object readAttribute(InputNode node, String name) throws Exception { if(name != null) { name = style.getAttribute(name); node = node.getAttribute(name); } if(node == null) { return null; } return root.read(node); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then an null is assumed and returned. * * @param node this is the node to read the key value from * @param key this is the name of the attribute used by the key * * @return this returns the value deserialized from the node */ private Object readAttribute(InputNode node, String key) throws Exception { String name = style.getAttribute(key); InputNode child = node.getAttribute(name); if(child == null) { return null; } return root.read(child); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then the node is considered as null and is valid. * * @param node this is the node to read the key value from * @param key this is the name of the attribute used by the key * * @return this returns the value deserialized from the node */ private boolean validateAttribute(InputNode node, String key) throws Exception { String name = style.getElement(key); InputNode child = node.getAttribute(name); if(child == null) { return true; } return root.validate(child); }
/** * This method is used to read the text value from the node. The * value read from the node is resolved using the template filter. * If the value value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the value object from * @param name this is the name of the value XML attribute, if any * * @return this returns the value deserialized from the node */ private Object readAttribute(InputNode node, String name) throws Exception { if(name != null) { name = style.getAttribute(name); node = node.getAttribute(name); } if(node == null) { return null; } return root.read(node); }