Coverage Report - org.apache.any23.extractor.xpath.TemplateSubject
 
Classes in this File Line Coverage Branch Coverage Complexity
TemplateSubject
0%
0/15
0%
0/8
5
TemplateSubject$1
0%
0/1
N/A
5
TemplateSubject$Type
0%
0/3
N/A
5
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *  http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.apache.any23.extractor.xpath;
 19  
 
 20  
 import org.openrdf.model.Resource;
 21  
 import org.openrdf.model.impl.BNodeImpl;
 22  
 import org.openrdf.model.impl.URIImpl;
 23  
 
 24  
 /**
 25  
  * Represents a <i>Quad</i> subject <i>template</i>.
 26  
  *
 27  
  * @author Michele Mostarda (mostarda@fbk.eu)
 28  
  */
 29  0
 public class TemplateSubject extends Term<Resource> {
 30  
 
 31  
     /**
 32  
      * Supported subject types.
 33  
      */
 34  0
     public enum Type {
 35  0
         uri,
 36  0
         bnode
 37  
     }
 38  
 
 39  
     /**
 40  
      * Instance subject type.
 41  
      */
 42  
     private final Type type;
 43  
 
 44  
     /**
 45  
      * Constructor.
 46  
      *
 47  
      * @param type subject type.
 48  
      * @param value internal value.
 49  
      * @param isVar if <code>true</code> it the given <code>value</code>
 50  
      *              will be resolved with the variable value.
 51  
      */
 52  
     public TemplateSubject(Type type, String value, boolean isVar) {
 53  0
         super(value, isVar);
 54  0
         if (type == null) {
 55  0
             throw new NullPointerException("object type cannot be null.");
 56  
         }
 57  0
         this.type = type;
 58  0
     }
 59  
 
 60  
     @Override
 61  
     protected Resource getValueInternal(String value) {
 62  0
         switch (type) {
 63  
             case uri:
 64  0
                 return new URIImpl(value);
 65  
             case bnode:
 66  0
                 return new BNodeImpl(value);
 67  
             default:
 68  0
                 throw new IllegalStateException();
 69  
         }
 70  
     }
 71  
 
 72  
     @Override
 73  
     public String toString() {
 74  0
         final String superStr = super.toString();
 75  0
         switch (type) {
 76  
             case uri:
 77  0
                 return "<" + superStr + ">";
 78  
             case bnode:
 79  0
                 return "_:" + superStr;
 80  
             default:
 81  0
                 throw new IllegalStateException();
 82  
         }
 83  
     }
 84  
 
 85  
 }