📄 categorywriter.java
字号:
/*--------------------------------------------------------------------------*
| Copyright (C) 2006 Christopher Kohlhaas |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by the |
| Free Software Foundation. A copy of the license has been included with |
| these distribution in the COPYING file, if not go to www.fsf.org . |
| |
| As a special exception, you are granted the permissions to link this |
| program with every library, which license fulfills the Open Source |
| Definition as published by the Open Source Initiative (OSI). |
*--------------------------------------------------------------------------*/
package org.rapla.storage.xml;
import java.io.IOException;
import org.rapla.entities.Category;
import org.rapla.entities.RaplaObject;
import org.rapla.framework.RaplaContext;
import org.rapla.framework.RaplaException;
public class CategoryWriter extends RaplaXMLWriter {
public CategoryWriter(RaplaContext sm) throws RaplaException {
super(sm);
}
public void printRaplaType(RaplaObject type) throws RaplaException, IOException {
printCategory( (Category) type);
}
public void printCategory(Category category) throws IOException,RaplaException {
printCategory( category, true);
}
public void printCategory(Category category,boolean printSubcategories) throws IOException,RaplaException {
openTag("rapla:category");
printVersion( category);
if (isIdOnly())
{
printId(category);
Category parent = category.getParent();
if ( parent != null)
{
att("parentid", getId( parent));
}
}
att("key",category.getKey());
closeTag();
printTranslation(category.getName());
printAnnotations( category );
if ( printSubcategories )
{
Category[] categories = category.getCategories();
for (int i=0;i<categories.length;i++)
printCategory(categories[i]);
}
closeElement("rapla:category");
}
public void writeObject(RaplaObject persistant) throws RaplaException, IOException {
printCategory( (Category) persistant, false);
}
public void printCategories() throws IOException,RaplaException {
openElement("rapla:categories");
Category[] categories = cache.getSuperCategory().getCategories();
for (int i=0;i<categories.length;i++)
printCategory(categories[i]);
closeElement("rapla:categories");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -