📄 getformat.java
字号:
package com.rochoc.xml.tools;
import org.jdom.output.Format;
/**
* @author luoc
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*
* 读取配置文件,获取XML Format对象
*/
public class GetFormat
{
/**
* 构造函数,设置PropSet
* 默认为prop.ini
*/
public GetFormat()
{
PropSet.getInstance();
}
/**
* 构造函数,设置PropSet
* @param path 配置文件的路径
*/
public GetFormat(String path)
{
PropSet.getInstance(path);
}
/**
* 方法名称:getFomatter
* 方法功能:获取XML的Format对象
* @return Format
* @author:luoc
* @since:1.0
* 编写时间:2005-02-04
*/
public Format getFormatter()
{
Format fmt=Format.getCompactFormat();
/*输出测试*/
/*
System.out.println(">>"+PropSet.getValueAt("Indent")+"<<");
System.out.println(">>"+PropSet.getValueAt("LineSeparator")+"<<");
System.out.println(">>"+PropSet.getValueAt("Encoding")+"<<");
System.out.println(">>"+PropSet.getValueAt("ExpandEmptyElements")+"<<");
*/
/*************************************************************************************/
if(PropSet.getValueAt("Indent")!=null)//Indent
{
String tmpStr=PropSet.getValueAt("Indent");
if(tmpStr.endsWith("W"))
{
String num=tmpStr.substring(0,tmpStr.length()-1);
try
{
int Num=Integer.parseInt(num);
tmpStr="";
for(int i=0;i<Num;i++)
{
tmpStr+=" ";
}
}catch(Exception e)
{}
}
fmt.setIndent(tmpStr);
}
if(PropSet.getValueAt("LineSeparator")!=null)//LineSeparator
{
fmt.setLineSeparator(PropSet.getValueAt("LineSeparator"));
}
if(PropSet.getValueAt("Encoding")!=null)//Encoding
{
fmt.setEncoding(PropSet.getValueAt("Encoding"));
}
if(PropSet.getValueAt("ExpandEmptyElements")!=null)//Encoding
{
String tmpStr = PropSet.getValueAt("ExpandEmptyElements");
if(tmpStr.equals("true"))
{
fmt.setExpandEmptyElements(true);
}
else
{
fmt.setExpandEmptyElements(false);
}
}
return fmt;
}
/*全局变量*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -