protected Element getSchema () throws JDOMException, IOException { return getSchema (baseSchema); } protected Element getSchema (String message)
protected Element getSchema (String message) throws JDOMException, IOException { return getSchema (message, "", null); } protected Element getSchema (String prefix, String suffix, String defSuffix)
/** * @return message string * @throws org.jdom2.JDOMException * @throws java.io.IOException * @throws ISOException */ public String pack () throws JDOMException, IOException, ISOException { StringBuilder sb = new StringBuilder (); pack (getSchema (baseSchema), sb); return sb.toString (); } public byte[] packToBytes ()
/** * parse message. If the stream ends before the message is completely read, then the method adds an EOF field. * * @param is input stream * * @throws IOException * @throws JDOMException */ public void unpack (InputStream is) throws IOException, JDOMException { try { if (is.markSupported()) is.mark(READ_BUFFER); unpack (new InputStreamReader(is, charset), getSchema (baseSchema)); if (is.markSupported()) { is.reset(); is.skip (readCount); readCount = 0; } } catch (EOFException e) { if (!fields.isEmpty()) fields.put ("EOF", "true"); // some fields were read, but unexpected EOF found else // nothing new since last msg, fields were read; no more msgs from this stream throw e; // just rethrow the exception } } /**
@Test( expected = NullPointerException.class) public void testGetSchemaThrowsNullPointerException() throws Throwable { FSDMsg fSDMsg = new FSDMsg(null, "testFSDMsgBaseSchema"); fSDMsg.getSchema(); }
@Test( expected = MalformedURLException.class) public void testGetSchemaThrowsMalformedURLException() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); fSDMsg.getSchema(); }
@Test( expected = MalformedURLException.class) public void testGetSchemaThrowsMalformedURLException1() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); fSDMsg.getSchema("testFSDMsgMessage"); }
@Test( expected = NullPointerException.class) public void testGetSchemaThrowsNullPointerException1() throws Throwable { FSDMsg fSDMsg = new FSDMsg(null, "testFSDMsgBaseSchema"); fSDMsg.getSchema("testFSDMsgMessage"); }
unpack(r, getSchema (getId (schema), keyOff, defaultKey)); // recursion
pack (getSchema (getId (schema), keyOff, defaultKey), sb);