Example usage for javax.activation UnsupportedDataTypeException UnsupportedDataTypeException

List of usage examples for javax.activation UnsupportedDataTypeException UnsupportedDataTypeException

Introduction

In this page you can find the example usage for javax.activation UnsupportedDataTypeException UnsupportedDataTypeException.

Prototype

public UnsupportedDataTypeException(String s) 

Source Link

Document

Constructs an UnsupportedDataTypeException with the specified message.

Usage

From source file:Main.java

public static final Node copyElement(Node e) throws UnsupportedDataTypeException {
    Node result = null;//w  w w .j a va2  s .com

    switch (e.getNodeType()) {
    case Node.ELEMENT_NODE:
        result = document.createElement(e.getNodeName());

        for (int i = 0; i < e.getAttributes().getLength(); i++) {
            Attr attr = document.createAttribute(e.getAttributes().item(i).getNodeName());
            attr.setNodeValue(e.getAttributes().item(i).getNodeValue());
            result.getAttributes().setNamedItem(attr);
        }
        break;

    case Node.CDATA_SECTION_NODE:
        result = document.createCDATASection(((CDATASection) e).getData());
        break;
    case Node.TEXT_NODE:
        if (((Text) e).getTextContent().replaceAll("\t", "").trim() != "")
            result = document.createTextNode(((Text) e).getTextContent().replaceAll("\t", "").trim());
        break;

    default:
        throw new UnsupportedDataTypeException(new StringBuilder(e.getNodeType()).toString());
    }

    for (int i = 0; i < e.getChildNodes().getLength(); i++)
        result.appendChild(copyElement(e.getChildNodes().item(i)));

    return result;
}

From source file:com.mirth.connect.donkey.server.controllers.MessageController.java

public Attachment createAttachment(Object data, String type) throws UnsupportedDataTypeException {
    byte[] byteData;

    if (data instanceof byte[]) {
        byteData = (byte[]) data;
    } else if (data instanceof String) {
        byteData = StringUtil.getBytesUncheckedChunked((String) data, Constants.ATTACHMENT_CHARSET);
    } else {//from   w  w w .  j a v  a 2s. c o  m
        throw new UnsupportedDataTypeException("Attachment can be of type String or byte[]");
    }

    Attachment attachment = new Attachment();
    attachment.setId(UUID.randomUUID().toString());
    attachment.setContent(byteData);
    attachment.setType(type);
    return attachment;
}

From source file:com.bigtobster.pgnextractalt.chess.ChessIO.java

/**
 * Converts a PGN file into a list of Chesspresso games
 *
 * @param pgnFile The file pointing to a PGN file to import
 * @throws javax.activation.UnsupportedDataTypeException Throws exception in the event that passed file is not a PGN
 * @throws IOException                                   Filesystem issue with reading PGN file
 * @throws PGNSyntaxError                                Syntax error with readying PGN file
 *///  w  w  w  . j  a v a2s.com
public void importPGN(final File pgnFile) throws IOException, PGNSyntaxError, UnsupportedDataTypeException {
    final PGNReader pgnReader;
    final ArrayList<Game> games = new ArrayList<Game>(100);
    final FileInputStream fileInputStream;
    if (!PGNReader.isPGNFile(pgnFile.getPath())) {
        throw new UnsupportedDataTypeException("File at " + pgnFile.getPath() + " is not a PGN file");
    }
    fileInputStream = new FileInputStream(pgnFile);
    try {
        pgnReader = new PGNReader(new FileInputStream(pgnFile), pgnFile.getPath());
        Game game = pgnReader.parseGame();
        if (game == null) {
            throw new PGNSyntaxError(PGNSyntaxError.ERROR, "Empty PGN file!", pgnFile.getPath(), 0, "");
        }
        do {
            games.add(game);
            game = pgnReader.parseGame();
        } while (game != null);
        this.addGames(games);
    } finally {
        fileInputStream.close();
    }
}

From source file:com.mirth.connect.server.controllers.DefaultMessageObjectController.java

public Attachment createAttachment(Object data, String type) throws UnsupportedDataTypeException {
    byte[] byteData;

    if (data instanceof byte[]) {
        byteData = (byte[]) data;
    } else if (data instanceof String) {
        byteData = ((String) data).getBytes();
    } else {/*from   ww  w .  j ava 2 s.  co  m*/
        throw new UnsupportedDataTypeException("Attachment can be of type String or byte[]");
    }

    Attachment attachment = new Attachment();
    attachment.setAttachmentId(UUIDGenerator.getUUID());
    attachment.setData(byteData);
    attachment.setSize(byteData.length);
    attachment.setType(type);
    return attachment;
}

From source file:org.cloudifysource.usm.dsl.OpenspacesDomainUIAdapter.java

