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.jena.annotation;
014
015import static org.apache.juneau.jena.RdfCommon.*;
016import static org.apache.juneau.jena.RdfSerializer.*;
017import static org.apache.juneau.jena.RdfParser.*;
018
019import org.apache.juneau.*;
020import org.apache.juneau.reflect.*;
021import org.apache.juneau.svl.*;
022
023/**
024 * Applies {@link RdfConfig} annotations to a {@link PropertyStoreBuilder}.
025 */
026public class RdfConfigApply extends ConfigApply<RdfConfig> {
027
028   /**
029    * Constructor.
030    *
031    * @param c The annotation class.
032    * @param r The resolver for resolving values in annotations.
033    */
034   public RdfConfigApply(Class<RdfConfig> c, VarResolverSession r) {
035      super(c, r);
036   }
037
038   @Override
039   public void apply(AnnotationInfo<RdfConfig> ai, PropertyStoreBuilder psb) {
040      RdfConfig a = ai.getAnnotation();
041      if (! a.language().isEmpty())
042         psb.set(RDF_language, string(a.language()));
043      if (! a.juneauNs().isEmpty())
044         psb.set(RDF_juneauNs, string(a.juneauNs()));
045      if (! a.juneauBpNs().isEmpty())
046         psb.set(RDF_juneauBpNs, string(a.juneauBpNs()));
047      if (! a.useXmlNamespaces().isEmpty())
048         psb.set(RDF_useXmlNamespaces, bool(a.useXmlNamespaces()));
049      if (! a.arp_iriRules().isEmpty())
050         psb.set(RDF_arp_iriRules, string(a.arp_iriRules()));
051      if (! a.arp_errorMode().isEmpty())
052         psb.set(RDF_arp_errorMode, string(a.arp_errorMode()));
053      if (! a.arp_embedding().isEmpty())
054         psb.set(RDF_arp_embedding, bool(a.arp_embedding()));
055      if (! a.rdfxml_xmlBase().isEmpty())
056         psb.set(RDF_rdfxml_xmlBase, string(a.rdfxml_xmlBase()));
057      if (! a.rdfxml_longId().isEmpty())
058         psb.set(RDF_rdfxml_longId, bool(a.rdfxml_longId()));
059      if (! a.rdfxml_allowBadUris().isEmpty())
060         psb.set(RDF_rdfxml_allowBadUris, bool(a.rdfxml_allowBadUris()));
061      if (! a.rdfxml_relativeUris().isEmpty())
062         psb.set(RDF_rdfxml_relativeUris, string(a.rdfxml_relativeUris()));
063      if (! a.rdfxml_showXmlDeclaration().isEmpty())
064         psb.set(RDF_rdfxml_showXmlDeclaration, string(a.rdfxml_showXmlDeclaration()));
065      if (! a.rdfxml_showDoctypeDeclaration().isEmpty())
066         psb.set(RDF_rdfxml_showDoctypeDeclaration, bool(a.rdfxml_showDoctypeDeclaration()));
067      if (! a.rdfxml_tab().isEmpty())
068         psb.set(RDF_rdfxml_tab, integer(a.rdfxml_tab(), "rdfxml_tab"));
069      if (! a.rdfxml_attributeQuoteChar().isEmpty())
070         psb.set(RDF_rdfxml_attributeQuoteChar, string(a.rdfxml_attributeQuoteChar()));
071      if (! a.rdfxml_blockRules().isEmpty())
072         psb.set(RDF_rdfxml_blockRules, string(a.rdfxml_blockRules()));
073      if (! a.n3_minGap().isEmpty())
074         psb.set(RDF_n3_minGap, integer(a.n3_minGap(), "n3_minGap"));
075      if (! a.n3_objectLists().isEmpty())
076         psb.set(RDF_n3_objectLists, bool(a.n3_objectLists()));
077      if (! a.n3_subjectColumn().isEmpty())
078         psb.set(RDF_n3_subjectColumn, integer(a.n3_subjectColumn(), "n3_subjectColumn"));
079      if (! a.n3_propertyColumn().isEmpty())
080         psb.set(RDF_n3_propertyColumn, integer(a.n3_propertyColumn(), "n3_propertyColumn"));
081      if (! a.n3_indentProperty().isEmpty())
082         psb.set(RDF_n3_indentProperty, integer(a.n3_indentProperty(), "n3_indentProperty"));
083      if (! a.n3_widePropertyLen().isEmpty())
084         psb.set(RDF_n3_widePropertyLen, integer(a.n3_widePropertyLen(), "n3_widePropertyLen"));
085      if (! a.n3_abbrevBaseUri().isEmpty())
086         psb.set(RDF_n3_abbrevBaseUri, bool(a.n3_abbrevBaseUri()));
087      if (! a.n3_usePropertySymbols().isEmpty())
088         psb.set(RDF_n3_usePropertySymbols, bool(a.n3_usePropertySymbols()));
089      if (! a.n3_useTripleQuotedStrings().isEmpty())
090         psb.set(RDF_n3_useTripleQuotedStrings, bool(a.n3_useTripleQuotedStrings()));
091      if (! a.n3_useDoubles().isEmpty())
092         psb.set(RDF_n3_useDoubles, bool(a.n3_useDoubles()));
093      if (! a.collectionFormat().isEmpty())
094         psb.set(RDF_collectionFormat, string(a.collectionFormat()));
095      if (! a.looseCollections().isEmpty())
096         psb.set(RDF_looseCollections, bool(a.looseCollections()));
097
098      if (! a.addBeanTypes().isEmpty())
099         psb.set(RDF_addBeanTypes, bool(a.addBeanTypes()));
100      if (! a.addLiteralTypes().isEmpty())
101         psb.set(RDF_addLiteralTypes, bool(a.addLiteralTypes()));
102      if (! a.addRootProperty().isEmpty())
103         psb.set(RDF_addRootProperty, bool(a.addRootProperty()));
104      if (! a.autoDetectNamespaces().isEmpty())
105         psb.set(RDF_autoDetectNamespaces, bool(a.autoDetectNamespaces()));
106      if (a.namespaces().length > 0)
107         psb.set(RDF_namespaces, strings(a.namespaces()));
108
109      if (! a.trimWhitespace().isEmpty())
110         psb.set(RDF_trimWhitespace, bool(a.trimWhitespace()));
111   }
112}