@Override public Set<Class<? extends java.lang.annotation.Annotation>> init(ProcessingContext env) { return Tools.<Class<? extends java.lang.annotation.Annotation>> set(Shiro.class, RequiresGuest.class, RequiresUser.class, RequiresAuthentication.class, RequiresPermissions.class, RequiresRoles.class, Login.class, Logout.class); }
private FileKey(String packageFQN, String rawName, String ext) { String name = rawName + "." + ext; String fqn; if (packageFQN.length() == 0) { fqn = rawName; } else { fqn = packageFQN + "." + rawName; } // String[] abc = Tools.split(packageFQN, '.', 1); abc[abc.length - 1] = name; // this.packageNames = Tools.iterable(abc, 0, abc.length - 1); this.names = Tools.iterable(abc, 0, abc.length); this.packageFQN = packageFQN; this.rawName = rawName; this.fqn = fqn; this.ext = ext; this.name = name; }
public void close() throws IOException { Tools.safeClose(applicationLifeCycle); applicationLifeCycle = null; } }
AnnotationMirror annotationMirror = Tools.getAnnotation(pkgElt, Less.class.getName()); Tools.safeClose(writer);
@Override public InputStream minify(String name, String type, InputStream stream) throws IOException { if (type.equals("script")) { NormalizeJSReader reader = new NormalizeJSReader(new InputStreamReader(stream)); String s = Tools.read(reader); return new ByteArrayInputStream(s.getBytes()); } else { throw new IOException("Can only process scripts and not " + type + " asset"); } } }
@Override public Iterable<String> getNames(String[] path) { return Tools.iterable(path); }
@Test public void test() throws Exception { init(); bootstrap.declareBean(Bean1.class, null, null, null); bootstrap.declareBean(Bean2.class, null, null, null); boot(); // ArrayList<B> beans = Tools.list(mgr.resolveBeans(AbstractBean.class)); assertEquals(2, beans.size()); HashSet<Class<?>> classes = new HashSet<Class<?>>(); for (B bean : beans) { I instance = mgr.createContext(bean); Object o = mgr.getInstance(bean, instance); classes.add(o.getClass()); } assertEquals(Tools.<Class<?>>set(Bean1.class, Bean2.class), classes); } }
@Test public void testIterableArray() { String[] a = {"a", "b"}; assertEquals(Collections.<String>emptyList(), Tools.list(Tools.iterable(a, 0, 0))); assertEquals(Arrays.asList("a"), Tools.list(Tools.iterable(a, 0, 1))); assertEquals(Arrays.asList("a", "b"), Tools.list(Tools.iterable(a, 0, 2))); assertEquals(Arrays.asList("b"), Tools.list(Tools.iterable(a, 1, 2))); }
public static byte[] bytes(URL url) throws IOException { return bytes(url.openStream()); }
@Override public void postProcessEvents(ApplicationMetaModel application) { // Do GC ElementHandle.Package pkg = application.getHandle(); String[] names = enabledMap.get(pkg); if (names != null) { PackageElement pkgElt = application.model.processingContext.get(pkg); AnnotationMirror am = Tools.getAnnotation(pkgElt, Portlet.class.getName()); if (am == null) { enabledMap.remove(pkg); toEmit.remove(pkg); } else { if (toEmit.contains(pkg)) { toEmit.remove(pkg); emitPortlet(application.model.processingContext, pkgElt, names); } } } }
public static void encodeHtmlText(CharSequence src, int from, int end, Appendable dst) throws IOException, IllegalArgumentException { encodeHtml(src, from, end, dst); }
dst.append(attr.getName()); dst.append("=\""); encodeHtmlAttribute(attr.getValue(), 0, attr.getValue().length(), dst); dst.append("\""); } else if (child instanceof CharacterData) { String data = ((CharacterData)child).getData(); encodeHtmlText(data, 0, data.length(), dst); } else if (child instanceof org.w3c.dom.Element) { encodeHtml((org.w3c.dom.Element)child, dst);
private Charset getRequestEncoding(Map<String, String> config) { String requestEncodingParam = config.get(REQUEST_ENCODING); if (requestEncodingParam != null) { requestEncodingParam = Tools.interpolate(requestEncodingParam, System.getProperties()); return Charset.forName(requestEncodingParam); } else { return Tools.ISO_8859_1; } } }
public static String read(Reader in) throws IOException { StringWriter buffer = new StringWriter(); copy(in, buffer); return buffer.toString(); }
public void close() throws IOException { Tools.safeClose(applicationLifeCycle); applicationLifeCycle = null; } }
AnnotationMirror annotationMirror = Tools.getAnnotation(pkgElt, Less.class.getName()); Tools.safeClose(writer);
@Override public InputStream minify(String name, String type, InputStream stream) throws IOException { if (type.equals("script")) { NormalizeJSReader reader = new NormalizeJSReader(new InputStreamReader(stream)); String s = Tools.read(reader); return new ByteArrayInputStream(s.getBytes()); } else { throw new IOException("Can only process scripts and not " + type + " asset"); } } }
@Override public Iterable<String> getNames(String[] path) { return Tools.iterable(path); }