/**
 * Convert a DSL user interface POJO into an openspaces user interface POJO
 * @param userInterface//from w  w w  .j  a v a2 s . c om
 *          user interface DSL POJO.
 * @return
 *          the equivalent openspaces user interface object.
 * @throws UnsupportedDataTypeException 
 * @throws IllegalAccessException .
 * @throws InvocationTargetException .
 */
public org.openspaces.ui.UserInterface createOpenspacesUIObject(final UserInterface userInterface)
        throws IllegalAccessException, InvocationTargetException, UnsupportedDataTypeException {
    org.openspaces.ui.UserInterface ui = new org.openspaces.ui.UserInterface();
    final List<MetricGroup> metricGroups = userInterface.getMetricGroups();
    final List<org.openspaces.ui.MetricGroup> destMetricGroups = new ArrayList<org.openspaces.ui.MetricGroup>();
    final List<Object> destMetrics = new ArrayList<Object>();
    for (MetricGroup metricGroup : metricGroups) {
        final org.openspaces.ui.MetricGroup group = new org.openspaces.ui.MetricGroup();
        List<Object> metrics = metricGroup.getMetrics();
        for (Object metric : metrics) {
            if (metric instanceof List<?>) {
                @SuppressWarnings("unchecked")
                List<Object> metricDef = (List<Object>) metric;
                String metricName = metricDef.get(0).toString();
                org.openspaces.ui.Unit axisYUnit = getOpenspacesAxisYUnit((Unit) metricDef.get(1));
                final List<Object> destMatrix = new ArrayList<Object>();
                destMatrix.add(metricName);
                destMatrix.add(axisYUnit);
                destMetrics.add(destMatrix);
            } else {
                destMetrics.add(metric);
            }
        }

        group.setMetrics(destMetrics);
        group.setName(metricGroup.getName());
        destMetricGroups.add(group);
    }

    final List<WidgetGroup> widgetGroups = userInterface.getWidgetGroups();
    final List<org.openspaces.ui.WidgetGroup> destWidgetGroups = new ArrayList<org.openspaces.ui.WidgetGroup>();
    for (WidgetGroup widgetGroup : widgetGroups) {
        final org.openspaces.ui.WidgetGroup destGroup = new org.openspaces.ui.WidgetGroup();
        destGroup.setName(widgetGroup.getName());
        destGroup.setTtile(widgetGroup.getTitle());
        final List<Widget> widgets = widgetGroup.getWidgets();
        final List<org.openspaces.ui.Widget> destWidgets = new ArrayList<org.openspaces.ui.Widget>();
        for (Widget widget : widgets) {
            if (widget instanceof BarLineChart) {
                final org.openspaces.ui.BarLineChart chart = new org.openspaces.ui.BarLineChart();
                final Unit axisYUnit = ((BarLineChart) widget).getAxisYUnit();
                org.openspaces.ui.Unit destUnit = getOpenspacesAxisYUnit(axisYUnit);
                chart.setAxisYUnit(destUnit);
                chart.setMetric(((BarLineChart) widget).getMetric());
                destWidgets.add(chart);
            } else if (widget instanceof BalanceGauge) {
                org.openspaces.ui.BalanceGauge gauge = new org.openspaces.ui.BalanceGauge();
                BeanUtils.copyProperties(gauge, widget);
                destWidgets.add(gauge);
            } else {
                throw new UnsupportedDataTypeException(
                        "widget type: " + widget.getClass().getSimpleName() + " is not supported.");
            }
        }
        destGroup.setWidgets(destWidgets);
        destWidgetGroups.add(destGroup);
    }

    ui.setMetricGroups(destMetricGroups);
    ui.setWidgetGroups(destWidgetGroups);
    return ui;
}

From source file:org.cloudifysource.usm.dsl.OpenspacesDomainUIAdapter.java

private org.openspaces.ui.Unit getOpenspacesAxisYUnit(final Unit axisYUnit)
        throws UnsupportedDataTypeException {
    switch (axisYUnit) {
    case REGULAR:
        return org.openspaces.ui.Unit.REGULAR;
    case PERCENTAGE:
        return org.openspaces.ui.Unit.PERCENTAGE;
    case MEMORY:/*from w  w w.ja va  2s.c  om*/
        return org.openspaces.ui.Unit.MEMORY;
    case DURATION:
        return org.openspaces.ui.Unit.DURATION;
    default:
        throw new UnsupportedDataTypeException("Unit type " + axisYUnit.toString() + " is not supported");
    }
}

From source file:org.interpss.mapper.odm.impl.acsc.AbstractODMAcscDataMapper.java

