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

Author(s):
Yana Panchenko
 
 @XmlType(propOrder = {
     "speechSignalLayer",
     "tokenSegmentationLayer",
     "phoneticSegmentationLayer",
     "canonicalSegmentationLayer",
     "namedEntityModelLayer"
 })
 public class ExternalDataStored implements ExternalData {
 
     public static final String XML_NAME = "ExternalData";
     public static final String XML_NAMESPACE = "http://www.dspin.de/data/extdata";
 
     public ExternalDataStored() {
          = new ExternalDataLayerStored[ExternalDataLayerTag.orderedLayerTags().size()];
     }
 
     @Override
     public List<ExternalDataLayergetLayers() {
         List<ExternalDataLayerallLayers = new ArrayList<ExternalDataLayer>(this..length);
         for (ExternalDataLayer layer : this.) {
             if (layer != null) {
                 allLayers.add(layer);
             }
         }
         return allLayers;
     }
 
     @Override
     public SpeechSignalLayer createSpeechSignalLayer(String mimeType) {
         SpeechSignalLayer layer = initializeLayer(SpeechSignalLayerStored.classmimeType);
         return layer;
     }
 
     @Override
     public SpeechSignalLayer createSpeechSignalLayer(String mimeTypeint numberOfChannels) {
         SpeechSignalLayer layer = initializeLayer(SpeechSignalLayerStored.class,
                 mimeTypenew Integer(numberOfChannels));
         return layer;
     }
 
     @Override
         TokenSegmentationLayer layer = initializeLayer(TokenSegmentationLayerStored.classmimeType);
         return layer;
     }
 
     @Override
         PhoneticSegmentationLayer layer = initializeLayer(PhoneticSegmentationLayerStored.classmimeType);
         return layer;
     }
 
     @Override
         CanonicalSegmentationLayer layer = initializeLayer(CanonicalSegmentationLayerStored.classmimeType);
         return layer;
     }
     
     @Override
     public NamedEntityModelLayer createNamedEntityModelLayer(String mimeTypeString neTypeString modelType) {
         NamedEntityModelLayer layer = initializeLayer(NamedEntityModelLayerStored.classmimeTypeneTypemodelType);
         return layer;
    }
    @SuppressWarnings("unchecked")
    private <T extends ExternalDataLayerStored> 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();
            }
        }
        ExternalDataLayerTag layerTag = ExternalDataLayerTag.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(connector);
        } catch (Exception e) {
            //  e.printStackTrace();
            Logger.getLogger(ExternalDataStored.class.getName()).log(.nulle);
        }
        return (T) [layerTag.ordinal()];
    }
    protected void setSpeechSignalLayer(SpeechSignalLayerStored layer) {
        //System.out.println(layer);
    }
    @Override
    }
        //System.out.println(layer);
    }
    @Override
    }
        //System.out.println(layer);
    }
    @Override
    }
        //System.out.println(layer);
    }
    @Override
    }
    
    protected void setNamedEntityModelLayer(NamedEntityModelLayerStored layer) {
        //System.out.println(layer);
    }
    
    @Override
    }
//		protected void afterUnmarshal(Unmarshaller u, Object parent) {
//			connectLayers();
//		}
//
//
//		protected void connectLayers() {
//			for (int i = 0; i < this.layersInOrder.length; i++) {
//				if (layersInOrder[i] != null) {
//					layersInOrder[i].setLayersConnector(connector);
//				}
//			}
//		}
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(":\n");
        for (ExternalDataLayer layer : this.) {
            if (layer != null) {
                sb.append(layer);
                sb.append("\n");
            }
        }
        return sb.toString().trim();
    }

    
Composes the layers into one document. Normally, you should not use this method, unless you want to manually compose document from the layer pieces.

Parameters:
layers
Returns:
external data composed of the provided layers
    public static ExternalDataStored compose(ExternalDataLayerStored... layers) {
        ExternalDataStored ed = new ExternalDataStored();
        for (ExternalDataLayerStored layer : layers) {
            ed.layersInOrder[ExternalDataLayerTag.getFromClass(layer.getClass()).ordinal()] = layer;
        }
        return ed;
    }
New to GrepCode? Check out our FAQ X