public Resource resolve(String path) { if (path.startsWith("/portal/resource/") && path.endsWith(".css")) { final StringBuffer sb = new StringBuffer(); String encoded = path.substring("/portal/resource/".length()); String blah[] = encoded.split("/"); int len = (blah.length >> 1) << 1; for (int i = 0; i < len; i += 2) { String name = Codec.decode(blah[i]); String module = Codec.decode(blah[i + 1]); SkinKey key = new SkinKey(module, name); SkinConfig skin = skins.get(key); if (skin != null) { sb.append("@import url(").append(skin.getCSSPath()).append(");").append("\n"); } } return new Resource(path) { @Override public Reader read() { return new StringReader(sb.toString()); } }; } else { return null; } }
/** * CcBase64 can encode and decode. * * @throws IOException If some problem inside */ @Test public void encodesAndDecodes() throws IOException { final String urn = "urn:test:Hello World!"; final Map<String, String> properties = ImmutableMap.of("userName", "user"); final Codec codec = new CcBase64(new CcPlain()); final Identity expected = codec.decode(codec.encode(new Identity.Simple(urn, properties))); MatcherAssert.assertThat(expected.urn(), Matchers.equalTo(urn)); MatcherAssert.assertThat(expected.properties(), Matchers.equalTo(properties)); }
@Override public Object decode(InputByteStream payload, Object[] dependants) throws IOException { Object array = Array.newInstance(type, length); for (int i = 0; i < length; i++) { Array.set(array, i, codec.decode(payload, dependants)); } return array; }
public T decode(BitBuffer buffer, Resolver resolver, Builder builder, boolean debug) throws DecodingException { return delegate.decode(buffer, resolver, builder, debug); }