📄 domadapter.java
字号:
/*
* $Id: DOMAdapter.java,v 1.3 2006/01/29 20:50:19 geoffm74 Exp $
* $Source: /cvsroot/domify/domify/src/java/org/infohazard/domify/DOMAdapter.java,v $
*/
package org.infohazard.domify;
import org.w3c.dom.*;
import java.util.*;
/**
*/
public class DOMAdapter
{
/**
*/
public DOMAdapter()
{
}
/**
* List of classes which should be converted to string immediately rather
* than exposing their getters as properties.
*/
protected List toStringClasses = new ArrayList();
// Initialize with the things we *know* should be strings
{
toStringClasses.add(String.class);
toStringClasses.add(StringBuffer.class);
toStringClasses.add(Character.class);
toStringClasses.add(Boolean.class);
toStringClasses.add(Number.class);
toStringClasses.add(Class.class); // Trying to serialize getters for this causes explosions.
toStringClasses.add(ClassLoader.class); // Looking at the getters for this is a bad idea too.
}
/**
* Adds a class to the list of classes which are converted to String
* immediately rather than exposing their getters as properties.
*/
public void stringify(Class cls)
{
if (!toStringClasses.contains(cls))
this.toStringClasses.add(cls);
}
/**
*/
protected boolean shouldConvertToString(Object something)
{
Iterator it = toStringClasses.iterator();
while (it.hasNext())
{
Class c = (Class)it.next();
if (c.isInstance(something))
return true;
}
return false;
}
/**
* The primary method of this package; use this to adapt
* a Java object to a DOM representation.
*
* @param rootName - the name assigned to the root element of the document.
*/
public Node adapt(Object root, String rootName)
{
return new DocumentAdapter(root, rootName, this);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -