001/* 002 * Copyright 2021 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.runtime.i18n; 017 018import org.apache.cocoon.xml.XMLUtils; 019import org.xml.sax.ContentHandler; 020import org.xml.sax.SAXException; 021 022/** 023 * Interface for all internationalizable or localizable objects (dates, texts, numbers...). 024 */ 025public interface I18nizable 026{ 027 /** 028 * Represents this {@link I18nizable} as SAX events. 029 * @param handler the SAX content handler 030 * @throws SAXException if an error occurs 031 */ 032 public void toSAX(ContentHandler handler) throws SAXException; 033 034 /** 035 * Represents this {@link I18nizable} as SAX events, surrounded by the provided tag. 036 * @param handler the SAX content handler 037 * @param tagName the tag name 038 * @throws SAXException if an error occurs 039 */ 040 public default void toSAX(ContentHandler handler, String tagName) throws SAXException 041 { 042 XMLUtils.startElement(handler, tagName); 043 toSAX(handler); 044 XMLUtils.endElement(handler, tagName); 045 } 046}