public Property createProperty() { return new Attach(); } }
/** * @param aList a list of parameters for this component * @param aValue a value string for this component * @throws IOException when there is an error reading the binary stream * @throws URISyntaxException where the specified string is not a valid uri */ public Attach(final ParameterList aList, final String aValue) throws IOException, URISyntaxException { super(ATTACH, aList, PropertyFactoryImpl.getInstance()); setValue(aValue); }
/** * {@inheritDoc} */ public final String getValue() { if (getUri() != null) { return Uris.decode(Strings.valueOf(getUri())); } else if (getBinary() != null) { // return Base64.encodeBytes(getBinary(), Base64.DONT_BREAK_LINES); try { final BinaryEncoder encoder = EncoderFactory.getInstance() .createBinaryEncoder( getParameter(Parameter.ENCODING)); return new String(encoder.encode(getBinary())); } catch (UnsupportedEncodingException | EncoderException uee) { Logger log = LoggerFactory.getLogger(Attach.class); log.error("Error encoding binary data", uee); } } return null; }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { /* * ; the following is optional, ; but MUST NOT occur more than once (";" fmttypeparam) / */ ParameterValidator.getInstance().assertOneOrLess(Parameter.FMTTYPE, getParameters()); /* * ; the following is optional, ; and MAY occur more than once (";" xparam) */ /* * If the value type parameter is ";VALUE=BINARY", then the inline encoding parameter MUST be specified with the * value ";ENCODING=BASE64". */ if (Value.BINARY.equals(getParameter(Parameter.VALUE))) { ParameterValidator.getInstance().assertOne(Parameter.ENCODING, getParameters()); if (!Encoding.BASE64.equals(getParameter(Parameter.ENCODING))) { throw new ValidationException( "If the value type parameter is [BINARY], the inline" + "encoding parameter MUST be specified with the value [BASE64]" ); } } }
/** * Unit testing of serialization. */ public void testSerialization() throws IOException, ClassNotFoundException, URISyntaxException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(attach); ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream(bout.toByteArray())); Attach clone = (Attach) in.readObject(); assertNotNull(clone); assertEquals(attach, clone); // set a bogus value to trigger logging.. clone.getParameters().replace(new Encoding("BOGUS")); clone.setValue(""); } }
/** * @param data binary data */ public Attach(final byte[] data) { super(ATTACH, PropertyFactoryImpl.getInstance()); // add required parameters.. getParameters().add(Encoding.BASE64); getParameters().add(Value.BINARY); this.binary = data; }
+ "pointer the document template for the agenda file.")); Attach attachment = new Attach(new URI("http://example.com/templates/agenda.doc")); attachment.getParameters().add(new FmtType("application/msword")); alarm.getProperties().add(attachment); suite.addTest(new VAlarmTest("testValidation", alarm));
/** * @param attProp * @return BwAttachment * @throws Throwable */ public static BwAttachment getAttachment(final Attach attProp) throws Throwable { BwAttachment att = new BwAttachment(); ParameterList pars = attProp.getParameters(); att.setFmtType(getOptStr(pars, "FMTTYPE")); att.setValueType(getOptStr(pars, "VALUE")); att.setEncoding(getOptStr(pars, "ENCODING")); if (att.getEncoding() == null) { att.setUri(attProp.getValue()); } else { att.setValue(attProp.getValue()); } return att; }
if (getParameter(Parameter.ENCODING) != null) { getParameter(Parameter.ENCODING)); binary = decoder.decode(aValue.getBytes()); } catch (UnsupportedEncodingException uee) {
if (att.getUri() !=null) { return DataType.URI;
/** * {@inheritDoc} */ public final String getValue() { if (getUri() != null) { return Uris.decode(Strings.valueOf(getUri())); } else if (getBinary() != null) { // return Base64.encodeBytes(getBinary(), Base64.DONT_BREAK_LINES); try { final BinaryEncoder encoder = EncoderFactory.getInstance() .createBinaryEncoder( getParameter(Parameter.ENCODING)); return new String(encoder.encode(getBinary())); } catch (UnsupportedEncodingException | EncoderException uee) { Logger log = LoggerFactory.getLogger(Attach.class); log.error("Error encoding binary data", uee); } } return null; }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { /* * ; the following is optional, ; but MUST NOT occur more than once (";" fmttypeparam) / */ ParameterValidator.getInstance().assertOneOrLess(Parameter.FMTTYPE, getParameters()); /* * ; the following is optional, ; and MAY occur more than once (";" xparam) */ /* * If the value type parameter is ";VALUE=BINARY", then the inline encoding parameter MUST be specified with the * value ";ENCODING=BASE64". */ if (Value.BINARY.equals(getParameter(Parameter.VALUE))) { ParameterValidator.getInstance().assertOne(Parameter.ENCODING, getParameters()); if (!Encoding.BASE64.equals(getParameter(Parameter.ENCODING))) { throw new ValidationException( "If the value type parameter is [BINARY], the inline" + "encoding parameter MUST be specified with the value [BASE64]"); } } }
/** * @param data binary data */ public Attach(final byte[] data) { super(ATTACH, new Factory()); // add required parameters.. getParameters().add(Encoding.BASE64); getParameters().add(Value.BINARY); this.binary = data; }
if (getParameter(Parameter.ENCODING) != null) { getParameter(Parameter.ENCODING)); binary = decoder.decode(aValue.getBytes()); } catch (UnsupportedEncodingException uee) {
if(component.getProperty(Property.ATTACH) != null) { Attach attach = (Attach)component.getProperty(Property.ATTACH); if(attach.getUri() != null) { URI r_attach = createURI(URLDecoder.decode(attach.getUri().toString(),"UTF-8")); URI p_attach = createURI(NS_ICAL + "attach"); rdfHandler.handleStatement(createStatement(resource,p_attach,r_attach));
/** * {@inheritDoc} */ public final String getValue() { if (getUri() != null) { return Uris.decode(Strings.valueOf(getUri())); } else if (getBinary() != null) { // return Base64.encodeBytes(getBinary(), Base64.DONT_BREAK_LINES); try { final BinaryEncoder encoder = EncoderFactory.getInstance() .createBinaryEncoder( (Encoding) getParameter(Parameter.ENCODING)); return new String(encoder.encode(getBinary())); } catch (UnsupportedEncodingException uee) { Logger log = LoggerFactory.getLogger(Attach.class); log.error("Error encoding binary data", uee); } catch (EncoderException ee) { Logger log = LoggerFactory.getLogger(Attach.class); log.error("Error encoding binary data", ee); } } return null; }
/** * {@inheritDoc} */ public final void validate() throws ValidationException { /* * ; the following is optional, ; but MUST NOT occur more than once (";" fmttypeparam) / */ ParameterValidator.getInstance().assertOneOrLess(Parameter.FMTTYPE, getParameters()); /* * ; the following is optional, ; and MAY occur more than once (";" xparam) */ /* * If the value type parameter is ";VALUE=BINARY", then the inline encoding parameter MUST be specified with the * value ";ENCODING=BASE64". */ if (Value.BINARY.equals(getParameter(Parameter.VALUE))) { ParameterValidator.getInstance().assertOne(Parameter.ENCODING, getParameters()); if (!Encoding.BASE64.equals(getParameter(Parameter.ENCODING))) { throw new ValidationException( "If the value type parameter is [BINARY], the inline" + "encoding parameter MUST be specified with the value [BASE64]" ); } } }
public Property createProperty(final String name, final ParameterList parameters, final String value) throws IOException, URISyntaxException, ParseException { return new Attach(parameters, value); }
/** * @param data binary data */ public Attach(final byte[] data) { super(ATTACH, new Factory()); // add required parameters.. getParameters().add(Encoding.BASE64); getParameters().add(Value.BINARY); this.binary = data; }
/** * @param aList a list of parameters for this component * @param aValue a value string for this component * @throws URISyntaxException where the specified string is not a valid uri */ public Attach(final ParameterList aList, final String aValue) throws URISyntaxException { super(ATTACH, aList, new Factory()); setValue(aValue); }