@Override public Enc pretty() { enc.indent("\t"); return this; }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws Exception { app.append("{"); app.indent(); String del = ""; for (int i = 0; i < fields.length; i++) try { if (fields[i].getName().startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException(fields[i].getName() +":", e); } app.undent(); app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws Exception { app.append("{"); app.indent(); String del = ""; for (int i = 0; i < fields.length; i++) try { if (fields[i].getName() .startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } catch (Exception e) { throw new IllegalArgumentException(fields[i].getName() + ":", e); } app.undent(); app.append("}"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws Exception { app.append("{"); app.indent(); String del = ""; for (int i = 0; i < fields.length; i++) try { if (fields[i].getName().startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException(fields[i].getName() +":", e); } app.undent(); app.append("}"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws Exception { app.append("{"); app.indent(); String del = ""; for (int i = 0; i < fields.length; i++) try { if (fields[i].getName().startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException(fields[i].getName() +":", e); } app.undent(); app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws Exception { app.append("{"); app.indent(); String del = ""; for (int i = 0; i < fields.length; i++) try { if (fields[i].getName().startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException(fields[i].getName() +":", e); } app.undent(); app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws Exception { app.append("{"); app.indent(); String del = ""; for (int i = 0; i < fields.length; i++) try { if (fields[i].getName().startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException(fields[i].getName() +":", e); } app.undent(); app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws Exception { app.append("{"); app.indent(); String del = ""; for (int i = 0; i < fields.length; i++) try { if (fields[i].getName() .startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } catch (Exception e) { throw new IllegalArgumentException(fields[i].getName() + ":", e); } app.undent(); app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws Exception { app.append("{"); app.indent(); String del = ""; for (int i = 0; i < fields.length; i++) try { if (fields[i].getName().startsWith("__")) continue; Object value = fields[i].get(object); if (!app.writeDefaults) { if (value == defaults[i]) continue; if (value != null && value.equals(defaults[i])) continue; } app.append(del); StringHandler.string(app, fields[i].getName()); app.append(":"); app.encode(value, types[i], visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException(fields[i].getName() +":", e); } app.undent(); app.append("}"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if (object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch (Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if (object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch (Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if ( object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if ( object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if ( object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if ( object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if (object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch (Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if ( object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if ( object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { // Byte arrays should not be treated as arrays. We treat them // as hex strings if ( object instanceof byte[]) { StringHandler.string(app, Hex.toHexString((byte[]) object)); return; } app.append("["); app.indent(); String del = ""; int l = Array.getLength(object); for (int i = 0; i < l; i++) try { app.append(del); app.encode(Array.get(object, i), componentType, visited); del = ","; } catch( Exception e) { throw new IllegalArgumentException("[" + i + "]", e); } app.undent(); app.append("]"); }
private void index(HttpServletResponse rsp) throws Exception { Bundle b = context.getBundle(); URL url = cache.internalUrlOf(b, "osgi/enroute/web/index.html"); CacheFile c = cache.getFromBundle(b, url, "osgi/enroute/web/index.html"); if (c == null || c.is404 || c.isNotFound()) { url = cache.internalUrlOf(b, "osgi/enroute/web/local/index.html"); c = cache.getFromBundle(b, url, "osgi/enroute/web/local/index.html"); } String content = IO.collect(c.file); Map<String,String> map = new HashMap<>(); synchronized (index) { map.put("index", new JSONCodec().enc().put(index).indent(" ").toString()); } ReplacerAdapter ra = new ReplacerAdapter(map); content = ra.process(content); IO.store(content, rsp.getOutputStream()); }