本文整理汇总了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;
}
示例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);
}
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
}
}
示例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);
}