Example usage for java.lang CloneNotSupportedException printStackTrace

List of usage examples for java.lang CloneNotSupportedException printStackTrace

Introduction

In this page you can find the example usage for java.lang CloneNotSupportedException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static void main(String[] args) {

    DataFlavor df = DataFlavor.stringFlavor;

    try {/*from w w w.j a v  a2  s . c o  m*/
        System.out.println(df.clone());
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static Object clone(Object obj) {
    try {//from   www  .  j  a  v a2  s  .c  om
        return CloneUtils.clone(obj);
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.thinkbiganalytics.util.PartitionKey.java

public static PartitionKey[] partitionKeysForTableAlias(PartitionKey[] keys, String alias) {
    List<PartitionKey> partitionKeys = new ArrayList<>();

    Arrays.stream(keys).forEach(key -> {
        try {//from www  . j  a  va 2s.  c o m
            PartitionKey clonedKey = (PartitionKey) key.clone();
            clonedKey.setAlias(alias);
            partitionKeys.add(clonedKey);
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    });
    return partitionKeys.toArray(new PartitionKey[0]);
}

From source file:gov.gtas.svc.util.TargetingResultUtils.java

/**
 * Eliminates duplicates and adds flight id, if missing.
 * /*  ww w . jav a 2  s.c  o  m*/
 * @param result
 * @return
 */
public static RuleServiceResult ruleResultPostProcesssing(RuleServiceResult result) {
    logger.info("Entering ruleResultPostProcesssing().");
    // get the list of RuleHitDetail objects returned by the Rule Engine
    List<RuleHitDetail> resultList = result.getResultList();

    // create a Map to eliminate duplicates
    Map<RuleHitDetail, RuleHitDetail> resultMap = new HashMap<>();

    if (logger.isInfoEnabled()) {
        logger.info("Number of rule hits --> " + resultList.size());
    }
    for (RuleHitDetail rhd : resultList) {
        if (rhd.getFlightId() == null) {
            // get all the flights for the passenger
            // and replicate the RuleHitDetail object, for each flight id
            // Note that the RuleHitDetail key is (UdrId, EngineRuleId,
            // PassengerId, FlightId)
            Collection<Flight> flights = rhd.getPassenger().getFlights();
            if (flights != null && !CollectionUtils.isEmpty(flights)) {
                try {
                    for (Flight flight : flights) {
                        RuleHitDetail newrhd = rhd.clone();
                        processPassengerFlight(newrhd, flight.getId(), resultMap);
                    }
                } catch (CloneNotSupportedException cnse) {
                    cnse.printStackTrace();
                }
            } else {
                // ERROR we do not have flights for this passenger
                logger.error(
                        "TargetingServiceUtils.ruleResultPostProcesssing() no flight information for passenger  with ID:"
                                + rhd.getPassenger().getId());
            }
        } else {
            processPassengerFlight(rhd, rhd.getFlightId(), resultMap);
        }
        rhd.setPassenger(null);
    }
    // Now create the return list from the set, thus eliminating duplicates.
    RuleServiceResult ret = new BasicRuleServiceResult(new LinkedList<RuleHitDetail>(resultMap.values()),
            result.getExecutionStatistics());
    logger.info("Exiting ruleResultPostProcesssing().");
    return ret;
}

From source file:gov.gtas.svc.util.TargetingResultCaseMgmtUtils.java

/**
 * Eliminates duplicates and adds flight id, if missing.
 *
 * @param result// www. j a  v  a2s  .  c  o m
 * @return
 */
public static RuleServiceResult ruleResultPostProcesssing(RuleServiceResult result,
        CaseDispositionService dispositionService) {
    logger.info("Entering ruleResultPostProcesssing().");
    // get the list of RuleHitDetail objects returned by the Rule Engine
    List<RuleHitDetail> resultList = result.getResultList();

    // create a Map to eliminate duplicates
    Map<RuleHitDetail, RuleHitDetail> resultMap = new HashMap<>();

    if (logger.isInfoEnabled()) {
        logger.info("Number of rule hits --> " + resultList.size());
    }
    for (RuleHitDetail rhd : resultList) {
        if (rhd.getFlightId() == null) {
            // get all the flights for the passenger
            // and replicate the RuleHitDetail object, for each flight id
            // Note that the RuleHitDetail key is (UdrId, EngineRuleId,
            // PassengerId, FlightId)
            Collection<Flight> flights = rhd.getPassenger().getFlights();
            if (flights != null && !CollectionUtils.isEmpty(flights)) {
                try {
                    for (Flight flight : flights) {
                        RuleHitDetail newrhd = rhd.clone();
                        processPassengerFlight(newrhd, flight.getId(), resultMap, dispositionService);
                    }
                } catch (CloneNotSupportedException cnse) {
                    cnse.printStackTrace();
                }
            } else {
                // ERROR we do not have flights for this passenger
                logger.error(
                        "TargetingServiceUtils.ruleResultPostProcesssing() no flight information for passenger  with ID:"
                                + rhd.getPassenger().getId());
            }
        } else {
            processPassengerFlight(rhd, rhd.getFlightId(), resultMap, dispositionService);
        }
        rhd.setPassenger(null);
    }
    // Now create the return list from the set, thus eliminating duplicates.
    RuleServiceResult ret = new BasicRuleServiceResult(new LinkedList<RuleHitDetail>(resultMap.values()),
            result.getExecutionStatistics());
    logger.info("Exiting ruleResultPostProcesssing().");
    return ret;
}

From source file:org.blockartistry.mod.Restructured.assets.Assets.java

public static WeightTable<SchematicWeightItem> getTableForVillageGen() {
    final WeightTable<SchematicWeightItem> table = new WeightTable<SchematicWeightItem>();
    for (final SchematicWeightItem e : villageSchematics.getEntries()) {
        try {//from  w  w w  .jav a2 s  .c o  m
            table.add((SchematicWeightItem) e.clone());
        } catch (final CloneNotSupportedException e1) {
            e1.printStackTrace();
        }
    }

    return table;
}

From source file:org.blockartistry.mod.Restructured.assets.Assets.java

public static WeightTable<SchematicWeightItem> getTableForWorldGen(int dimId, BiomeGenBase biome) {

    final WeightTable<SchematicWeightItem> table = new WeightTable<SchematicWeightItem>();
    for (final SchematicWeightItem e : worldSchematics.getEntries()) {
        final SchematicProperties p = e.properties;
        if (p.dimensions.isOk(dimId) && p.biomes.isOk(biome.biomeID))
            try {
                table.add((SchematicWeightItem) e.clone());
            } catch (final CloneNotSupportedException e1) {
                e1.printStackTrace();
            }/*from  ww w.  j  a v  a2  s  . c o m*/
    }

    return table;
}

From source file:org.kalypso.model.wspm.tuhh.schema.simulation.BreakLinesWriter.java

private static GM_Curve thinnedOutClone(final GM_Curve curve, final Double epsThinning,
        final String gmlVersion) {
    try {//from  w  w w .  j  ava  2s.  co  m
        if (epsThinning > 0.0) {
            // TODO thin out: sollten "Zwangspunkte" wie Marker fr Trennflchen / durchstrmte Bereiche erhalten
            // bleiben?
            return GeometryUtilities.getThinnedCurve(curve, epsThinning);
        } else {
            final IMarshallingTypeHandler lineStringTypeHandler = MarshallingTypeRegistrySingleton
                    .getTypeRegistry().getTypeHandlerForTypeName(GM_LineString.LINE_STRING_ELEMENT);
            final Object cloneObject = lineStringTypeHandler.cloneObject(curve, gmlVersion);
            return (GM_Curve) cloneObject;
        }
    } catch (final CloneNotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (final GM_Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return curve;
}

From source file:org.rhq.plugins.mobicents.servlet.sip.ConvergedWarDiscoveryHelper.java

public static Set<DiscoveredResourceDetails> initPluginConfigurations(
        JBossASServerComponent parentJBossASComponent, Set<DiscoveredResourceDetails> warResources) {

    EmsConnection jmxConnection = parentJBossASComponent.getEmsConnection();
    File configPath = parentJBossASComponent.getConfigurationPath();
    File logDir = new File(configPath, "log");
    File rtLogDir = new File(logDir, "rt");

    List<String> objectNames = new ArrayList<String>();

    // Create a List of objectNames that will be passed to DeploymentUtility.
    for (DiscoveredResourceDetails resourceDetails : warResources) {
        Configuration warConfig = resourceDetails.getPluginConfiguration();
        PropertySimple objectNameProperty = warConfig.getSimple(MBeanResourceComponent.OBJECT_NAME_PROP);
        objectNames.add(objectNameProperty.getStringValue());
    }/*from   ww  w .j  ava2s  .  c o  m*/

    Map<String, List<WarDeploymentInformation>> deploymentInformations = ConvergedDeploymentUtility
            .getConvergedWarDeploymentInformation(jmxConnection, objectNames);

    Set<DiscoveredResourceDetails> resultingResources = new HashSet<DiscoveredResourceDetails>();

    for (Iterator<DiscoveredResourceDetails> warResourcesIterator = warResources
            .iterator(); warResourcesIterator.hasNext();) {
        DiscoveredResourceDetails discoResDetail = warResourcesIterator.next();
        Configuration warConfig = discoResDetail.getPluginConfiguration();
        PropertySimple objectNameProperty = warConfig.getSimple(MBeanResourceComponent.OBJECT_NAME_PROP);
        List<WarDeploymentInformation> deploymentInfoList = null;

        if (deploymentInformations != null) {
            deploymentInfoList = deploymentInformations.get(objectNameProperty.getStringValue());
        }

        if (deploymentInfoList != null) {
            /*
             * Loop over the list elements and create new resources for all the vhosts
             * that are not localhost. This is needed so that the majority of installed
             * webapps will just be found with their existing key in case of an update.
             */
            for (WarDeploymentInformation info : deploymentInfoList) {
                String vhost = info.getVHost();
                LOG.debug("vHost " + vhost);
                if ("localhost".equals(vhost)) {
                    initPluginConfiguration(info, rtLogDir, warResourcesIterator, discoResDetail);
                    resultingResources.add(discoResDetail);
                } else {
                    DiscoveredResourceDetails myDetail;
                    String key = discoResDetail.getResourceKey();
                    key += ",vhost=" + vhost;

                    Configuration configClone;
                    try {
                        configClone = discoResDetail.getPluginConfiguration().clone();
                    } catch (CloneNotSupportedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        configClone = new Configuration();
                    }

                    myDetail = new DiscoveredResourceDetails(discoResDetail.getResourceType(), key,
                            discoResDetail.getResourceName(), discoResDetail.getResourceVersion(),
                            discoResDetail.getResourceDescription() + " on (" + vhost + ")", configClone,
                            discoResDetail.getProcessInfo());

                    initPluginConfiguration(info, rtLogDir, warResourcesIterator, myDetail);
                    resultingResources.add(myDetail); // the cloned one
                }
            }
        } else {
            // WAR has no associated context root, so remove it from the list of discovered resources...
            // @todo Might not want to call remove, because, as an example, in EC, the EC war file would end up being removed because this happens before it is completely deployed
            warResourcesIterator.remove();

            if (!discoResDetail.getResourceName().equals(ROOT_WEBAPP_RESOURCE_NAME)) {
                LOG.debug("The deployed WAR '" + discoResDetail.getResourceName()
                        + "' does not have a jboss.web MBean (i.e. context root) associated with it; it will not be added to inventory.");
            }
        }
    }
    return resultingResources;
}

From source file:de.fosd.jdime.stats.ASTStats.java

public static ASTStats add(final ASTStats a, final ASTStats b) {
    ASTStats sum = null;/*w ww.  j  ava  2s.  c  o m*/
    try {
        sum = (ASTStats) a.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    sum.add(b);
    return sum;
}