Package org.eclipse.jetty.server

Examples of org.eclipse.jetty.server.ResourceCache$Content


    public TemplateContext(String key, Server server,Resource baseResource, ClassLoader libLoader) throws IOException
    {
        _server=server;
        _baseResource=baseResource;
        _mimeTypes=new MimeTypes();
        _resourceCache=new ResourceCache(null,baseResource,_mimeTypes,false,false);
       
        String[] patterns = (String[])_server.getAttribute(WebAppContext.SERVER_SRV_CLASSES);
        _serverClasses=new ClasspathPattern(patterns==null?WebAppContext.__dftServerClasses:patterns);
        patterns = (String[])_server.getAttribute(WebAppContext.SERVER_SYS_CLASSES);
        _systemClasses=new ClasspathPattern(patterns==null?WebAppContext.__dftSystemClasses:patterns);
View Full Code Here


            if (instance_webapp.exists())
            {  
                context.setBaseResource(new ResourceCollection(instance_webapp,shared.getBaseResource()));

                // Create the resource cache
                ResourceCache cache = new ResourceCache(shared.getResourceCache(),instance_webapp,context.getMimeTypes(),false,false);
                context.setAttribute(ResourceCache.class.getCanonicalName(),cache);
            }
            else
            {
                context.setBaseResource(shared.getBaseResource());
View Full Code Here

       
        try
        {
            if (_cache==null && (max_cached_files!=-2 || max_cache_size!=-2 || max_cached_file_size!=-2))
            {
                _cache= new ResourceCache(null,this,_mimeTypes,_useFileMappedBuffer,_etags);

                if (max_cache_size>=0)
                    _cache.setMaxCacheSize(max_cache_size);
                if (max_cached_file_size>=-1)
                    _cache.setMaxCachedFileSize(max_cached_file_size);
View Full Code Here

       
        try
        {
            if (_cache==null && max_cached_files>0)
            {
                _cache= new ResourceCache(null,this,_mimeTypes,_useFileMappedBuffer,_etags);

                if (max_cache_size>0)
                    _cache.setMaxCacheSize(max_cache_size);
                if (max_cached_file_size>=-1)
                    _cache.setMaxCachedFileSize(max_cached_file_size);
View Full Code Here

    sentence+="\t\t\t<s snum=\""+String.valueOf(s)+"\">\n";
    ArrayList<Content> stack=new ArrayList<Content>();
    stack.addAll(body.getContent());
    while(stack.size()>0)
    {
      Content c=stack.get(0);
      stack.remove(0);
      if(c.getCType().equals(CType.Text))//actual text
      {
        //a dot creates a new sentence after processing
        String line=c.getValue().trim();
        while(!line.equals(""))
        {         
          int idx=line.indexOf(" ");
          String words;
          if(idx>=0)
            words=line.substring(0,idx);
          else
            words=line;
          line=line.substring(words.length()).trim();
          String punct=words.replaceAll("\\p{Punct}","�");
          int index=0;
          while(!punct.equals(""))
          {
            idx=punct.indexOf("�");
            String word;
            if(idx>=0)
              word=punct.substring(0,idx);
            else
              word=punct;
            if(word.equals(""))
            {
              //first the punctuation then the word
              //add a punc node
             
              if(words.charAt(index)=='<')
              {
                sentence+="\t\t\t\t<punc>&lt;</punc>\n";
              }
              else
              {
                if(words.charAt(index)=='>')
                  sentence+="\t\t\t\t<punc>&gt;</punc>\n";
                else
                  sentence+="\t\t\t\t<punc>"+words.charAt(index)+"</punc>\n";
              }
              if(words.charAt(index)=='.')
              {
                sentence+=("\t\t\t</s>\n");
                if(sentence.contains("wf"))
                {
                  System.out.print(".");
                  s++;
                  paragraph+=sentence;
                }
                sentence="\t\t\t<s snum=\""+String.valueOf(s)+"\">\n";
              }
              index++;
              punct=punct.substring(1);
            }
            else
            {
              index+=word.length();
              sentence+="\t\t\t\t<wf cmd=\"tag\" pos=\"\" lemma=\""+word+"\" wnsn=\"0\" lexsn=\"NA\">";
              sentence+=word;
              sentence+="</wf>\n";
              punct=punct.substring(word.length());
            }
             
          }
           
        }
      }
      if(c.getCType().equals(CType.Element))//other html elements such a or table should extract the text inside these elements
      {
        Element current=(Element)c;
        //tr creates a new sentence after processing
        String href=current.getAttributeValue("href");
     
View Full Code Here

        //
        //  Go through the children
        //
        for( Iterator i = ce.getContent().iterator(); i.hasNext(); )
        {
            Content c = (Content)i.next();
           
            if( c instanceof PluginContent )
            {
                PluginContent pc = (PluginContent)c;
               
View Full Code Here

            //
            //  In many cases these are the same.  [linktext|linkref].
            //
            if( VariableManager.isVariableLink( linktext ) )
            {
                Content el = new VariableContent(linktext);

                addElement( el );
            }
            else if( isExternalLink( linkref ) )
            {
View Full Code Here

            int idxOfFirstContent = 0;
            int count = 0;

            for( Iterator i = kids.iterator(); i.hasNext(); count++ )
            {
                Content c = (Content) i.next();
                if( c instanceof Element )
                {
                    String name = ((Element)c).getName();
                    if( isBlockLevel(name) ) break;
                }

                if( !(c instanceof ProcessingInstruction) )
                {
                    ls.add( c );
                    if( idxOfFirstContent == 0 ) idxOfFirstContent = count;
                }
            }

            //
            //  If there were any elements, then add a new <p> (unless it would
            //  be an empty one)
            //
            if( ls.size() > 0 )
            {
                Element newel = new Element("p");

                for( Iterator i = ls.iterator(); i.hasNext(); )
                {
                    Content c = (Content) i.next();

                    c.detach();
                    newel.addContent(c);
                }

                //
                // Make sure there are no empty <p/> tags added.
View Full Code Here

          xsw.close();
          String expect = sw.toString();
         
          StAXStreamBuilder sbuilder = new StAXStreamBuilder();
         
      Content backagain = sbuilder.fragment(
          sinfactory.createXMLStreamReader(new StringReader(expect)));

      // convert the input to a SAX Stream

      sw.getBuffer().setLength(0);
          xsw = soutfactory.createXMLStreamWriter(sw);
          switch(content.getCType()) {
            case CDATA :
                  xout.output((CDATA)backagain, xsw);
                  break;
            case Text:
                  xout.output((Text)backagain, xsw);
                  break;
            case Comment:
                  xout.output((Comment)backagain, xsw);
                  break;
            case DocType:
                  xout.output((DocType)backagain, xsw);
                  break;
            case Element:
                  xout.output((Element)backagain, xsw);
                  break;
            case EntityRef:
                  xout.output((EntityRef)backagain, xsw);
                  break;
            case ProcessingInstruction:
                  xout.output((ProcessingInstruction)backagain, xsw);
                  break;
            default:
              throw new IllegalStateException(backagain.getCType().toString());
          }
          xsw.close();
         
          String actual = sw.toString();
          assertEquals(expect, actual);
View Full Code Here

      // OK, we have text-like content to push back.
      // and it still has values in it.
      // advance the cursor
      multitext.mpos++;
     
      final Content ret = multitext.ctext[multitext.mpos] == null
          ? multitext.data[multitext.mpos] : null;

     
      // we can calculate the hasnext
      hasnext = multitext.mpos + 1 < multitext.msize ||
          multitext.nextcursor < size;
     
      // return null to indicate text content.
      return ret;
    }
   
    // non-text, increment and return content.
    final Content ret = content.get(cursor++);
   
    // OK, we are returning some content.
    // we need to determine the state of the next loop.
    // cursor at this point has been advanced!
    if (cursor >= size) {
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.server.ResourceCache$Content

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.