001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.xml.types; 029 030import org.opencms.i18n.CmsMessageContainer; 031import org.opencms.widgets.serialdate.CmsSerialDateValue; 032import org.opencms.xml.I_CmsXmlDocument; 033 034import java.util.Locale; 035 036import org.dom4j.Element; 037 038/** 039 * Describes the XML content type "OpenCmsSerialDate".<p> 040 * 041 * @since 11.0.0 042 */ 043public class CmsXmlSerialDateValue extends A_CmsXmlValueTextBase implements I_CmsXmlValidateWithMessage { 044 045 /** The name of this type as used in the XML schema. */ 046 public static final String TYPE_NAME = "OpenCmsSerialDate"; 047 048 /** 049 * Creates a new, empty schema type descriptor of type "OpenCmsDateTime".<p> 050 */ 051 public CmsXmlSerialDateValue() { 052 053 // empty constructor is required for class registration 054 } 055 056 /** 057 * Creates a new XML content value of type "OpenCmsSerialDate".<p> 058 * 059 * @param document the XML content instance this value belongs to 060 * @param element the XML element that contains this value 061 * @param locale the locale this value is created for 062 * @param type the type instance to create the value for 063 */ 064 public CmsXmlSerialDateValue(I_CmsXmlDocument document, Element element, Locale locale, I_CmsXmlSchemaType type) { 065 066 super(document, element, locale, type); 067 } 068 069 /** 070 * Creates a new schema type descriptor for the type "OpenCmsDateTime".<p> 071 * 072 * @param name the name of the XML node containing the value according to the XML schema 073 * @param minOccurs minimum number of occurrences of this type according to the XML schema 074 * @param maxOccurs maximum number of occurrences of this type according to the XML schema 075 */ 076 public CmsXmlSerialDateValue(String name, String minOccurs, String maxOccurs) { 077 078 super(name, minOccurs, maxOccurs); 079 } 080 081 /** 082 * @see org.opencms.xml.types.A_CmsXmlContentValue#createValue(I_CmsXmlDocument, org.dom4j.Element, Locale) 083 */ 084 public I_CmsXmlContentValue createValue(I_CmsXmlDocument document, Element element, Locale locale) { 085 086 return new CmsXmlSerialDateValue(document, element, locale, this); 087 } 088 089 /** 090 * @see org.opencms.xml.types.A_CmsXmlContentValue#getDefault(Locale) 091 */ 092 @Override 093 public String getDefault(Locale locale) { 094 095 if (m_defaultValue != null) { 096 return m_defaultValue; 097 } 098 return ""; 099 } 100 101 /** 102 * @see org.opencms.xml.types.I_CmsXmlSchemaType#getSchemaDefinition() 103 */ 104 public String getSchemaDefinition() { 105 106 return "<xsd:simpleType name=\"" + TYPE_NAME + "\"><xsd:restriction base=\"xsd:string\" /></xsd:simpleType>"; 107 } 108 109 /** 110 * @see org.opencms.xml.types.A_CmsXmlContentValue#getTypeName() 111 */ 112 public String getTypeName() { 113 114 return TYPE_NAME; 115 } 116 117 /** 118 * @see org.opencms.xml.types.A_CmsXmlContentValue#isSearchable() 119 */ 120 @Override 121 public boolean isSearchable() { 122 123 // there is no point in searching date/time values 124 return false; 125 } 126 127 /** 128 * @see org.opencms.xml.types.A_CmsXmlContentValue#newInstance(java.lang.String, java.lang.String, java.lang.String) 129 */ 130 public I_CmsXmlSchemaType newInstance(String name, String minOccurs, String maxOccurs) { 131 132 return new CmsXmlSerialDateValue(name, minOccurs, maxOccurs); 133 } 134 135 /** 136 * @see org.opencms.xml.types.I_CmsXmlSchemaType#validateValue(java.lang.String) 137 */ 138 @Override 139 public boolean validateValue(String value) { 140 141 return null == validateWithMessage(value); 142 } 143 144 /** 145 * @see org.opencms.xml.types.I_CmsXmlValidateWithMessage#validateWithMessage(java.lang.String) 146 */ 147 public CmsMessageContainer validateWithMessage(String value) { 148 149 CmsSerialDateValue wrapper = new CmsSerialDateValue(value); 150 return wrapper.validateWithMessage(); 151 } 152}