Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2009 eXo Platform SAS. This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 
 package org.exoplatform.groovyscript;
 
 import java.util.List;


Author(s):
Julien Viet
Version:
$Revision$
 
 public class TemplateSection {

    
.
 
     private final SectionType type;

    
.
 
     private final List<SectionItemitems;
 
     public TemplateSection(SectionType typeString text) {
         this(typetext, 0, 0);
     }
 
     public TemplateSection(SectionType typeString textPosition pos) {
         this(typetextpos.getCol(), pos.getLine());
     }
 
     public TemplateSection(SectionType typeString textint colNumberint lineNumber) {
         if (type == null) {
             throw new NullPointerException();
         }
         if (text == null) {
             throw new NullPointerException();
         }
 
         // Now we process the line breaks
         ArrayList<SectionItemsections = new ArrayList<SectionItem>();
 
         //
         int from = 0;
         while (true) {
             int to = text.indexOf('\n'from);
 
             //
             if (to != -1) {
                 String chunk = text.substring(fromto);
                 sections.add(new TextItem(new Position(colNumberlineNumber), chunk));
 
                 //
                 sections.add(new LineBreakItem(new Position(colNumber + (to - from), lineNumber)));
 
                 //
                 from = to + 1;
                 lineNumber++;
                 colNumber = 1;
             } else {
                 String chunk = text.substring(from);
                 sections.add(new TextItem(new Position(colNumberlineNumber), chunk));
                 break;
             }
         }
 
         //
         this. = type;
         this. = Collections.unmodifiableList(sections);
     }
 
     public SectionType getType() {
         return ;
     }
 
     public List<SectionItemgetItems() {
         return ;
     }
 
     @Override
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
         }
         if (obj instanceof TemplateSection) {
            TemplateSection that = (TemplateSectionobj;
            return  == that.type && .equals(that.items);
        }
        return false;
    }
    @Override
    public String toString() {
        return "TextSection[type=" +  + ",text=" +  + "]";
    }
New to GrepCode? Check out our FAQ X