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) Yana Panchenko. 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;
 

Author(s):
Yana Panchenko
 
 @XmlType(propOrder = {
     "lemmasLayer",
     "posTagsLayer",
     "frequenciesLayer",
     "relationsLayer",})
 public class LexiconStored implements Lexicon {
 
     public static final String XML_NAME = "Lexicon";
     public static final String XML_NAMESPACE = "http://www.dspin.de/data/lexicon";
     @XmlAttribute
     protected String lang;
     private LexiconLayersConnector connector;
 
     LexiconStored() {
          = new LexiconLayersConnector();
          = new LexiconLayerStoredAbstract[LexiconLayerTag.orderedLayerTags().size()];
     }
 
     public LexiconStored(String language) {
         this();
         this. = language;
     }
 
     public String getLanguage() {
         return ;
     }
 
     public LemmasLayer createLemmasLayer() {
         return initializeLayer(LemmasLayerStored.class);
     }
 
     public PosTagsLayer createPosTagsLayer(String tagset) {
         return initializeLayer(PosTagsLayerStored.classtagset);
     }
 
         return initializeLayer(FrequenciesLayerStored.class);
     }
 
     public RelationsLayer createRelationsLayer() {
         return initializeLayer(RelationsLayerStored.class);
     }
 
     @SuppressWarnings("unchecked")
     private <T extends LexiconLayerStoredAbstract> T initializeLayer(Class<T> layerClassObject... params) {
 
         Class<?>[] paramsClass = null;
         if (params != null) {
             paramsClass = new Class<?>[params.length];
             for (int i = 0; i < params.lengthi++) {
                 paramsClass[i] = params[i].getClass();
             }
         }
 
         LexiconLayerTag layerTag = LexiconLayerTag.getFromClass(layerClass);
         try {
             Constructor<?> ct;
             T instance;
             if (params == null) {
                 ct = layerClass.getDeclaredConstructor();
                instance = (T) ct.newInstance();
            } else {
                ct = layerClass.getDeclaredConstructor(paramsClass);
                instance = (T) ct.newInstance(params);
            }
            [layerTag.ordinal()] = instance;
            instance.setLayersConnector();
        } catch (Exception e) {
            //e.printStackTrace();
            Logger.getLogger(LexiconStored.class.getName()).log(.nulle);
        }
        return (T) [layerTag.ordinal()];
    }
    protected void setLemmasLayer(LemmasLayerStored layer) {
        [..ordinal()] = layer;
    }
    public LemmasLayerStored getLemmasLayer() {
    }
    protected void setPosTagsLayer(PosTagsLayerStored layer) {
        [..ordinal()] = layer;
    }
    }
    protected void setFrequenciesLayer(FrequenciesLayerStored layer) {
        [..ordinal()] = layer;
    }
    }
    protected void setRelationsLayer(RelationsLayerStored layer) {
        [..ordinal()] = layer;
    }
    }
    protected void afterUnmarshal(Unmarshaller uObject parent) {
        connectLayers();
    }
//		protected boolean beforeMarshal(Marshaller m) {
//			setEmptyLayersToNull();
//			return true;
//		}
//		
//
//		/**
//		 * 
//		 */
//		private void setEmptyLayersToNull() {
//			
//			for (int i = 0; i < this.layersInOrder.length; i++) {
//				if (layersInOrder[i] != null && layersInOrder[i].isEmpty()) {
//					layersInOrder[i] = null;
//				}
//			}
//		}
    protected void connectLayers() {
        for (int i = 0; i < this..lengthi++) {
            if ([i] != null) {
                [i].setLayersConnector();
            }
        }
    }
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(":\n");
        for (LexiconLayer layer : this.) {
            if (layer != null) {
                sb.append(layer);
                sb.append("\n");
            }
        }
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X