Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // Copyright 2004, 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
 package org.apache.tapestry.components;
 
Defines a number of ways to format multi-line text for proper renderring.

Implementation taken from the now deprecated InsertTextMode class.

Author(s):
jkuhnert
 
 public abstract class InsertMode
 {
    
Mode where each line (after the first) is preceded by a <br> tag.
 
 
     public static final InsertMode BREAK = new BreakMode();

    
Mode where each line is wrapped with a <p> element.
 
 
     public static final InsertMode PARAGRAPH = new ParagraphMode();
     
     protected final String _name;
    
    
Creates a new instance with a name.

Parameters:
name Textual description of the mode.
 
     protected InsertMode(String name)
     {
          = name;
     }
     
     public String toString()
     {
         return "InsertMode[" +  + "]";
     }

    
Invoked by the Insert component to write the next line.

Parameters:
lineNumber the line number of the line, starting with 0 for the first line.
line the String for the current line.
writer the org.apache.tapestry.IMarkupWriter to send output to.
raw if true, then the output should be unfiltered
 
 
     public abstract void writeLine(int lineNumberString lineIMarkupWriter writerboolean raw);
    
    

Author(s):
hls
 
     private static final class BreakMode extends InsertMode
     {
         private BreakMode()
         {
             super("BREAK");
         }
 
         public void writeLine(int lineNumberString line,
                 IMarkupWriter writerboolean raw)
         {
             if (lineNumber > 0) 
                 writer.beginEmpty("br");
 
             writer.print(lineraw);
         }
     }

    

Author(s):
hls
 
     private static final class ParagraphMode extends InsertMode
    {
        private ParagraphMode()
        {
            super("PARAGRAPH");
        }
        
        public void writeLine(int lineNumberString line,
                IMarkupWriter writerboolean raw)
        {
            writer.begin("p");
            writer.print(lineraw);
            writer.end();
        }
    }
New to GrepCode? Check out our FAQ X