Ejemplo n.º 1
0
  private static boolean validExtension(String[] extensions, String file) {

    String ext = ResourceUtil.getExtension(file, "");
    ext = railo.runtime.type.util.ListUtil.first(ext, "/", true);

    if (StringUtil.isEmpty(ext)) return true;
    for (int i = 0; i < extensions.length; i++) {
      if (ext.equalsIgnoreCase(extensions[i])) return true;
    }
    return false;
  }
Ejemplo n.º 2
0
  /**
   * @see
   *     railo.transformer.cfml.evaluator.EvaluatorSupport#evaluate(railo.transformer.bytecode.statement.tag.Tag,
   *     railo.transformer.library.tag.TagLibTag, railo.transformer.library.function.FunctionLib[])
   */
  public void evaluate(Tag tag, TagLibTag tagLibTag, FunctionLib[] flibs)
      throws EvaluatorException {
    String id = "sprite_" + IDGenerator.intId();
    try {
      Page page = ASMUtil.getAncestorPage(tag);
      String key = Md5.getDigestAsString(Thread.currentThread().getId() + ":" + page.getSource());
      Expression src = tag.getAttribute("src").getValue();

      // get data from previous sprites
      Previous previous = sprites.get(key);
      if (previous != null) {
        previous.tag.removeAttribute("_ids");
        previous.tag.removeAttribute("_srcs");
        previous.tag = tag;
      } else {
        sprites.put(key, previous = new Previous(tag));
      }

      previous.ids.add(id);
      if (previous.src == null) previous.src = src;
      else {
        previous.src = OpString.toExprString(previous.src, DELIMITER);
        previous.src = OpString.toExprString(previous.src, src);
      }

      tag.addAttribute(new Attribute(false, "_id", LitString.toExprString(id), "string"));
      tag.addAttribute(
          new Attribute(
              false,
              "_ids",
              LitString.toExprString(
                  railo.runtime.type.util.ListUtil.listToList(previous.ids, ",")),
              "string"));

      tag.addAttribute(new Attribute(false, "_srcs", previous.src, "string"));

    } catch (Throwable e) { // TODO handle Excpetion much more precise
      throw new PageRuntimeException(Caster.toPageException(e));
    }
  }
Ejemplo n.º 3
0
 public ContentTypeImpl(InputStream is) {
   String raw = IOUtil.getMimeType(is, null);
   String[] arr = ListUtil.listToStringArray(raw, '/');
   this.type = arr[0];
   this.subtype = arr[1];
 }