⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configinfoobject.java

📁 RMI通讯
💻 JAVA
字号:
/**
 * 
 */
package com.vanceinfo.socket.server;

import java.io.IOException;
import java.util.HashSet;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

import com.vanceinfo.socket.today.Article;
import com.vanceinfo.socket.today.Articles;
import com.vanceinfo.socket.today.EditorPane;
import com.vanceinfo.socket.today.Item;
import com.vanceinfo.socket.today.MetaInfo;
import com.vanceinfo.socket.today.Today;
import com.vanceinfo.socket.today.ToolBar;

/**
 * @author 谷明亮
 * @description 配置信息对象实现
 */
public class ConfigInfoObject implements AbstractConfigInfoObject {

	public Object getConfigInfoObject() {
		SAXBuilder sb = new SAXBuilder();
		Document doc = null;
		try {
			doc = sb.build(TodayServer.class.getResource("Today.xml"));

		} catch (JDOMException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		Element root = doc.getRootElement();
		Element window = root.getChild("window");
		Element meta = window.getChild("meta");
		Element toolbar = window.getChild("components").getChild("toolbar");
		Element editorpane = window.getChild("components").getChild(
				"editorpane");

		MetaInfo metaInfo = new MetaInfo();
		metaInfo.setTitle(meta.getChildText("title"));
		metaInfo.setWidth(Integer.parseInt(meta.getChildText("width")));
		metaInfo.setHeight(Integer.parseInt(meta.getChildText("height")));
		metaInfo.setLayout(meta.getChildText("layout"));
		metaInfo.setResizable(Boolean.parseBoolean(meta
				.getChildText("resizable")));

		int sizeOfToolbar = toolbar.getChildren("item").size();// 工具栏条目数
		HashSet<Item> items = new HashSet<Item>();// 一个工具栏条目
		Item item = null;
		Articles articles = null;
		Article article = null;
		int articleCount = 0;
		Element tempItem = null;
		Element tempArticles = null;
		for (int i = 0; i < sizeOfToolbar; i++) {
			tempItem = (Element) toolbar.getChildren("item").get(i);
			tempArticles = (Element) editorpane.getChildren("articles").get(i);
			articleCount = tempArticles.getChildren("article").size();
			Element tempArticle = null;
			articles = new Articles();
			article = new Article();
			for (int j = 0; j < articleCount; j++) {
				tempArticle = (Element) tempArticles.getChildren("article")
						.get(j);
				article.setId(Integer.parseInt(tempArticle
						.getAttributeValue("id")));
				article.setUri(tempArticle.getText());
				articles.getArticles().add(article);
			}
			item = new Item(tempItem.getAttributeValue("type"), articles);
			item.setIcon(tempItem.getText());
			items.add(item);
		}
		ToolBar toolBar = new ToolBar(items);

		EditorPane editorPane = new EditorPane(articles.getArticles());

		Today today = new Today(metaInfo, toolBar, editorPane);

		return today;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -