Changeset 6617


Ignore:
Timestamp:
09/30/15 10:20:10 (9 years ago)
Author:
davor.ostojic@oeaw.ac.at
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.3-oeaw/vlo-vocabularies/src/main/java/eu/clarin/cmdi/vlo/transformers/VariantsMapMarshaller.java

    r6604 r6617  
    22
    33import java.io.InputStream;
    4 import java.io.InputStreamReader;
    54import java.io.OutputStream;
    6 import java.io.UnsupportedEncodingException;
    7 import java.nio.charset.StandardCharsets;
     5import java.util.Map;
    86
    97import javax.xml.bind.JAXBContext;
     
    1210import javax.xml.bind.Unmarshaller;
    1311
     12import org.slf4j.Logger;
     13import org.slf4j.LoggerFactory;
     14
    1415import eu.clarin.cmdi.vlo.pojo.VariantsMap;
    1516
    1617public class VariantsMapMarshaller {
    1718       
     19        private final static Logger LOG = LoggerFactory.getLogger(VariantsMapMarshaller.class);
    1820       
    19     public static VariantsMap unmarshal(InputStream input)throws JAXBException, UnsupportedEncodingException{
     21    public static VariantsMap unmarshal(InputStream input)throws JAXBException{
    2022        JAXBContext jc = JAXBContext.newInstance(VariantsMap.class);
    2123        Unmarshaller unmarshaller = jc.createUnmarshaller();
    22         InputStreamReader isr = new InputStreamReader(input, StandardCharsets.ISO_8859_1);
    23         return (VariantsMap) unmarshaller.unmarshal(isr);       
     24        return (VariantsMap) unmarshaller.unmarshal(input);       
    2425       
    2526    }
     
    2728   
    2829    public static void marshal(VariantsMap map, OutputStream output) throws JAXBException{
     30       
     31        Map<String, String> vocab = map.getInvertedMap();
     32        for(String key: vocab.keySet()){
     33                byte bytes[] = key.getBytes();
     34                         StringBuilder sb = new StringBuilder();
     35                            for (byte b : bytes)
     36                                sb.append(String.format("%02X ", b));
     37                           
     38                         LOG.info("Key <{} {}> will be mapped to <{}>", key, sb.toString(), vocab.get(key));
     39        }
     40       
    2941        JAXBContext jc = JAXBContext.newInstance(VariantsMap.class);
    3042       
Note: See TracChangeset for help on using the changeset viewer.