XMLResources implements Comparator<Object> { @Pure public Map<Long, Entry> getPairs() { return Collections.unmodifiableMap(Collections.synchronizedMap(this.resourcesFromIdentifiers)); } XMLResources(PathBuilder pathBuilder); @Override @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"}) @Pure int compare(Object o1, Object o2); @Pure static String getStringIdentifier(long identifier); @Pure static boolean isStringIdentifier(String str); @SuppressWarnings("checkstyle:magicnumber") @Pure static long getNumericalIdentifier(String identifier); synchronized String add(long identifier, URL url, String mimeType); synchronized String add(long identifier, File file, String mimeType); synchronized String add(long identifier, byte[] rawData, String mimeType); @Inline(value = "add($1, null)") final String add(URL url); @Inline(value = "add(-1, $1, $2)") final String add(URL url, String mimeType); @Inline(value = "add($1, null)") final String add(File file); @Inline(value = "add(-1, $1, $2)") final String add(File file, String mimeType); @Inline(value = "add($1, null)") final String add(byte[] rawData); @Inline(value = "add(-1, $1, $2)") final String add(byte[] rawData, String mimeType); synchronized long computeNextIdentifier(); @Pure final long getIdentifier(URL url); @Pure final long getIdentifier(File file); @Pure final long getIdentifier(byte[] rawData); @Pure final URL getResourceURL(long identifier); @Pure @Inline(value = "getResourceFromIdentifier($1)") final Entry getResource(long identifier); synchronized void remove(URL url); synchronized void remove(File file); synchronized void remove(byte[] rawData); synchronized void remove(long identifier); @Pure Map<Long, Entry> getPairs(); synchronized void clear(); static final String IDENTIFIER_PREFIX; }
@Test public void getPairs() throws Exception { Map<Long, XMLResources.Entry> pairs = this.xml.getPairs(); assertEquals(4, pairs.size()); XMLResources.Entry e; e = pairs.get(1l); assertNotNull(e); assertTrue(e.isEmbeddedData()); assertSame(this.data, e.getEmbeddedData()); assertNull(e.getFile()); assertNull(e.getURL()); assertEquals(MimeName.MIME_PDF.getMimeConstant(), e.getMimeType()); e = pairs.get(2l); assertNotNull(e); assertTrue(e.isFile()); assertEquals(new File("a.txt"), e.getFile()); assertNull(e.getURL()); assertNull(e.getEmbeddedData()); assertEquals(MimeName.MIME_PLAIN_TEXT.getMimeConstant(), e.getMimeType()); e = pairs.get(3l); assertNotNull(e); assertTrue(e.isURL()); assertEquals(new URL("file:b.txt"), e.getURL()); assertNull(e.getFile()); assertNull(e.getEmbeddedData()); assertEquals(MimeName.MIME_PLAIN_TEXT.getMimeConstant(), e.getMimeType()); e = pairs.get(4l); assertNotNull(e); assertTrue(e.isFile()); assertEquals(new File("a.jpg"), e.getFile()); assertNull(e.getURL()); assertNull(e.getEmbeddedData()); assertEquals(MimeName.MIME_JPG.getMimeConstant(), e.getMimeType()); }