001/* 002 * Style.java July 2008 003 * 004 * Copyright (C) 2008, Niall Gallagher <niallg@users.sf.net> 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 015 * implied. See the License for the specific language governing 016 * permissions and limitations under the License. 017 */ 018 019package org.simpleframework.xml.stream; 020 021/** 022 * The <code>Style</code> interface is used to represent an XML style 023 * that can be applied to a serialized object. A style can be used to 024 * modify the element and attribute names for the generated document. 025 * Styles can be used to generate hyphenated or camel case XML. 026 * <pre> 027 * 028 * <example-element> 029 * <child-element example-attribute='example'> 030 * <inner-element>example</inner-element> 031 * </child-element> 032 * </example-element> 033 * 034 * </pre> 035 * Above the hyphenated XML elements and attributes can be generated 036 * from a style implementation. Styles enable the same objects to be 037 * serialized in different ways, generating different styles of XML 038 * without having to modify the class schema for that object. 039 * 040 * @author Niall Gallagher 041 */ 042public interface Style { 043 044 /** 045 * This is used to generate the XML element representation of 046 * the specified name. Element names should ensure to keep the 047 * uniqueness of the name such that two different names will 048 * be styled in to two different strings. 049 * 050 * @param name this is the element name that is to be styled 051 * 052 * @return this returns the styled name of the XML element 053 */ 054 String getElement(String name); 055 056 /** 057 * This is used to generate the XML attribute representation of 058 * the specified name. Attribute names should ensure to keep the 059 * uniqueness of the name such that two different names will 060 * be styled in to two different strings. 061 * 062 * @param name this is the attribute name that is to be styled 063 * 064 * @return this returns the styled name of the XML attribute 065 */ 066 String getAttribute(String name); 067}