001/* 002 * Copyright 2011 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.web.sitemap; 017 018import org.apache.avalon.framework.configuration.Configuration; 019import org.apache.avalon.framework.configuration.ConfigurationException; 020 021import org.ametys.runtime.i18n.I18nizableText; 022 023/** 024 * A decorator for page in sitemap 025 * 026 */ 027public class SitemapDecorator extends SitemapIcon 028{ 029 private I18nizableText _label; 030 private String _id; 031 /** 032 * Constructor 033 */ 034 public SitemapDecorator () 035 { 036 // nothing 037 } 038 039 @Override 040 public void configure (Configuration configuration) throws ConfigurationException 041 { 042 super.configure(configuration); 043 this._id = configuration.getAttribute("id"); 044 this._label = _configureI18n(configuration.getChild("label")); 045 } 046 047 /** 048 * The id 049 * @return the id 050 */ 051 public String getId () 052 { 053 return _id; 054 } 055 056 /** 057 * The decorator label 058 * @return The label 059 */ 060 public I18nizableText getLabel() 061 { 062 return _label; 063 } 064 065 private I18nizableText _configureI18n(Configuration child) 066 { 067 String value = child.getValue(""); 068 if (child.getAttributeAsBoolean("i18n", false)) 069 { 070 return new I18nizableText("application", value); 071 } 072 else 073 { 074 return new I18nizableText(value); 075 } 076 } 077}