private void setBusLoadEquivShuntY(ShortCircuitBusXmlType acscBusXml, AcscBus acscBus) {
    // at this point we assume that acscContributeLoadList has been consolidated to
    // the acscEquivLoad. The consolidation logic is implemented in AcscParserHelper.createBusScEquivLoadData()

    // we should not check condition here, since by arriving here acscLoadData should be of type ShortCircuitLoadDataXmlType 
    //if(acscBusXml.getLoadData().getEquivLoad().getValue() instanceof ShortCircuitLoadDataXmlType){

    ShortCircuitLoadDataXmlType acscLoadData = (ShortCircuitLoadDataXmlType) acscBusXml.getLoadData()
            .getEquivLoad().getValue();//w  w  w  . j  a  v a  2s . c o  m

    // 1) positive sequence 
    if (acscBus.isConstPLoad() || acscBus.isConstILoad()) {
        /*
         * Use unit voltage vmag=1.0 to initialize the equivalent shuntY
         * 
         * For load flow-based short circuit analysis, 
         *  equivY_actual = equivY_0/v^2   for Constant Power load
         *                = equivY_0/v    for Constant current load
         * 
         */
        Complex eqivShuntY1 = acscBus.getLoad().conjugate();
        acscBus.setScLoadShuntY1(eqivShuntY1);
    } else if (acscBus.isFunctionLoad()) {
        try {
            throw new UnsupportedDataTypeException(
                    "ZIP function load is not supported for converting to positive sequence shunt load");
        } catch (UnsupportedDataTypeException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    //2) Negative part
    //2.1) if sequence data provided, it represents all loads connected to the bus

    if (acscLoadData.getShuntLoadNegativeY() != null) {
        YXmlType y2 = acscLoadData.getShuntLoadNegativeY();
        UnitType unit = ToYUnit.f(y2.getUnit());
        Complex ypu = UnitHelper.yConversion(new Complex(y2.getRe(), y2.getIm()), acscBus.getBaseVoltage(),
                acscBus.getNetwork().getBaseKva(), unit, UnitType.PU);
        acscBus.setScLoadShuntY2(ypu);
    }
    //1.2) else, shuntY2 = shuntY1 for the constant MVA and/or current part.
    else {
        if (acscBus.isConstPLoad() || acscBus.isConstILoad()) {
            /*
             * Use unit voltage vmag=1.0 to initialize the equivalent shuntY
             * 
             * For load flow-based short circuit analysis, 
             *  equivY_actual = equivY_0/v^2   for Constant Power load
             *                = equivY_0/v    for Constant current load
             * 
             */
            Complex eqivShuntY2 = acscBus.getLoad().conjugate();
            acscBus.setScLoadShuntY2(eqivShuntY2);
        } else if (acscBus.isFunctionLoad()) {
            try {
                throw new UnsupportedDataTypeException(
                        "ZIP function load is not supported for converting to negative sequence shunt load");
            } catch (UnsupportedDataTypeException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }

    //2) Zero sequence part
    if (acscLoadData.getShuntLoadZeroY() != null) {
        YXmlType y0 = acscLoadData.getShuntLoadNegativeY();
        UnitType unit = ToYUnit.f(y0.getUnit());
        Complex ypu = UnitHelper.yConversion(new Complex(y0.getRe(), y0.getIm()), acscBus.getBaseVoltage(),
                acscBus.getNetwork().getBaseKva(), unit, UnitType.PU);
        acscBus.setScLoadShuntY0(ypu);
    }
    // If not provided ,then the load is open from the zero sequence network
    //}
}

From source file:org.interpss.mapper.odm.impl.acsc.AbstractODMAcscParserMapper.java

private void setBusLoadEquivShuntY(ShortCircuitBusXmlType acscBusXml, AcscBus acscBus) {
    // at this point we assume that acscContributeLoadList has been consolidated to
    // the acscEquivLoad. The consolidation logic is implemented in AcscParserHelper.createBusScEquivLoadData()

    // we should not check condition here, since by arriving here acscLoadData should be of type ShortCircuitLoadDataXmlType 
    //if(acscBusXml.getLoadData().getEquivLoad().getValue() instanceof ShortCircuitLoadDataXmlType){
    //System.out.println("proc equiv load of bus#"+acscBus.getId());   
    ShortCircuitLoadDataXmlType acscLoadData = AcscParserHelper.getDefaultScLoad(acscBusXml.getLoadData());

    // 1) positive sequence 
    if (acscBus.isConstPLoad() || acscBus.isConstILoad()) {
        /*/*w  w w.  j  a v  a 2  s .  co m*/
         * Use unit voltage vmag=1.0 to initialize the equivalent shuntY
         * 
         * For load flow-based short circuit analysis, 
         *  equivY_actual = equivY_0/v^2   for Constant Power load
         *                = equivY_0/v    for Constant current load
         * 
         */
        //TODO InterPSS ACSC algo will automatically calculate scLoadShuntY1 based on load flow or by setting v=1.0 
        //Complex eqivShuntY1= acscBus.getLoadPQ().conjugate();
        //acscBus.setScLoadShuntY1(eqivShuntY1);
    } else if (acscBus.isFunctionLoad()) {
        try {
            throw new UnsupportedDataTypeException(
                    "ZIP function load is not supported for converting to positive sequence shunt load");
        } catch (UnsupportedDataTypeException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    //2) Negative part
    //2.1) if sequence data provided, it represents all loads connected to the bus

    if (acscLoadData.getShuntLoadNegativeY() != null) {
        YXmlType y2 = acscLoadData.getShuntLoadNegativeY();
        UnitType unit = toYUnit.apply(y2.getUnit());
        Complex ypu = UnitHelper.yConversion(new Complex(y2.getRe(), y2.getIm()), acscBus.getBaseVoltage(),
                acscBus.getNetwork().getBaseKva(), unit, UnitType.PU);
        acscBus.setScLoadShuntY2(ypu);
    }
    //1.2) else, shuntY2 = shuntY1 for the constant MVA and/or current part.
    else {
        if (acscBus.isConstPLoad() || acscBus.isConstILoad()) {
            /*
             * Use unit voltage vmag=1.0 to initialize the equivalent shuntY
             * 
             * For load flow-based short circuit analysis, 
             *  equivY_actual = equivY_0/v^2   for Constant Power load
             *                = equivY_0/v    for Constant current load
             * 
             */
            //TODO InterPSS ACSC algo will automatically calculate scLoadShuntY2 if it is not provided. 
            //Complex eqivShuntY2= acscBus.getLoadPQ().conjugate();
            //acscBus.setScLoadShuntY2(eqivShuntY2);
        } else if (acscBus.isFunctionLoad()) {
            try {
                throw new UnsupportedDataTypeException(
                        "ZIP function load is not supported for converting to negative sequence shunt load");
            } catch (UnsupportedDataTypeException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }

    //2) Zero sequence part
    if (acscLoadData.getShuntLoadZeroY() != null) {
        YXmlType y0 = acscLoadData.getShuntLoadNegativeY();
        UnitType unit = toYUnit.apply(y0.getUnit());
        Complex ypu = UnitHelper.yConversion(new Complex(y0.getRe(), y0.getIm()), acscBus.getBaseVoltage(),
                acscBus.getNetwork().getBaseKva(), unit, UnitType.PU);
        acscBus.setScLoadShuntY0(ypu);
    }
    // If not provided ,then the load is open from the zero sequence network
    //}
}

From source file:org.pattern.api.MultiImageImporterFinder.java

/**
 * Finds importer to import data from images.
 * @param file file with images.//from   w  w  w  .ja  v  a 2 s  .  co m
 * @return data importer
 * @throws javax.activation.UnsupportedDataTypeException when no importer found
 */
public static MultiImageImporter findImporter(File file) throws UnsupportedDataTypeException {
    if (file.isDirectory())
        throw new IllegalStateException("Can't find importer for a directory");
    String extension = FilenameUtils.getExtension(file.getPath());

    for (MultiImageImporter importer : Lookup.getDefault().lookupAll(MultiImageImporter.class)) {
        if (importer.isSupporting(extension)) {
            return importer;
        }
    }

    throw new UnsupportedDataTypeException("No suitable data importer found!");
}

From source file:org.trend.hgraph.Properties.java

/**
 * transfer value to <code>K, V</code> generic types, based on its <code>PairStrategy</code> object.
 * @param key//from  w w w.ja v  a2s. c o m
 * @param value
 * @param strategy a <code>PairStrategy</code> object
 * @return a <code>Pair</code> with generic types
 * @throws UnsupportedDataTypeException
 */
static <K, V> Pair<K, V> keyValueToPair(String key, Object value, PairStrategy<K, V> strategy)
        throws UnsupportedDataTypeException {
    if (null == key || null == value)
        return null;
    Validate.notNull(strategy, "strategy shall always not be null");

    Pair<K, V> pair = null;
    if (value instanceof String) {
        pair = strategy.getStringPair(key, value.toString());
    } else if (value instanceof Integer) {
        pair = strategy.getIntPair(key, (Integer) value);
    } else if (value instanceof Long) {
        pair = strategy.getLongPair(key, (Long) value);
    } else if (value instanceof Float) {
        pair = strategy.getFloatPair(key, (Float) value);
    } else if (value instanceof Double) {
        pair = strategy.getDoublePair(key, (Double) value);
    } else if (value instanceof Boolean) {
        pair = strategy.getBooleanPair(key, (Boolean) value);
    } else if (value instanceof Short) {
        pair = strategy.getShortPair(key, (Short) value);
    } else if (value instanceof BigDecimal) {
        pair = strategy.getBigDecimalPair(key, (BigDecimal) value);
    } else {
        throw new UnsupportedDataTypeException("Not support data type for value:" + value);
    }
    return pair;
}