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.lx.xb;
 
 import java.util.List;

Author(s):
Yana Panchenko
 
 public class SynonymsLayerStored extends TermsContainerStored implements SynonymsLayer {
 
     public static final String XML_NAME = "synonyms";
     @XmlElement(name = .)
     private List<SynonymStoredsyns = new ArrayList<SynonymStored>();
 
     protected SynonymsLayerStored() {
     }
 
     protected SynonymsLayerStored(LexiconLayersConnector connector) {
         super(connector);
     }
 
     @Override
     protected void setLayersConnector(LexiconLayersConnector connector) {
         super.setLayersConnector(connector);
         for (SynonymStored syn : ) {
             connect(syn);
         }
     }
 
     @Override
     public boolean isEmpty() {
         return .isEmpty();
     }
 
     @Override
     public int size() {
         return .size();
     }
 
     @Override
     public Synonym getSynonym(int index) {
         return .get(index);
     }
     
     @Override
     public Synonym[] getSynonyms(Entry entry) {
         List<Synonymlist = ..get(entry);
         if (list != null) {
             return list.toArray(new Synonym[list.size()]);
         } else {
             return new Synonym[]{};
         }
     }
     
     @Override
     public Entry[] getEntries(Synonym synonym) {
         if (synonym instanceof SynonymStored) {
             SynonymStored syn = (SynonymStoredsynonym;
             List<Entryentries = new ArrayList<Entry>();
             for (TermStored t : syn.terms) {
                 if (t.entryId != null) {
                     entries.add(..get(t.entryId));
                 }
             }
             return entries.toArray(new Entry[entries.size()]);
         } else {
             return null;
         }
     }
 
     @Override
    public String[] getTermsAsStrings(Synonym synonymboolean includeAnnotatedTerm) {
        if (synonym instanceof SynonymStored) {
            SynonymStored syn = (SynonymStoredsynonym;
            return super.getTermsAsStrings(syn.termsincludeAnnotatedTerm);
        } else {
            return null;
        }
    }
    @Override
    public Synonym addSynonym(List<Termterms) {
        SynonymStored syn = new SynonymStored();
        for (Term term : terms) {
            if (term instanceof TermStored) {
                syn.terms.add((TermStoredterm);
            }
        }
        connect(syn);
        .add(syn);
        return syn;
    }
    private void connect(SynonymStored syn) {
        for (TermStored term : syn.terms) {
            if (term.entryId != null) {
                Entry entry = ..get(term.entryId);
                if (!..containsKey(entry)) {
                    ..put(entrynew ArrayList<Synonym>());
                }
                ..get(entry).add(syn);
            }
        }
    }
    @Override
    public Synonym addSynonym(Sig sigList<Termterms) {
        SynonymStored syn = (SynonymStoredaddSynonym(terms);
        if (sig instanceof SigStored) {
            syn.sig = (SigStoredsig;
        }
        return syn;
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(" : ");
        sb.append(.toString());
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X