Exemplo n.º 1
0
  CompositeSkin(SkinService service, Collection<SkinConfig> skins) {
    TreeMap<String, SkinConfig> urlSkins = new TreeMap<String, SkinConfig>();
    for (SkinConfig skin : skins) {
      urlSkins.put(skin.getCSSPath(), skin);
    }

    //
    final StringBuilder builder = new StringBuilder();
    builder.append("/portal/resource");

    //
    final StringBuilder id = new StringBuilder();

    //
    try {
      for (SkinConfig cfg : urlSkins.values()) {
        StringBuilder encodedName = new StringBuilder();
        Codec.encode(encodedName, cfg.getName());
        StringBuilder encodedModule = new StringBuilder();
        Codec.encode(encodedModule, cfg.getModule());

        //
        id.append(encodedName).append(encodedModule);
        builder.append("/").append(encodedName).append("/").append(encodedModule);
      }
    } catch (IOException e) {
      throw new Error(e);
    }

    //
    this.service = service;
    this.id = id.toString();
    this.urlPrefix = builder.toString();
  }
Exemplo n.º 2
0
 /**
  * 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));
 }
Exemplo n.º 3
0
  @Override
  public boolean encode(OutputByteStream payload, Object object, Object[] dependants) {

    if (length != Array.getLength(object)) {
      throw new IllegalArgumentException("The object is not an array of length " + length);
    }

    for (int i = 0; i < length; i++) {
      if (!codec.encode(payload, Array.get(object, i), dependants)) {
        return false;
      }
    }

    return true;
  }
Exemplo n.º 4
0
 public void encode(T value, BitChannel channel, Resolver resolver) throws IOException {
   delegate.encode(value, channel, resolver);
 }