001/** 002 * Copyright (c) 2011, Regents of the University of Colorado 003 * All rights reserved. 004 * 005 * Redistribution and use in source and binary forms, with or without 006 * modification, are permitted provided that the following conditions are met: 007 * 008 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 009 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 010 * Neither the name of the University of Colorado at Boulder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 011 * 012 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 013 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 014 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 015 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 016 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 017 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 018 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 019 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 020 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 021 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 022 * POSSIBILITY OF SUCH DAMAGE. 023 */ 024package org.cleartk.ml.feature.extractor; 025 026import org.apache.uima.cas.Feature; 027import org.apache.uima.cas.Type; 028import org.apache.uima.jcas.tcas.Annotation; 029import org.cleartk.ml.CleartkProcessingException; 030 031/** 032 * <br> 033 * Copyright (c) 2011, Regents of the University of Colorado <br> 034 * All rights reserved. 035 */ 036public class CleartkExtractorException extends CleartkProcessingException { 037 038 private static final String KEY_PREFIX = CleartkExtractorException.class.getName() + "."; 039 040 private static final long serialVersionUID = 1L; 041 042 public static CleartkExtractorException invalidTypePath(String path, Type type) { 043 String key = KEY_PREFIX + "invalidTypePath"; 044 return new CleartkExtractorException(DEFAULT_RESOURCE_BUNDLE, key, path, type); 045 } 046 047 public static CleartkExtractorException moreThanOneName(String name1, String name2) { 048 String key = KEY_PREFIX + "moreThanOneName"; 049 return new CleartkExtractorException(DEFAULT_RESOURCE_BUNDLE, key, name1, name2); 050 } 051 052 public static CleartkExtractorException noAnnotationInWindow( 053 Class<? extends Annotation> expectedType, 054 Annotation window) { 055 String key = KEY_PREFIX + "noAnnotationInWindow"; 056 return new CleartkExtractorException( 057 DEFAULT_RESOURCE_BUNDLE, 058 key, 059 expectedType.getName(), 060 window); 061 } 062 063 public static CleartkExtractorException noAnnotationMatchingWindow( 064 Class<? extends Annotation> expectedType, 065 Annotation window) { 066 String key = KEY_PREFIX + "noAnnotationMatchingWindow"; 067 return new CleartkExtractorException( 068 DEFAULT_RESOURCE_BUNDLE, 069 key, 070 expectedType.getName(), 071 window); 072 } 073 074 public static CleartkExtractorException notPrimitive(Feature feature) { 075 String key = KEY_PREFIX + "notPrimitive"; 076 return new CleartkExtractorException( 077 DEFAULT_RESOURCE_BUNDLE, 078 key, 079 feature.getDomain(), 080 feature.getRange()); 081 } 082 083 public static CleartkExtractorException notPrimitiveArray(Feature feature) { 084 String key = KEY_PREFIX + "notPrimitiveArray"; 085 return new CleartkExtractorException( 086 DEFAULT_RESOURCE_BUNDLE, 087 key, 088 feature.getDomain(), 089 feature.getRange()); 090 } 091 092 public static CleartkExtractorException wrongAnnotationType( 093 Class<? extends Annotation> expectedType, 094 Annotation actualAnnotation) { 095 String key = KEY_PREFIX + "wrongAnnotationType"; 096 return new CleartkExtractorException( 097 DEFAULT_RESOURCE_BUNDLE, 098 key, 099 expectedType.getName(), 100 actualAnnotation); 101 } 102 103 public static CleartkExtractorException wrongNumberOfAnnotations( 104 Class<? extends Annotation> expectedType, 105 int expectedNumber, 106 int actualNumber) { 107 String key = KEY_PREFIX + "wrongNumberOfAnnotations"; 108 return new CleartkExtractorException( 109 DEFAULT_RESOURCE_BUNDLE, 110 key, 111 expectedType.getName(), 112 expectedNumber, 113 actualNumber); 114 } 115 116 public CleartkExtractorException( 117 Throwable cause, 118 String resourceBundleName, 119 String messageKey, 120 Object... arguments) { 121 super(resourceBundleName, messageKey, arguments, cause); 122 } 123 124 public CleartkExtractorException( 125 String resourceBundleName, 126 String messageKey, 127 Object... arguments) { 128 super(resourceBundleName, messageKey, arguments); 129 } 130 131 public CleartkExtractorException(Throwable cause) { 132 super(cause); 133 } 134}