Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
wlfxb - a library for creating and processing of TCF data streams. Copyright (C) University of Tübingen. This file is part of wlfxb. This program 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 3 of the License, or (at your option) any later version. This program 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 program. If not, see <http://www.gnu.org/licenses/>.
 
 
 package eu.clarin.weblicht.wlfxb.tc.xb;
 
 import java.util.List;

Author(s):
Yana Panchenko
 
 //@XmlRootElement(name = TextSpanStored.XML_NAME)
 //@XmlAccessorType(XmlAccessType.NONE)
 //public class TextSpanStored implements TextSpan {
 //
 //    public static final String XML_NAME = "textspan";
 //    @XmlAttribute(name = CommonAttributes.START_TOKEN)
 //    protected String startToken;
 //    @XmlAttribute(name = CommonAttributes.END_TOKEN)
 //    protected String endToken;
 //    @XmlAttribute(name = CommonAttributes.TYPE)
 //    protected TextSpanType type;
 //
 //    @Override
 //    public TextSpanType getType() {
 //        return type;
 //    }
 //
 //    @Override
 //    public String toString() {
 //        StringBuilder sb = new StringBuilder(type.name());
 //        if (startToken != null && endToken != null) {
 //            sb.append(" ");
 //            sb.append(startToken);
 //            sb.append(" - ");
 //            sb.append(endToken);
 //        }
 //        return sb.toString();
 //    }
 //}
 
 public class TextSpanStored implements TextSpan {
 
     public static final String XML_NAME = "textspan";
     @XmlAttribute(name = "startChar")
     protected Integer startChar;
     @XmlAttribute(name = "endChar")
     protected Integer endChar;
     protected String startToken;
     protected String endToken;
     @XmlAttribute(name = .)
     protected String type;
     
     protected String value;
     protected List<TextSpanStoredsubspans;
     
     // temporary to hold unmarshalled objects before I can transfer them to fs or value
     private List<Objectcontent = new ArrayList<Object>();
     
     @XmlMixed
     @XmlElementRefs({
     @XmlElementRef(name = ., type = TextSpanStored.class)})
     protected List<ObjectgetContent() {
         List<ObjectcontentToMarshal = new ArrayList<Object>();
        if ( != null) {
            contentToMarshal.addAll();
        } else if ( != null) {
            contentToMarshal.add();
        } else {
            return null;
        }
        return contentToMarshal;
    }
    void setContent(List<Objectcontent) {
        this. = content;
    }
    protected void afterUnmarshal(Unmarshaller uObject parent) {
        for (Object obj : ) {
            if (obj instanceof String) {
                String v = ((Stringobj).trim();
                if ( == null && v.length() > 0) {
                     = v;
                    return;
                }
            } else if (obj instanceof TextSpanStored) {
                if ( == null) {
                     = new ArrayList<TextSpanStored>();
                }
                .add((TextSpanStoredobj);
            }
        }
    }
    @Override
    public String getType() {
        return ;
    }
    @Override
    public boolean isTerminal() {
        return ( == null || .isEmpty());
    }
    @Override
    public String getValue() {
        return ;
    }
    @Override
    public TextSpanStored[] getSubspans() {
        if ( == null) {
            return null;
        }
        return .toArray(new TextSpanStored[.size()]);
    }
    @Override
    public Integer getStartChar() {
        return ;
    }
    @Override
    public Integer getEndChar() {
        return ;
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        if ( != null) {
            sb.append();
            sb.append(" ");
        }
        if ( != null &&  != null) {
            sb.append(" ");
            sb.append();
            sb.append(" - ");
            sb.append();
        }
        if ( != null &&  != null) {
            sb.append(" ");
            sb.append();
            sb.append(" - ");
            sb.append();
        }
        if (isTerminal()) {
            sb.append();
        } else if ( != null && !.isEmpty()) {
            sb.append(.toString());
        }
        return sb.toString();
    }
    
New to GrepCode? Check out our FAQ X