當前位置: 首頁>>代碼示例>>Java>>正文


Java InvalidClassException.printStackTrace方法代碼示例

本文整理匯總了Java中java.io.InvalidClassException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java InvalidClassException.printStackTrace方法的具體用法?Java InvalidClassException.printStackTrace怎麽用?Java InvalidClassException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.InvalidClassException的用法示例。


在下文中一共展示了InvalidClassException.printStackTrace方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initAppData

import java.io.InvalidClassException; //導入方法依賴的package包/類
/**
 * 初始化應用數據
 */
private String initAppData() {
    PreferenceHelper.loadDefaults();
    //TODO 測試,待刪除
    if (PreferenceHelper.getSharedPreferences().getBoolean(WeatherSettings.SETTINGS_FIRST_USE.getId(), false)) {
        try {
            PreferenceHelper.savePreference(WeatherSettings.SETTINGS_CURRENT_CITY_ID, "101020100");
            PreferenceHelper.savePreference(WeatherSettings.SETTINGS_FIRST_USE, false);
        } catch (InvalidClassException e) {
            e.printStackTrace();
        }
    }
    Log.d(TAG, "importCityData start");
    CityDBUtil.importCityData();
    Log.d(TAG, "importCityData end");
    return null;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:WelcomeActivity.java

示例2: main

import java.io.InvalidClassException; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    setup();

    try (URLClassLoader ldr =
        new URLClassLoader(new URL[]{ new URL("file:foo.jar") },
                PackageAccessTest.class.getClassLoader())) {
        bcl = Class.forName("B", true, ldr);
        dcl = Class.forName("D", true, ldr);

        Object b = bcl.newInstance();
        try {
            swizzle(b);
            throw new Error("expected InvalidClassException for class B");
        } catch (InvalidClassException e) {
            System.out.println("caught " + e);
            e.printStackTrace();
        }
        if (A.packagePrivateConstructorInvoked) {
            throw new Error("package private constructor of A invoked");
        }

        Object d = dcl.newInstance();
        swizzle(d);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:PackageAccessTest.java

示例3: getSimilarityBetweenClusters

import java.io.InvalidClassException; //導入方法依賴的package包/類
/** Calculates the similarity between two clusters. In this algorithm the 
 * maximum similarity over all pairs of the two clusters is used.
 *@param sClusterOne The first cluster.
 *@param sClusterTwo The second cluster.
 *@param clDistanceCalculator The calculator of distance between set elements.
 *@return The similarity between the clusters.
 */
protected double getSimilarityBetweenClusters(Set sClusterOne, Set sClusterTwo, 
        SimilarityComparatorListener clDistanceCalculator) {
    Distribution dDistances = new Distribution();
    
    // For every object in cluster one
    Iterator iFirstCluster = sClusterOne.iterator();
    int iCnt = 0;
    
    while (iFirstCluster.hasNext()) {
        Object oFirst = iFirstCluster.next();

        // For every object in cluster two
        Iterator iSecondCluster = sClusterTwo.iterator();
        while (iSecondCluster.hasNext()) {
            Object oSecond = iSecondCluster.next();
            ISimilarity sSimil;
            // Compare the objects
            try {
                synchronized (oFirst) {
                    synchronized (oSecond) {
                        sSimil = clDistanceCalculator.getSimilarityBetween(oFirst, 
                                oSecond);
                    }
                }
            } catch (InvalidClassException ex) {
                System.err.println("Cannot compare " + oFirst.toString() + " to " + 
                        oSecond.toString() + ". Cause:");
                ex.printStackTrace(System.err);
                continue;
            }
            // Put id of pair and their similarity in distance distribution
            dDistances.setValue(iCnt++, sSimil.getOverallSimilarity());                    
        }
    }
    
    // Return the maximum similarity
    return dDistances.maxValue();
}
 
開發者ID:ayushoriginal,項目名稱:Ngram-Graphs,代碼行數:46,代碼來源:SingleLinkClusterer.java

示例4: getSimilarityBetweenClusters

import java.io.InvalidClassException; //導入方法依賴的package包/類
/** Calculates the similarity between two clusters. In this algorithm the 
 * average similarity between all pairs of the two clusters is used.
 *@param sClusterOne The first cluster.
 *@param sClusterTwo The second cluster.
 *@param clDistanceCalculator The calculator of distance between set elements.
 *@return The similarity between the clusters.
 */
protected double getSimilarityBetweenClusters(Set sClusterOne, Set sClusterTwo, 
        SimilarityComparatorListener clDistanceCalculator) {
    Distribution dDistances = new Distribution();
    
    // For every object in cluster one
    Iterator iFirstCluster = sClusterOne.iterator();
    int iCnt = 0;
    while (iFirstCluster.hasNext()) {
        Object oFirst = iFirstCluster.next();

        // For every object in cluster two
        Iterator iSecondCluster = sClusterTwo.iterator();
        while (iSecondCluster.hasNext()) {
            Object oSecond = iSecondCluster.next();
            ISimilarity sSimil;
            // Compare the objects
            try {
                synchronized (oFirst) {
                    synchronized (oSecond) {
                        sSimil = clDistanceCalculator.getSimilarityBetween(oFirst, 
                                oSecond);
                    }
                }
            } catch (InvalidClassException ex) {
                System.err.println("Cannot compare " + oFirst.toString() + " to " + 
                        oSecond.toString() + ". Cause:");
                ex.printStackTrace(System.err);
                continue;
            }
            // Put id of pair and their similarity in distance distribution
            dDistances.setValue(iCnt++, sSimil.getOverallSimilarity());                    
        }
    }
    
    // Return the maximum similarity, which is actually the average of distance between elements.
    return dDistances.average(true);
}
 
開發者ID:ayushoriginal,項目名稱:Ngram-Graphs,代碼行數:45,代碼來源:AverageLinkClusterer.java

示例5: getSimilarityBetweenClusters

import java.io.InvalidClassException; //導入方法依賴的package包/類
/** Calculates the similarity between two clusters. In this algorithm the 
 * minimum similarity between all pairs of the two clusters is used.
 *@param sClusterOne The first cluster.
 *@param sClusterTwo The second cluster.
 *@param clDistanceCalculator The calculator of distance between set elements.
 *@return The similarity between the clusters.
 */
protected double getSimilarityBetweenClusters(Set sClusterOne, Set sClusterTwo, 
        SimilarityComparatorListener clDistanceCalculator) {
    Distribution dDistances = new Distribution();
    
    // For every object in cluster one
    Iterator iFirstCluster = sClusterOne.iterator();
    int iCnt = 0;
    while (iFirstCluster.hasNext()) {
        Object oFirst = iFirstCluster.next();

        // For every object in cluster two
        Iterator iSecondCluster = sClusterTwo.iterator();
        while (iSecondCluster.hasNext()) {
            Object oSecond = iSecondCluster.next();
            ISimilarity sSimil;
            // Compare the objects
            try {
                sSimil = clDistanceCalculator.getSimilarityBetween(oFirst, oSecond);
            } catch (InvalidClassException ex) {
                System.err.println("Cannot compare " + oFirst.toString() + " to " + 
                        oSecond.toString() + ". Cause:");
                ex.printStackTrace(System.err);
                continue;
            }
            // Put id of pair and their similarity in distance distribution
            dDistances.setValue(iCnt++, sSimil.getOverallSimilarity());                    
        }
    }
    
    // Return the maximum similarity
    return dDistances.minValue();
}
 
開發者ID:ayushoriginal,項目名稱:Ngram-Graphs,代碼行數:40,代碼來源:CompleteLinkClusterer.java

示例6: setAdapter

import java.io.InvalidClassException; //導入方法依賴的package包/類
@Override
public void setAdapter(Adapter adapter) {
    super.setAdapter(adapter);
    if (adapter instanceof RefreshAdapter) {
        this.adapter = (RefreshAdapter<ViewHolder>) adapter;
    } else {
        try {
            throw new InvalidClassException("所使用Adapter並非SwipeMenuAdapter的子類");
        } catch (InvalidClassException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:garyhu1,項目名稱:collapselrecycler,代碼行數:14,代碼來源:MyRefreshRecyclerView.java

示例7: locateSimilarDocuments

import java.io.InvalidClassException; //導入方法依賴的package包/類
/** Returns the set of documents of the cluster that is most appropriate,
 * given a document graph.
 *@param dngCur The graph of the document used.
 *@return A {@link Set} of strings, corresponding to the document IDs in the
 *cluster that has the most similar content to the given document.
 */
@Override
public Set<String> locateSimilarDocuments(DocumentNGramGraph dngCur) {
    String sClusterLabel = null;
    // Init similarity to low value
    double dSim = 0.0;
    double dPrvSim = 0.0;
                    
    // Remove grammar
    //if (Grammar != null)
    //  dgCur = dgCur.allNotIn(Grammar);
    
    // Init current cluster to top
    Vertex vBestCandidate = null;
    Vertex vCur = getRootHierarchyNode(Hierarchy);
    
    // DEBUG LINES
    // Store index path
    LinkedList<String> lPath = new LinkedList<String>();
    lPath.add(vCur.getLabel());
    //////////////
    do {
        dPrvSim = dSim;
        
        // Get similarity of all childen of the current node to given doc
        Iterator iChildren = utils.getAdjacentIncomingVertices(Hierarchy, 
                vCur).iterator();
        vBestCandidate = vCur; // Best candidate is the current vertex
        
        // If not reached leaf
        if (iChildren.hasNext())
        {                
            // For every child
            while (iChildren.hasNext()) {
                Vertex vCandidate = (Vertex)iChildren.next();
                double dCurSim = Double.NEGATIVE_INFINITY;
                try {
                    // DEBUG LINES
                    // System.out.println("Comparing to..." + vCandidate.getLabel());
                    //////////////
                    
                    // Init comparator if required
                    initComparator();
                    dCurSim = Comparator.getSimilarityBetween(
                            dngCur, 
                            getRepresentationFromCluster(vCandidate.getLabel())).getOverallSimilarity();
                } catch (InvalidClassException ex) {
                    System.err.println("Invalid document type. Ignoring...");
                    ex.printStackTrace(System.err);
                }
                // If candidate is more similar than the parent
                if (dCurSim > dSim)
                {
                    // Update best candidate
                    vBestCandidate = vCandidate;
                    // and similarity
                    dSim = dCurSim;
                }
            }
        }
        
        vCur = vBestCandidate; // Update current position
        sClusterLabel = vBestCandidate.getLabel(); // Update best cluster label
        // DEBUG LINES
        // Add current node to path
        lPath.add(sClusterLabel);
        //////////////
    } while (dPrvSim < dSim);
    
    // DEBUG LINES
    System.err.println(utils.printIterable(lPath, "->\n"));
    //////////////
    return getDocumentIDsFromCluster(sClusterLabel);
}
 
開發者ID:ayushoriginal,項目名稱:Ngram-Graphs,代碼行數:80,代碼來源:SimilarityBasedIndex.java


注:本文中的java.io.InvalidClassException.printStackTrace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。