Examples of ImageTag


Examples of br.com.caelum.tubaina.parser.html.ImageTag

    //  In HTML, the answer is kept below the question, not in a extra book. Therefore, there's no
    // need to copy them.
  }

  public void copyImage(File srcImage, String attribs) {
    Integer scale = new ImageTag().getScale(attribs);
   
    if (srcImage.exists()) {
      File destinationFile = new File(this.imageDestinationPath, FilenameUtils.getName(srcImage.getPath()));
      if (!destinationFile.exists()) {
       
View Full Code Here

Examples of br.com.caelum.tubaina.parser.html.desktop.ImageTag

    //  In HTML, the answer is kept below the question, not in a extra book. Therefore, there's no
    // need to copy them.
  }

  public void copyAndScaleImage(File srcImage, String attribs) {
    Double scale = new Double(new ImageTag(null).getScale(attribs));
    boolean shouldResize = new ImageTag(null).shouldResize(attribs);
    boolean tooBig = false;
   
    if (srcImage.exists()) {
      File destinationFile = new File(this.imageDestinationPath, FilenameUtils.getName(srcImage.getPath()));
      if (!destinationFile.exists()) {
View Full Code Here

Examples of br.com.caelum.tubaina.parser.latex.ImageTag

    this.parser = parser;
    this.noAnswer = noAnswer;
  }

  public void copyImage(File srcImage, String scale) {
    Integer width = new ImageTag().getScale(scale);
    if (srcImage.exists()) {
      File destinationPath = new File(this.imagePath, FilenameUtils.getName(srcImage.getPath()));
      if (!destinationPath.exists()) {
        try {
          if (width == null && Utilities.getImageWidth(srcImage) > PAGE_WIDTH) {
View Full Code Here

Examples of org.htmlparser.tags.ImageTag

      Node[] images = parser.extractAllNodesThatMatch(HtmlNodeFilters.imageFilter).toNodeArray();
      for(int i=0;images!=null&&i<images.length;i++){
        int start_pos = images[i].getStartPosition();
        content.append(desc.substring(last_pos, start_pos));
        last_pos = images[i].getEndPosition();
        ImageTag img = (ImageTag)images[i];
        String img_url = img.getImageURL();
        if(!img_url.startsWith("http://")&&!img_url.startsWith("https://")){       
          if(img_url.startsWith("/")){
            int idx = link.indexOf("/", 7);
            img.setImageURL(link.substring(0, idx) + img_url);
          }
          else{
            int idx = link.lastIndexOf('/');
            img.setImageURL(link.substring(0, idx) + '/' + img_url);
          }
        }
        content.append(img.toHtml());
        //System.out.println(img.getImageURL());
      }
    }catch(Exception e){}
    content.append(desc.substring(last_pos));
    return content.toString();
View Full Code Here

Examples of org.htmlparser.tags.ImageTag

                  Parser parser = new Parser();
                  parser.setInputHTML(new String(mailContent.getBytes(), ISO8859_1));
                    //Parser parser = Parser.createParser(new String(mailContent.getBytes(), ISO8859_1));
                    Node[] images = parser.extractAllNodesThatMatch(HtmlNodeFilters.imageFilter).toNodeArray();
                    for(int i=0;i<images.length;i++) {
                        ImageTag imgTag = (ImageTag) images[i];
                        if(!imgTag.getImageURL().toLowerCase().startsWith("http://"))
                            arrayList1.add(imgTag.getImageURL());
                    }
                } catch (UnsupportedEncodingException e1) {
                } catch (ParserException e) {}
                String afterReplaceStr = mailContent;
                //��html�ļ�����"cid:"+Content-ID���滻ԭ����ͼƬ����
View Full Code Here

Examples of org.htmlparser.tags.ImageTag

    int nImgs = oCollectionList.size();

    if (DebugFile.trace) DebugFile.writeln("Images NodeList.size() = " + String.valueOf(nImgs));

    for (int i=0; i<nImgs; i++) {
    ImageTag oImgTag = (ImageTag) oCollectionList.elementAt(i);
     
        sSrc = oImgTag.extractImageLocn().replace('\\','/');
   
    if (DebugFile.trace) DebugFile.writeln("Processing image location "+sSrc);
   
        // Keep a reference to every related image name so that the same image is not included twice in the message
        if (!oImgs.containsKey(sSrc)) {

          // Find last slash from image url
          iSlash = sSrc.lastIndexOf('/');
     
          // Take image name
          if (iSlash>=0) {
            while (sSrc.charAt(iSlash)=='/') { if (++iSlash==sSrc.length()) break; }
              sCid = sSrc.substring(iSlash);
          }
          else {
            sCid = sSrc;
          }
          if (DebugFile.trace) DebugFile.writeln("HashMap.put("+sSrc+","+sCid+")");

          oImgs.put(sSrc, sCid);
        } // fi (!oImgs.containsKey(sSrc))
       
        sBodyCid = doSubstitution (sBodyCid, "Src", Gadgets.replace(Gadgets.replace(oImgTag.extractImageLocn(),'\\',"\\\\"),'.',"\\x2E"), sPreffix+oImgs.get(sSrc));
    } // next

  // **********************************************************************
  // Replace <TABLE BACKGROUND="..." >
   
View Full Code Here

Examples of org.htmlparser.tags.ImageTag

    Pattern oPattern;
    String sTag, sCid;
    int iSlash;

    if (oNode instanceof ImageTag) {
      ImageTag oImgNode = (ImageTag) oNode;
      String sSrc = oImgNode.extractImageLocn();

      try {
        oPattern = oCompiler.compile(sSrc);
      } catch (MalformedPatternException neverthrown) {
        if (DebugFile.trace) DebugFile.writeln("MalformedPatternException "+sSrc);
        oPattern=null;
      }

      iSlash = sSrc.lastIndexOf('/');
      if (iSlash>=0) {
        while (sSrc.charAt(iSlash)=='/') { if (++iSlash==sSrc.length()) break; }
        sCid = sSrc.substring(iSlash);
      } else {
        sCid = sSrc;
      } // fi
   
      if (!oDocumentImages.containsKey(sCid)) {

       if (DebugFile.trace) DebugFile.writeln("HashMap.put(" + sSrc + "," + sCid + ")");

        oDocumentImages.put(sCid, sSrc);
      } // fi (oDocumentImages.containsKey(sCid))

    sTag = oImgNode.toHtml(true);

    if (DebugFile.trace) DebugFile.writeln("Util.substitute([Perl5Matcher], "+oPattern.getPattern()+", new Perl5Substitution(cid:"+oDocumentImages.get(sCid)+", Perl5Substitution.INTERPOLATE_ALL)"+", "+sTag+ ", Util.SUBSTITUTE_ALL)");

    oBuffer.append(Util.substitute(oMatcher, oPattern,
                                   new Perl5Substitution("cid:"+sCid,
View Full Code Here

Examples of org.htmlparser.tags.ImageTag

                    }
                } catch (MalformedURLException e1) {
                    throw new HTMLParseException(e1);
                }
            } else if (tag instanceof ImageTag) {
                ImageTag image = (ImageTag) tag;
                binUrlStr = image.getImageURL();
            } else if (tag instanceof AppletTag) {
                // look for applets

                // This will only work with an Applet .class file.
                // Ideally, this should be upgraded to work with Objects (IE)
                // and archives (.jar and .zip) files as well.
                AppletTag applet = (AppletTag) tag;
                binUrlStr = applet.getAppletClass();
            } else if (tag instanceof InputTag) {
                // we check the input tag type for image
                if (ATT_IS_IMAGE.equalsIgnoreCase(tag.getAttribute(ATT_TYPE))) {
                    // then we need to download the binary
                    binUrlStr = tag.getAttribute(ATT_SRC);
                }
            } else if (tag instanceof LinkTag) {
                LinkTag link = (LinkTag) tag;
                if (link.getChild(0) instanceof ImageTag) {
                    ImageTag img = (ImageTag) link.getChild(0);
                    binUrlStr = img.getImageURL();
                }
            } else if (tag instanceof ScriptTag) {
                binUrlStr = tag.getAttribute(ATT_SRC);
                // Bug 51750
            } else if (tag instanceof FrameTag || tagname.equalsIgnoreCase(TAG_IFRAME)) {
View Full Code Here

Examples of org.htmlparser.tags.ImageTag

                        throw new HTMLParseException(e1);
                    }
                }
                else if (node instanceof ImageTag)
                {
                    ImageTag image= (ImageTag)node;
                    binUrlStr= image.getImageURL();
                }
                else if (node instanceof AppletTag)
                {
                    AppletTag applet= (AppletTag)node;
                    binUrlStr= applet.getAppletClass();
                }
                else if (node instanceof InputTag)
                {
                    InputTag input= (InputTag)node;
                    // we check the input tag type for image
                    String strType= input.getAttribute("type");
                    if (strType != null && strType.equalsIgnoreCase("image"))
                    {
                        // then we need to download the binary
                        binUrlStr= input.getAttribute("src");
                    }
        } else if (node instanceof LinkTag){
          LinkTag link = (LinkTag)node;
          if (link.getChild(0) instanceof ImageTag){
            ImageTag img = (ImageTag)link.getChild(0);
            binUrlStr = img.getImageURL();
          }
        } else if (node instanceof ScriptTag){
          ScriptTag script = (ScriptTag)node;
          binUrlStr = script.getAttribute("src");
        } else if (node instanceof LinkTagTag){
View Full Code Here

Examples of org.htmlparser.tags.ImageTag

        assertTrue(
            "Second data node shouls be a String Node",
            dataNode[1] instanceof StringNode);

        // Check the contents of each data node
        ImageTag imageTag = (ImageTag) dataNode[0];
        assertEquals(
            "Image URL",
            "http://www.yahoo.com/abcd.jpg",
            imageTag.getImageURL());
        StringNode stringNode = (StringNode) dataNode[1];
        assertEquals("String Contents", "Hello World", stringNode.getText());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.