|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.xml.tree.traversal; import java.io.*; import java.util.Arrays; import java.util.Set; import java.util.HashSet; import java.util.Vector; import java.util.Iterator; /** * @deprecated Backward compatibility class for tree node filter. * * @author Libor Kramolis * @version 0.1 */ public final class TreeNodeFilter implements Serializable { /** Serial Version UID */ private static final long serialVersionUID =-1801680548977212544L; private static final boolean DEBUG = false; // Stream replacing private static final String WHAT_TO_SHOW_FIELD = "whatToShow"; // old field : private Class[] whatToShow; // NOI18N private static final String NODE_TYPE_NAMES_FIELD = "nodeTypeNames"; // NOI18N private static final String ACCEPT_POLICY_FIELD = "acceptPolicy"; // NOI18N private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField (NODE_TYPE_NAMES_FIELD, Vector.class), new ObjectStreamField (ACCEPT_POLICY_FIELD, short.class), }; /** */ transient private Class[] nodeTypes; /** */ transient private short acceptPolicy; /** */ private Object readResolve () throws ObjectStreamException { org.netbeans.tax.traversal.TreeNodeFilter peer = new org.netbeans.tax.traversal.TreeNodeFilter (nodeTypes, acceptPolicy); if ( DEBUG ) { System.err.println ("\n[COMPAT] TreeNodeFilter.readResolve: peer = " + peer + "\n"); } return peer; } /** */ private void readObject (ObjectInputStream ois) throws IOException, ClassNotFoundException { if ( DEBUG ) { System.err.println ("\n[compat] TreeNodeFilter.readObject"); Thread.dumpStack(); } ObjectInputStream.GetField getField = ois.readFields(); // try { Vector nodeTypeNames = (Vector)getField.get (NODE_TYPE_NAMES_FIELD, new Vector (Arrays.asList (new String[] { "org.netbeans.tax.TreeNode" }))); // NOI18N if ( DEBUG ) { System.err.println ("[compat] nodeTypeNames = " + nodeTypeNames); } Vector types = new Vector(); Iterator it = nodeTypeNames.iterator(); while (it.hasNext()) { try { String name = (String)it.next(); if ( name.startsWith ("org.netbeans.modules.xml.tree.") ) { // length == 30 String noPackage = name.substring (30); name = "org.netbeans.tax." + noPackage; } types.add (Class.forName (name)); } catch (ClassNotFoundException exc) { // let it be if ( DEBUG ) { exc.printStackTrace(); System.err.println(); } } } nodeTypes = (Class[])types.toArray (new Class[0]); if ( DEBUG ) { System.err.println ("[compat] types = " + types); } // } catch (IllegalArgumentException ex) { // } // Old TreeNodeFilter.FILTER_* starts at 1. // Current TreeNodeFilter.FILTER_* starts at 10. // FILTER_ACCEPT is default value. acceptPolicy = getField.get (ACCEPT_POLICY_FIELD, (short)(org.netbeans.tax.traversal.TreeNodeFilter.ACCEPT_TYPES - 9)); // old values (-9) acceptPolicy += 9; // new values (+9) if ( DEBUG ) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < nodeTypes.length; i++) { if ( i != 0 ) { sb.append (" | "); } sb.append (nodeTypes[i].getName()); } System.err.println ("[compat] nodeTypes = " + sb.toString()); System.err.println ("[compat] acceptPolicy = " + acceptPolicy + "\n"); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.