001/* 002 * Copyright 2019 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.plugins.repository.data.ametysobject; 017 018import java.io.IOException; 019import java.util.Locale; 020 021import org.xml.sax.ContentHandler; 022import org.xml.sax.SAXException; 023 024import org.ametys.plugins.repository.AmetysObject; 025import org.ametys.plugins.repository.data.UnknownDataException; 026import org.ametys.plugins.repository.data.holder.ModelLessDataHolder; 027import org.ametys.plugins.repository.data.holder.group.impl.ModelLessComposite; 028import org.ametys.plugins.repository.data.type.RepositoryModelItemType; 029import org.ametys.runtime.model.exception.BadDataPathCardinalityException; 030import org.ametys.runtime.model.exception.BadItemTypeException; 031import org.ametys.runtime.model.exception.NotUniqueTypeException; 032import org.ametys.runtime.model.exception.UnknownTypeException; 033 034/** 035 * Model less {@link AmetysObject} that can handle data. 036 */ 037public interface ModelLessDataAwareAmetysObject extends DataAwareAmetysObject, ModelLessDataHolder 038{ 039 @Override 040 public ModelLessDataHolder getDataHolder(); 041 042 public default ModelLessComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException 043 { 044 return getDataHolder().getComposite(compositePath); 045 } 046 047 public default boolean hasValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException 048 { 049 return DataAwareAmetysObject.super.hasValue(dataPath); 050 } 051 052 public default <T> T getValue(String dataPath) throws IllegalArgumentException, UnknownTypeException, NotUniqueTypeException, BadDataPathCardinalityException 053 { 054 return getDataHolder().getValue(dataPath); 055 } 056 057 public default <T> T getValue(String dataPath, T defaultValue) throws IllegalArgumentException, UnknownTypeException, NotUniqueTypeException, BadDataPathCardinalityException 058 { 059 return getDataHolder().getValue(dataPath, defaultValue); 060 } 061 062 public default <T> T getValueOfType(String dataPath, String dataTypeId) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, BadDataPathCardinalityException 063 { 064 return getDataHolder().getValueOfType(dataPath, dataTypeId); 065 } 066 067 public default <T> T getValueOfType(String dataPath, String dataTypeId, T defaultValue) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, BadDataPathCardinalityException 068 { 069 return getDataHolder().getValueOfType(dataPath, dataTypeId, defaultValue); 070 } 071 072 public default boolean isMultiple(String dataPath) throws IllegalArgumentException, UnknownDataException, BadDataPathCardinalityException 073 { 074 return getDataHolder().isMultiple(dataPath); 075 } 076 077 public default RepositoryModelItemType getType(String dataPath) throws IllegalArgumentException, UnknownDataException, UnknownTypeException, NotUniqueTypeException, BadDataPathCardinalityException 078 { 079 return getDataHolder().getType(dataPath); 080 } 081 082 public default void dataToSAX(ContentHandler contentHandler, Locale locale) throws SAXException, IOException, UnknownTypeException, NotUniqueTypeException 083 { 084 getDataHolder().dataToSAX(contentHandler, locale); 085 } 086}