001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.dto.atom; 014 015import static org.apache.juneau.internal.StringUtils.*; 016import static org.apache.juneau.xml.annotation.XmlFormat.*; 017 018import java.net.*; 019import java.net.URI; 020 021import org.apache.juneau.*; 022import org.apache.juneau.annotation.*; 023import org.apache.juneau.xml.*; 024import org.apache.juneau.xml.annotation.*; 025 026/** 027 * Represents an <c>atomCommonAttributes</c> construct in the RFC4287 specification. 028 * 029 * <h5 class='figure'>Schema</h5> 030 * <p class='bcode w800'> 031 * atomCommonAttributes = 032 * attribute xml:base { atomUri }?, 033 * attribute xml:lang { atomLanguageTag }?, 034 * undefinedAttribute* 035 * </p> 036 * 037 * <ul class='seealso'> 038 * <li class='link'>{@doc DtoAtom} 039 * <li class='jp'>{@doc package-summary.html#TOC} 040 * </ul> 041 */ 042public abstract class Common { 043 044 private URI base; 045 private String lang; 046 047 048 //----------------------------------------------------------------------------------------------------------------- 049 // Bean properties 050 //----------------------------------------------------------------------------------------------------------------- 051 052 /** 053 * Returns the uri base of this object. 054 * 055 * @return The URI base of this object. 056 */ 057 @Xml(prefix="xml", format=ATTR) 058 public URI getBase() { 059 return base; 060 } 061 062 /** 063 * Sets the URI base of this object. 064 * 065 * <p> 066 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 067 * Strings must be valid URIs. 068 * 069 * <p> 070 * URIs defined by {@link UriResolver} can be used for values. 071 * 072 * @param base The URI base of this object. 073 * @return This object (for method chaining). 074 */ 075 @Beanp("base") 076 public Common base(Object base) { 077 this.base = toURI(base); 078 return this; 079 } 080 081 /** 082 * Returns the language of this object. 083 * 084 * @return The language of this object. 085 */ 086 @Xml(prefix="xml", format=ATTR) 087 public String getLang() { 088 return lang; 089 } 090 091 /** 092 * Sets the language of this object. 093 * 094 * @param lang The language of this object. 095 * @return This object (for method chaining). 096 */ 097 @Beanp("lang") 098 public Common lang(String lang) { 099 this.lang = lang; 100 return this; 101 } 102 103 @Override /* Object */ 104 public String toString() { 105 return XmlSerializer.DEFAULT_SQ.toString(this); 106 } 107}