Package org.w3c.jigsaw.html

Examples of org.w3c.jigsaw.html.HtmlGenerator


         HttpExtList copt)
  throws org.w3c.tools.resources.ProtocolException
    {
  if (cman != null) {
      Reply error = request.makeReply(HTTP.NOT_EXTENDED) ;
      HtmlGenerator content = new HtmlGenerator("Error");
      content.append("<h1>Mandatory extension(s) not supported:",
         "</h1><p>\n");
      content.append("<ul>\n");
      HttpExt exts[] = cman.getHttpExts();
      for (int i=0 ; i < exts.length ; i++)
    content.append("<li> "+exts[i].getName()+"\n");
      content.append("</ul>\n");
      error.setStream(content);
      return error;
  }
  return null;
    }
View Full Code Here


//     setStatus(SC_SEE_OTHER);
//       } else {
    setStatus(SC_MOVED_TEMPORARILY);
//      }
      reply.setLocation(loc);
      HtmlGenerator g = new HtmlGenerator("Moved");
      g.append("<P>This resource has moved, click on the link if your"
         + " browser doesn't support automatic redirection<BR>"+
         "<A HREF=\""+loc.toExternalForm()+"\">"+
         loc.toExternalForm()+"</A>");
      reply.setStream(g);
  } catch (Exception ex) {
View Full Code Here

  Reply   rep = null;
  if (checkHeaders(req)) {
      return null;
  }
  rep = req.makeReply(HTTP.FORBIDDEN);
  HtmlGenerator g = new HtmlGenerator("Forbidden - Headers missing");
  g.append("Some Headers, mandatory for this resource, are missing.");
  if (sendHeaderList && (headerNames != null)) {
      g.append("<ul>");
      for (int i=0; i<headerNames.length; i++) {
    g.append("<li>");
    g.appendAndEscape(headerNames[i]);
    g.append("</li>");
      }
      g.append("</ul>");
  }
  rep.setStream(g);
  return rep;
    }
View Full Code Here

  Request request = (Request) req;
  int limit = getLimit();

  if (request.getURL().toExternalForm().length() > limit) {
      Reply error = request.makeReply(HTTP.REQUEST_URI_TOO_LONG);
      HtmlGenerator g = new HtmlGenerator("Request URI Too Long");
      g.append ("Your request should have an URI of less than " +
          limit + " bytes");
      error.setStream(g);
      return error;
  }
  return null;
View Full Code Here

  newdiff.append(diff);
  return newdiff.toString();
    }

    protected HtmlGenerator parseLog (String log) {
  HtmlGenerator g = getHtmlGenerator("CVS log of "+name);
  String CVSURL = getCvsURL();
  String head =
      "[ <a href=\"./../\">Up to directory</a> ] &middot; "+
      "[ <a href=\""+CVSURL+"\">Back to CVS</a> ]";

  g.append("<center>",head,"<hr noshade width=\"80%\"></center><p>");
  g.append ("<span class=\"title\"> CVS log of ",name,"</span>\n");
  g.append ("<div class=\"box\"><pre>\n");
  //parse the log string
  ByteArrayOutputStream out =
      new ByteArrayOutputStream();
  byte unparsed[] = log.getBytes();
  int byteIdx = 0;
  int startIdx = 0;
  byte ch;
  byteIdx += 7;
  do {
      while(byteIdx < unparsed.length) {
    if( (ch = unparsed[byteIdx]) == (byte) 'n' ) {
        if(byteArrayNEquals(unparsed, byteIdx-7,
          pattern, 0,
          7)) {
      break;
        }
    }
    byteIdx += increments[ch>=0 ? ch : 0];
      }
      if(++byteIdx >= unparsed.length)
    break;
      //we just found 'revision'
      while ((byteIdx <= unparsed.length) &&
       isSpace(unparsed[byteIdx])) {
    byteIdx++;
      }
      out.write(unparsed, startIdx, byteIdx-startIdx);
      startIdx = byteIdx;
      //get the revision number
      while ((byteIdx <= unparsed.length) &&
       isDigitOrPoint(unparsed[byteIdx])) {
    byteIdx++;
      }
      //revision number startIdx, byteIdx-1;
      if (byteIdx-1 > startIdx) {
    String rev = new String(unparsed,
          startIdx,
          byteIdx-startIdx);
    try {
        checkRevisionNumber(rev);
        writeLinks(out, unparsed, startIdx, byteIdx-startIdx);
    } catch (Exception ex) {
        out.write(unparsed, startIdx, byteIdx-startIdx);
    }
      }
      startIdx = byteIdx;
  } while (byteIdx < unparsed.length) ;
  // Add the last chunk of unparsed text
  int length = unparsed.length-startIdx-1;
  if (length > 0)
      out.write(unparsed, startIdx, length);
  String parsedlog = out.toString();
  g.append(parsedlog);
  //end of parsing
  g.append ("\n</pre></div>\n");
  g.append("<hr noshade width=\"80%\"><center>",head,"</center><p>");
  return g;
    }
