public Parameter createParameter(final String value) throws URISyntaxException { Encoding parameter = new Encoding(value); if (Encoding.EIGHT_BIT.equals(parameter)) { parameter = Encoding.EIGHT_BIT; } else if (Encoding.BASE64.equals(parameter)) { parameter = Encoding.BASE64; } return parameter; } }
public Parameter createParameter(final String name, final String value) throws URISyntaxException { Encoding parameter = new Encoding(value); if (Encoding.EIGHT_BIT.equals(parameter)) { parameter = Encoding.EIGHT_BIT; } else if (Encoding.BASE64.equals(parameter)) { parameter = Encoding.BASE64; } return parameter; } }
public Parameter createParameter(final String value) throws URISyntaxException { Encoding parameter = new Encoding(value); if (Encoding.EIGHT_BIT.equals(parameter)) { parameter = Encoding.EIGHT_BIT; } else if (Encoding.BASE64.equals(parameter)) { parameter = Encoding.BASE64; } return parameter; } }
public Parameter createParameter(final String value) throws URISyntaxException { Encoding parameter = new Encoding(value); if (Encoding.EIGHT_BIT.equals(parameter)) { parameter = Encoding.EIGHT_BIT; } else if (Encoding.BASE64.equals(parameter)) { parameter = Encoding.BASE64; } return parameter; } }
public Parameter createParameter(final String value) throws URISyntaxException { Encoding parameter = new Encoding(value); if (Encoding.EIGHT_BIT.equals(parameter)) { parameter = Encoding.EIGHT_BIT; } else if (Encoding.BASE64.equals(parameter)) { parameter = Encoding.BASE64; } return parameter; } }
/** * 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(""); } }
/** * Test creation of binary decoder. * * @throws UnsupportedEncodingException * @throws DecoderException */ public void testCreateBinaryDecoder() throws UnsupportedEncodingException, DecoderException { BinaryDecoder decoder = factory.createBinaryDecoder( Encoding.QUOTED_PRINTABLE); assertNotNull(decoder); String encoded = "=C3=A0 la maison"; String decoded = (String) decoder.decode(encoded); assertNotNull(decoded); LOG.info("Decoded: [" + decoded + "]"); try { factory.createBinaryDecoder(new Encoding("9-BIT")); fail("Should throw UnsupportedEncodingException"); } catch (UnsupportedEncodingException uee) { LOG.debug("Caught exception: " + uee.getMessage()); } }
/** * Test creation of string decoder. * * @throws UnsupportedEncodingException * @throws DecoderException */ public void testCreateStringDecoder() throws UnsupportedEncodingException, DecoderException { StringDecoder decoder = factory.createStringDecoder( Encoding.QUOTED_PRINTABLE); assertNotNull(decoder); String encoded = "=C3=A0 la maison"; String decoded = (String) decoder.decode(encoded); assertNotNull(decoded); LOG.info("Decoded: [" + decoded + "]"); try { factory.createStringDecoder(new Encoding("9-BIT")); fail("Should throw UnsupportedEncodingException"); } catch (UnsupportedEncodingException uee) { LOG.debug("Caught exception: " + uee.getMessage()); } }
/** make an attachment * * @param val * @return Attendee * @throws Throwable */ public static Attach setAttachment(final BwAttachment val) throws Throwable { ParameterList pars = new ParameterList(); String temp = val.getFmtType(); if (temp != null) { pars.add(new FmtType(temp)); } temp = val.getEncoding(); if (temp == null) { return new Attach(pars, val.getUri()); } else { pars.add(new Encoding(temp)); temp = val.getValueType(); if (temp != null) { pars.add(new Value(temp)); } return new Attach(pars, val.getValue()); } }