View Full Code Here

  if ( debug )
      printNegotiationState ("After Q selection:", states) ;
  if ( qmax == REQUIRED_QUALITY ) {

      Reply reply = request.makeReply(HTTP.NOT_ACCEPTABLE) ;
       HtmlGenerator g = new HtmlGenerator("No acceptable");
       g.append("<P>The resource cannot be served according to the "
          + "headers sent</P>");
       reply.setStream (g) ;
      throw new HTTPException (reply) ;
  } else if ( states.size() == 1 ) {
      return ((VariantState) states.elementAt(0)).getResource() ;
  } else {
      // Respond with multiple choice (for the time being, there should
      // be a parameter to decide what to do.
      Reply reply = request.makeReply(HTTP.MULTIPLE_CHOICE) ;
      HtmlGenerator g = new HtmlGenerator ("Multiple choice for "+
             resource.getIdentifier()) ;
      g.append ("<ul>") ;
      for (int i = 0 ; i < states.size() ; i++) {
    VariantState state = (VariantState) states.elementAt(i) ;
    String name = null;
    ResourceReference rr = state.getResource();
    try {
        name = rr.unsafeLock().getIdentifier();
        g.append ("<li>"
            + "<a href=\"" + name + "\">" + name + "</a>"
            + " Q= " + state.getQ()) ;
    } catch (InvalidResourceException ex) {
        //FIXME
    } finally {
View Full Code Here

      }
  }
  // now we have multiple choice :(
  String name;
  Reply reply = request.makeReply(HTTP.MULTIPLE_CHOICE) ;
  HtmlGenerator g = new HtmlGenerator ("Multiple choice for "+
               resource.getIdentifier()) ;
  g.append ("<ul>") ;
  for (int i = 0 ; i < variants.length ; i++) {
      if (variants[i] != null) {
    try {
        name = variants[i].unsafeLock().getIdentifier();
        g.append ("<li>"
            + "<a href=\"" + name + "\">" +name+ "</a>");
    } catch (InvalidResourceException ex) {
        //FIXME (this should NOT happen :) )
    } finally {
        variants[i].unlock();
View Full Code Here

  if ( debug )
      printNegotiationState ("After Q selection:", states) ;
  if ( qmax == REQUIRED_QUALITY ) {

      Reply reply = request.makeReply(HTTP.NOT_ACCEPTABLE) ;
       HtmlGenerator g = new HtmlGenerator("No acceptable");
       g.append("<P>The resource cannot be served according to the "
          + "headers sent</P>");
       reply.setStream (g) ;
      throw new HTTPException (reply) ;
  } else if ( states.size() == 1 ) {
      return ((VariantState) states.elementAt(0)).getResource() ;
  } else {
      // Respond with multiple choice (for the time being, there should
      // be a parameter to decide what to do.
      Reply reply = request.makeReply(HTTP.MULTIPLE_CHOICE) ;
      HtmlGenerator g = new HtmlGenerator ("Multiple choice for "+
             resource.getIdentifier()) ;
      g.append ("<ul>") ;
      for (int i = 0 ; i < states.size() ; i++) {
    VariantState state = (VariantState) states.elementAt(i) ;
    String name = null;
    ResourceReference rr = state.getResource();
    try {
        name = rr.unsafeLock().getIdentifier();
        g.append ("<li>"
            + "<a href=\"" + name + "\">" + name + "</a>"
            + " Q= " + state.getQ()) ;
    } catch (InvalidResourceException ex) {
        //FIXME
    } finally {
View Full Code Here

      }
  }
  // now we have multiple choice :(
  String name;
  Reply reply = request.makeReply(HTTP.MULTIPLE_CHOICE) ;
  HtmlGenerator g = new HtmlGenerator ("Multiple choice for "+
               resource.getIdentifier()) ;
  g.append ("<ul>") ;
  for (int i = 0 ; i < variants.length ; i++) {
      if (variants[i] != null) {
    try {
        name = variants[i].unsafeLock().getIdentifier();
        g.append ("<li>"
            + "<a href=\"" + name + "\">" +name+ "</a>");
    } catch (InvalidResourceException ex) {
        //FIXME (this should NOT happen :) )
    } finally {
        variants[i].unlock();
View Full Code Here

     * </ul>
     * @param title The document title.
     * @return a HtmlGenerator instance.
     */
    public static HtmlGenerator getHtmlGenerator(String title) {
  HtmlGenerator g = new HtmlGenerator(title);
  g.addStyle("BODY {color: black; background: white; "+
       "font-family: serif; margin-top: 35px }\n");
  addStyle(g);
  return g;
    }
View Full Code Here

TOP

Related Classes of org.w3c.jigsaw.html.HtmlGenerator

Copyright © 2018 www.massapicom. 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.