├── .gitignore ├── LICENSE ├── README.md ├── core-api ├── CHANGELOG.md ├── LICENSE ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── cyc │ │ │ ├── CoreServicesLoader.java │ │ │ ├── Cyc.java │ │ │ ├── CycApiEntryPoint.java │ │ │ ├── CycServicesLoader.java │ │ │ ├── DefaultNlApiServiceImpl.java │ │ │ ├── kb │ │ │ ├── ArgPosition.java │ │ │ ├── ArgUpdate.java │ │ │ ├── Assertion.java │ │ │ ├── BinaryPredicate.java │ │ │ ├── Context.java │ │ │ ├── DefaultContext.java │ │ │ ├── Fact.java │ │ │ ├── FirstOrderCollection.java │ │ │ ├── KbCollection.java │ │ │ ├── KbFunction.java │ │ │ ├── KbIndividual.java │ │ │ ├── KbObject.java │ │ │ ├── KbPredicate.java │ │ │ ├── KbStatus.java │ │ │ ├── KbTerm.java │ │ │ ├── Relation.java │ │ │ ├── Rule.java │ │ │ ├── SecondOrderCollection.java │ │ │ ├── Sentence.java │ │ │ ├── Symbol.java │ │ │ ├── Variable.java │ │ │ ├── exception │ │ │ │ ├── CreateException.java │ │ │ │ ├── DeleteException.java │ │ │ │ ├── InvalidFormulaInContextException.java │ │ │ │ ├── InvalidNameException.java │ │ │ │ ├── KbException.java │ │ │ │ ├── KbObjectNotFoundException.java │ │ │ │ ├── KbRuntimeException.java │ │ │ │ ├── KbServerSideException.java │ │ │ │ ├── KbTypeConflictException.java │ │ │ │ ├── KbTypeException.java │ │ │ │ ├── StaleKbObjectException.java │ │ │ │ ├── VariableArityException.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── spi │ │ │ │ ├── AssertionService.java │ │ │ │ ├── BinaryPredicateService.java │ │ │ │ ├── ContextService.java │ │ │ │ ├── FactService.java │ │ │ │ ├── FirstOrderCollectionService.java │ │ │ │ ├── KbApiService.java │ │ │ │ ├── KbCollectionService.java │ │ │ │ ├── KbFunctionService.java │ │ │ │ ├── KbIndividualService.java │ │ │ │ ├── KbPredicateService.java │ │ │ │ ├── KbService.java │ │ │ │ ├── KbTermService.java │ │ │ │ ├── RelationService.java │ │ │ │ ├── RuleService.java │ │ │ │ ├── SecondOrderCollectionService.java │ │ │ │ ├── SentenceService.java │ │ │ │ ├── SymbolService.java │ │ │ │ ├── VariableService.java │ │ │ │ └── package-info.java │ │ │ └── wrapper │ │ │ │ ├── AssertionWrapper.java │ │ │ │ ├── BinaryPredicateWrapper.java │ │ │ │ ├── ContextWrapper.java │ │ │ │ ├── FactWrapper.java │ │ │ │ ├── FirstOrderCollectionWrapper.java │ │ │ │ ├── KbCollectionWrapper.java │ │ │ │ ├── KbFunctionWrapper.java │ │ │ │ ├── KbIndividualWrapper.java │ │ │ │ ├── KbObjectWrapper.java │ │ │ │ ├── KbPredicateWrapper.java │ │ │ │ ├── KbTermWrapper.java │ │ │ │ ├── RelationWrapper.java │ │ │ │ ├── RuleWrapper.java │ │ │ │ ├── SecondOrderCollectionWrapper.java │ │ │ │ ├── SentenceWrapper.java │ │ │ │ ├── SymbolWrapper.java │ │ │ │ ├── VariableWrapper.java │ │ │ │ └── package-info.java │ │ │ ├── nl │ │ │ ├── GenerationMode.java │ │ │ ├── HtmlLinkType.java │ │ │ ├── NlForce.java │ │ │ ├── NlGenerationParams.java │ │ │ ├── Paraphrase.java │ │ │ ├── Paraphraser.java │ │ │ ├── SubParaphrase.java │ │ │ ├── package-info.java │ │ │ └── spi │ │ │ │ ├── NlApiService.java │ │ │ │ ├── ParaphraserFactory.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── query │ │ │ ├── InferenceAnswerIdentifier.java │ │ │ ├── InferenceIdentifier.java │ │ │ ├── InferenceStatus.java │ │ │ ├── InferenceSuspendReason.java │ │ │ ├── ModifiableQuerySpecification.java │ │ │ ├── ParaphrasedQueryAnswer.java │ │ │ ├── ProofIdentifier.java │ │ │ ├── ProofView.java │ │ │ ├── ProofViewGenerator.java │ │ │ ├── ProofViewMarshaller.java │ │ │ ├── ProofViewNode.java │ │ │ ├── ProofViewSpecification.java │ │ │ ├── Query.java │ │ │ ├── QueryAnswer.java │ │ │ ├── QueryAnswerExplanation.java │ │ │ ├── QueryAnswerExplanationGenerator.java │ │ │ ├── QueryAnswerExplanationSpecification.java │ │ │ ├── QueryAnswers.java │ │ │ ├── QueryListener.java │ │ │ ├── QueryResultSet.java │ │ │ ├── QueryRules.java │ │ │ ├── QuerySpecification.java │ │ │ ├── exception │ │ │ │ ├── ProofViewException.java │ │ │ │ ├── QueryConstructionException.java │ │ │ │ ├── QueryException.java │ │ │ │ ├── QueryRuntimeException.java │ │ │ │ └── package-info.java │ │ │ ├── graph │ │ │ │ ├── GraphNodeAbsolutePath.java │ │ │ │ └── package-info.java │ │ │ ├── metrics │ │ │ │ ├── InferenceMetric.java │ │ │ │ ├── InferenceMetrics.java │ │ │ │ ├── InferenceMetricsValues.java │ │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── parameters │ │ │ │ ├── Browsable.java │ │ │ │ ├── DisjunctionFreeElVarsPolicy.java │ │ │ │ ├── InferenceAnswerLanguage.java │ │ │ │ ├── InferenceMode.java │ │ │ │ ├── InferenceParameter.java │ │ │ │ ├── InferenceParameterGetter.java │ │ │ │ ├── InferenceParameterSetter.java │ │ │ │ ├── InferenceParameterSymbolValue.java │ │ │ │ ├── InferenceParameterValue.java │ │ │ │ ├── InferenceParameterValueDescription.java │ │ │ │ ├── InferenceParameters.java │ │ │ │ ├── ProblemReusePolicy.java │ │ │ │ ├── ProofValidationMode.java │ │ │ │ ├── ResultUniqueness.java │ │ │ │ ├── StandardInferenceMetric.java │ │ │ │ ├── TransitiveClosureMode.java │ │ │ │ └── package-info.java │ │ │ └── spi │ │ │ │ ├── ProofViewService.java │ │ │ │ ├── QueryAnswerExplanationService.java │ │ │ │ ├── QueryApiService.java │ │ │ │ ├── QueryService.java │ │ │ │ └── package-info.java │ │ │ └── session │ │ │ ├── CycAddress.java │ │ │ ├── CycAddressImpl.java │ │ │ ├── CycServerInfo.java │ │ │ ├── CycServerReleaseType.java │ │ │ ├── CycSession.java │ │ │ ├── CycSessionConfiguration.java │ │ │ ├── CycSessionConfigurationProperties.java │ │ │ ├── ServerAddress.java │ │ │ ├── SessionManager.java │ │ │ ├── SessionManagerConfiguration.java │ │ │ ├── SessionManagerConfigurationProperties.java │ │ │ ├── SessionOptions.java │ │ │ ├── exception │ │ │ ├── OpenCycUnsupportedFeatureException.java │ │ │ ├── SessionCommandException.java │ │ │ ├── SessionCommunicationException.java │ │ │ ├── SessionConfigurationException.java │ │ │ ├── SessionException.java │ │ │ ├── SessionInitializationException.java │ │ │ ├── SessionManagerConfigurationException.java │ │ │ ├── SessionManagerException.java │ │ │ ├── SessionRuntimeException.java │ │ │ ├── SessionServiceException.java │ │ │ ├── UnsupportedCycOperationException.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ └── spi │ │ │ ├── SessionApiService.java │ │ │ └── package-info.java │ └── resources │ │ └── com │ │ └── cyc │ │ └── core │ │ └── BuildInfo.properties │ └── site │ └── site.xml ├── pom.xml └── src └── site └── resources └── images └── api-stack.png /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | nbactions.xml 8 | nb-configuration.xml 9 | .classpath 10 | .project 11 | .settings/ 12 | *~ 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Cyc Java API Suite 2 | ================== 3 | 4 | The Cyc Java API Suite comprises a set of Java APIs (and implementations) for developing Cyc-based 5 | applications or otherwise accessing Cyc capabilities, and provides a layered suite of functionality. 6 | We have currently released the following Java libraries: 7 | 8 | * [Core API Specification](core-api/README.md): Core set of APIs for interacting with the Cyc 9 | inference engine and knowledge base. 10 | * [Core Client Implementation](core-client/README.md): Reference implementation for the Core API 11 | Specification. 12 | 13 | Additionally, the [Model Generator Suite](https://github.com/cycorp/model-generator-suite) is 14 | available in a separate repository. 15 | 16 | Further functionality will be rolled out in a series of releases, including the Knowledge 17 | Management, Natural Language, Structured Knowledge, and Administration APIs: 18 | 19 |
29 | * An API may have multiple services defined, but only the API's CycApiEntryPoint will be loaded, 30 | * and the primary service may then provide additional services. For example, the KB API's 31 | * {@link com.cyc.kb.spi.KbApiService} provides a number of other KB-related services 32 | * ({@link com.cyc.kb.spi.AssertionService}, {@link com.cyc.kb.spi.KbTermService}, etc.) To simplify 33 | * service loading, CycApiEntryPoints may have methods which accept a class that extends 34 | * {@link com.cyc.CycServicesLoader} to provide access to whatever service loader methods would be 35 | * appropriate; an example of this is 36 | * {@link com.cyc.query.spi.QueryApiService#getQueryExplanationFactoryServices(com.cyc.CoreServicesLoader) }. 37 | * 38 | *
39 | * Note that a CycApiEntryPoint may not be directly exposed to the calling application. Although
40 | * this is possible, method calls to a CycApiEntryPoint are often made through wrapper methods on
41 | * {@link Cyc}, and/or via static interface methods.
42 | *
43 | * @author nwinant
44 | */
45 | public interface CycApiEntryPoint {
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/DefaultNlApiServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cyc;
2 |
3 | /*
4 | * #%L
5 | * File: DefaultNlApiServiceImpl.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 |
24 | import com.cyc.nl.Paraphraser;
25 | import com.cyc.nl.Paraphraser.ParaphrasableType;
26 | import com.cyc.nl.spi.NlApiService;
27 | import com.cyc.nl.spi.ParaphraserFactory;
28 | import org.slf4j.Logger;
29 | import org.slf4j.LoggerFactory;
30 |
31 | /**
32 | * Interface for generating structured paraphrases of terms.
33 | *
34 | * DefaultNlApiServiceImpl objects provide the ability to generate natural language strings for CycL
35 | * objects (e.g. sentences and terms). The basic DefaultNlApiServiceImpl implementation available
36 | * from baseclient will provide very basic paraphrasing functionality. If the NL API is available on
37 | * the classpath, the
32 | * The KB API factory methods that find or create terms and assertions cache the KB Object they
33 | * return. Multiple get/findOrCreate requests to the same object will be return the identical
34 | * underlying object from the cache. The cache can be cleared using {@link KbService#clearCache()},
35 | * which can be called like so: {@code Cyc.getKbService().clearCache(); }
36 | *
37 | * When an object is deleted using {@link Assertion#delete()} or {@link KbTerm#delete()}, the object
38 | * is marked "invalid". The validity of the object can be checked using {@link Assertion#isValid()}
39 | * or {@link KbTerm#isValid()}, respectively.
40 | *
41 | * @author Vijay Raj
42 | * @version $Id: StaleKbObjectException.java 151668 2014-06-03 21:46:52Z jmoszko
43 | * $
44 | */
45 | public class StaleKbObjectException extends KbRuntimeException {
46 |
47 | //====| Factory methods |=================================================================//
48 |
49 | /**
50 | * Converts a Throwable to a StaleKbObjectException. If the Throwable is a
51 | * StaleKbObjectException, it will be passed through unmodified; otherwise, it will be wrapped
52 | * in a new StaleKbObjectException.
53 | *
54 | * @param cause the Throwable to convert
55 | *
56 | * @return a StaleKbObjectException
57 | */
58 | public static StaleKbObjectException fromThrowable(Throwable cause) {
59 | return (cause instanceof StaleKbObjectException)
60 | ? (StaleKbObjectException) cause
61 | : new StaleKbObjectException(cause);
62 | }
63 |
64 | /**
65 | * Converts a Throwable to a StaleKbObjectException with the specified detail message. If the
66 | * Throwable is a StaleKbObjectException and if the Throwable's message is identical to the
67 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
68 | * a new StaleKbObjectException with the detail message.
69 | *
70 | * @param cause the Throwable to convert
71 | * @param message the specified detail message
72 | *
73 | * @return a StaleKbObjectException
74 | */
75 | public static StaleKbObjectException fromThrowable(String message, Throwable cause) {
76 | return (cause instanceof StaleKbObjectException && Objects.equals(message, cause.getMessage()))
77 | ? (StaleKbObjectException) cause
78 | : new StaleKbObjectException(message, cause);
79 | }
80 |
81 | //====| Construction |====================================================================//
82 |
83 | public StaleKbObjectException(String msg) {
84 | super(msg);
85 | }
86 |
87 | protected StaleKbObjectException(Throwable cause) {
88 | super(cause);
89 | }
90 |
91 | protected StaleKbObjectException(String msg, Throwable cause) {
92 | super(msg, cause);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/VariableArityException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | /*
4 | * #%L
5 | * File: VariableArityException.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import com.cyc.kb.Relation;
24 | import java.util.Objects;
25 |
26 | /**
27 | * Thrown when the arity of a Relation without a fixed arity is requested. For
28 | * variable-arity relations, {@link Relation#getArityMin()} and
29 | * {@link Relation#getArityMax()} methods should be used.
30 | *
31 | * @author Dave Schneider
32 | * @version $Id: VariableArityException.java 151668 2014-06-03 21:46:52Z jmoszko
33 | * $
34 | */
35 | public class VariableArityException extends KbRuntimeException {
36 |
37 | //====| Factory methods |=================================================================//
38 |
39 | /**
40 | * Converts a Throwable to a VariableArityException with the specified detail message. If the
41 | * Throwable is a VariableArityException and if the Throwable's message is identical to the
42 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
43 | * a new VariableArityException with the detail message.
44 | *
45 | * @param cause the Throwable to convert
46 | * @param message the specified detail message
47 | *
48 | * @return a VariableArityException
49 | */
50 | public static VariableArityException fromThrowable(String message, Throwable cause) {
51 | return (cause instanceof VariableArityException && Objects.equals(message, cause.getMessage()))
52 | ? (VariableArityException) cause
53 | : new VariableArityException(message, cause);
54 | }
55 |
56 | //====| Construction |====================================================================//
57 |
58 | public VariableArityException(String message) {
59 | super(message);
60 | }
61 |
62 | protected VariableArityException(String message, Throwable cause) {
63 | super(message, cause);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * KB API exception hierarchy.
3 | *
4 | * {@link com.cyc.kb.exception.KbException} is the root level exception for KB API. All other
5 | * exceptions thrown by the API are sub-classes of this.
6 | *
7 | * {@link com.cyc.kb.exception.StaleKbObjectException} is thrown when the Java program uses
8 | * an object reference that points to a KB concept that has been deleted, by calling the API
9 | * delete method.
10 | *
11 | * {@link com.cyc.kb.exception.KbRuntimeException} is thrown mostly wrapping any lower-level
12 | * connection exceptions.
13 | *
14 | * Refer to individual exception documentation for more details.
15 | */
16 | package com.cyc.kb.exception;
17 |
18 | /*
19 | * #%L
20 | * File: package-info.java
21 | * Project: Core API
22 | * %%
23 | * Copyright (C) 2015 - 2019 Cycorp, Inc
24 | * %%
25 | * Licensed under the Apache License, Version 2.0 (the "License");
26 | * you may not use this file except in compliance with the License.
27 | * You may obtain a copy of the License at
28 | *
29 | * http://www.apache.org/licenses/LICENSE-2.0
30 | *
31 | * Unless required by applicable law or agreed to in writing, software
32 | * distributed under the License is distributed on an "AS IS" BASIS,
33 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 | * See the License for the specific language governing permissions and
35 | * limitations under the License.
36 | * #L%
37 | */
38 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Interfaces for manipulating CycL-based java objects, both for the purpose of
3 | * making assertions and for retrieving terms and values via simple queries.
4 | *
5 | *
24 | *
36 | * Once the objects exists, the {@code #get(...)} and {@code #findOrCreate(...)} methods on
37 | * {@link com.cyc.kb.Assertion}, {@link com.cyc.kb.Fact}, and {@link com.cyc.kb.Rule} can be used to
38 | * create the actual assertions. The KB API generally allows the creation and retrieval of Cyc KB
39 | * objects (KbIndividuals, KbCollections, Facts, etc.) from a variety of forms including their
40 | * string representations, their IDs, and from the objects that will comprise them. The string-based
41 | * factory methods in InferenceAnswerIdentifier is designed to...
30 | *
31 | * @author jmoszko, May 13, 2014, 5:54:59 PM
32 | * @version $Id: InferenceAnswerIdentifier.java 185299 2019-01-14 16:15:35Z daves $
33 | */
34 | public interface InferenceAnswerIdentifier {
35 |
36 | int getAnswerId();
37 |
38 | InferenceIdentifier getInferenceIdentifier();
39 |
40 | CycSession getSession();
41 |
42 | String stringApiValue();
43 |
44 | Object cycListApiValue();
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/InferenceIdentifier.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query;
2 |
3 | import com.cyc.session.CycSession;
4 |
5 | /*
6 | * #%L
7 | * File: InferenceIdentifier.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | *
28 | * @author nwinant
29 | */
30 | public interface InferenceIdentifier {
31 |
32 | void close();
33 |
34 | Integer getFirstProofId(Integer answerId);
35 |
36 | int getInferenceId();
37 |
38 | int getProblemStoreId();
39 |
40 | /**
41 | * Interrupt this inference.
42 | *
43 | * @param patience Give inference process this many seconds to halt gracefully,
44 | * after which terminate it with prejudice. A null value indicates infinite patience.
45 | */
46 | void interrupt(final Integer patience);
47 |
48 | String stringApiValue();
49 |
50 | CycSession getSession();
51 | }
52 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/InferenceStatus.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query;
2 |
3 | import com.cyc.query.parameters.InferenceParameterValue;
4 |
5 | /*
6 | * #%L
7 | * File: InferenceStatus.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 |
27 | /**
28 | *
29 | * @author nwinant
30 | */
31 | //@todo this doesn't really implement parameter-value, but it's something very similar
32 | public enum InferenceStatus implements InferenceParameterValue {
33 |
34 | /**
35 | * Newly created, attached to a problem store, query & mt unspecified.
36 | */
37 | NEW,
38 |
39 | /**
40 | * Query & mt specified, resource constraints still unspecified.
41 | */
42 | PREPARED,
43 |
44 | /**
45 | * Resource constraints specified, ready to start running under those constraints.
46 | */
47 | READY,
48 |
49 | /**
50 | * The inference has not yet been run.
51 | */
52 | NOT_STARTED,
53 |
54 | /**
55 | * The inference has been told to start, but may not actually be running yet.
56 | */
57 | STARTED,
58 |
59 | /**
60 | * Currently in the act of performing inference.
61 | */
62 | RUNNING,
63 |
64 | /**
65 | * Inference has been suspended, but may be possible to continue.
66 | */
67 | SUSPENDED,
68 |
69 | /**
70 | * Inference was explicitly destroyed; answers & problems cannot be accessed.
71 | */
72 | DEAD,
73 |
74 | /**
75 | * The query itself is a tautology, and therefore no inference will be performed on it.
76 | */
77 | TAUTOLOGY,
78 |
79 | /**
80 | * The query contains an internal contradiction, and cannot be run.
81 | */
82 | CONTRADICTION,
83 |
84 | /**
85 | * The query is syntactically ill-formed and cannot be run.
86 | */
87 | ILL_FORMED;
88 |
89 |
90 | // Public
91 | /**
92 | * Does this status indicates that an inference may be currently available for this query?
93 | *
94 | * @return true if has been run, or is currently running, and the inference has not been
95 | * destroyed.
96 | */
97 | public boolean indicatesInferenceExists() {
98 | return this.equals(STARTED)
99 | //|| this.equals(NEW)
100 | || this.equals(RUNNING)
101 | || this.equals(SUSPENDED);
102 | }
103 |
104 | /**
105 | * Does this status indicate that the inference is done? It may be continuable, but no further
106 | * work will be performed on it until instructed.
107 | *
108 | * @return true iff this status indicates that the inference is done.
109 | */
110 | boolean indicatesDone() {
111 | return this.equals(SUSPENDED)
112 | || this.equals(DEAD);
113 | }
114 |
115 | /**
116 | * Does this status indicate that there is a problem with the query, such that an inference cannot
117 | * be run?
118 | *
119 | * @return true iff this status indicates that the query cannot be run.
120 | */
121 | boolean indicatesQueryError() {
122 | return this.equals(TAUTOLOGY)
123 | || this.equals(CONTRADICTION)
124 | || this.equals(ILL_FORMED);
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/InferenceSuspendReason.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query;
2 |
3 | /*
4 | * #%L
5 | * File: InferenceSuspendReason.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 |
24 | /**
25 | *
26 | * @author nwinant
27 | */
28 | public interface InferenceSuspendReason {
29 |
30 | /** Can an inference suspended for this reason be reset? */
31 | boolean allowReset();
32 |
33 | /** Can an inference suspended for this reason be stopped? */
34 | boolean allowStop();
35 |
36 | /** A string to describe the status of the inference. */
37 | String getInferenceStatusString();
38 |
39 | /** Can an inference suspended for this reason be continued? */
40 | boolean isContinuable();
41 |
42 | /** Was inference suspended because of an error? */
43 | boolean isError();
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/ParaphrasedQueryAnswer.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query;
2 |
3 | /*
4 | * #%L
5 | * File: ParaphrasedQueryAnswer.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import com.cyc.kb.Variable;
24 | import com.cyc.nl.Paraphrase;
25 | import com.cyc.nl.Paraphraser;
26 | import java.util.Map;
27 |
28 | /**
29 | *
30 | * @author daves
31 | */
32 | public interface ParaphrasedQueryAnswer extends QueryAnswer {
33 |
34 | public Paraphraser getParaphraser();
35 |
36 | public Paraphrase getBindingParaphrase(Variable var);
37 |
38 | public Map
36 | * A
31 | * Note that in earlier API versions, this was sometimes referred to as a "Justification". To reduce
32 | * ambiguity, this interface has been renamed as of Core API 1.0.0.
33 | *
34 | * @author daves
35 | */
36 | public interface QueryAnswerExplanation {
37 |
38 | //====| Factory methods |=================================================================//
39 |
40 | /**
41 | * Returns an explanation for an answer, generating one if necessary via a call to
42 | * {@link QueryAnswerExplanationGenerator#generate()}.
43 | *
44 | * @param
45 | * This is normally performed automatically by Cyc, but some older releases may not do so.
46 | *
47 | * @param includePracticeRules whether to include queryPracticeRules
48 | *
49 | * @throws QueryConstructionException
50 | * @throws SessionCommunicationException
51 | */
52 | void useOnlySpecifiedRules(boolean includePracticeRules)
53 | throws QueryConstructionException, SessionCommunicationException;
54 |
55 | /**
56 | * If any rules are specified on the inference parameters for this query, remove them and let Cyc
57 | * decide what rules are relevant.
58 | */
59 | void allowAllRules();
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/exception/ProofViewException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.exception;
2 |
3 | /*
4 | * #%L
5 | * File: ProofViewException.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import java.util.Objects;
24 |
25 | /**
26 | * The class of {@link Exception} thrown when a {@link com.cyc.query.ProofView} cannot be
27 | * provided as specified.
28 | *
29 | * @author baxter
30 | */
31 | public class ProofViewException extends QueryException {
32 |
33 | //====| Factory methods |=================================================================//
34 |
35 | /**
36 | * Converts a Throwable to a ProofViewException. If the Throwable is a
37 | * ProofViewException, it will be passed through unmodified; otherwise, it will be wrapped
38 | * in a new ProofViewException.
39 | *
40 | * @param cause the Throwable to convert
41 | *
42 | * @return a ProofViewException
43 | */
44 | public static ProofViewException fromThrowable(Throwable cause) {
45 | return (cause instanceof ProofViewException)
46 | ? (ProofViewException) cause
47 | : new ProofViewException(cause);
48 | }
49 |
50 | /**
51 | * Converts a Throwable to a ProofViewException with the specified detail message. If the
52 | * Throwable is a ProofViewException and if the Throwable's message is identical to the
53 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
54 | * a new ProofViewException with the detail message.
55 | *
56 | * @param cause the Throwable to convert
57 | * @param message the specified detail message
58 | *
59 | * @return a ProofViewException
60 | */
61 | public static ProofViewException fromThrowable(String message, Throwable cause) {
62 | return (cause instanceof ProofViewException && Objects.equals(message, cause.getMessage()))
63 | ? (ProofViewException) cause
64 | : new ProofViewException(message, cause);
65 | }
66 |
67 | //====| Construction |====================================================================//
68 |
69 | protected ProofViewException(Throwable throwable) {
70 | super(throwable);
71 | }
72 |
73 | protected ProofViewException(String message, Throwable throwable) {
74 | super(message, throwable);
75 | }
76 |
77 | public ProofViewException(String message) {
78 | super(message);
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/exception/QueryConstructionException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.exception;
2 |
3 | /*
4 | * #%L
5 | * File: QueryConstructionException.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import java.util.Objects;
24 |
25 | /**
26 | * The class of {@link Exception} thrown when a {@link com.cyc.query.Query} cannot be constructed as
27 | * specified.
28 | *
29 | * @author baxter
30 | */
31 | public class QueryConstructionException extends QueryException {
32 |
33 | //====| Factory methods |=================================================================//
34 |
35 | /**
36 | * Converts a Throwable to a QueryConstructionException. If the Throwable is a
37 | * QueryConstructionException, it will be passed through unmodified; otherwise, it will be wrapped
38 | * in a new QueryConstructionException.
39 | *
40 | * @param cause the Throwable to convert
41 | *
42 | * @return a QueryConstructionException
43 | */
44 | public static QueryConstructionException fromThrowable(Throwable cause) {
45 | return (cause instanceof QueryConstructionException)
46 | ? (QueryConstructionException) cause
47 | : new QueryConstructionException(cause);
48 | }
49 |
50 | /**
51 | * Converts a Throwable to a QueryConstructionException with the specified detail message. If the
52 | * Throwable is a QueryConstructionException and if the Throwable's message is identical to the
53 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
54 | * a new QueryConstructionException with the detail message.
55 | *
56 | * @param cause the Throwable to convert
57 | * @param message the specified detail message
58 | *
59 | * @return a QueryConstructionException
60 | */
61 | public static QueryConstructionException fromThrowable(String message, Throwable cause) {
62 | return (cause instanceof QueryConstructionException && Objects.equals(message, cause.getMessage()))
63 | ? (QueryConstructionException) cause
64 | : new QueryConstructionException(message, cause);
65 | }
66 |
67 | //====| Construction |====================================================================//
68 |
69 | protected QueryConstructionException(Throwable throwable) {
70 | super(throwable);
71 | }
72 |
73 | protected QueryConstructionException(String message, Throwable throwable) {
74 | super(message, throwable);
75 | }
76 |
77 | public QueryConstructionException(String message) {
78 | super(message);
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/exception/QueryException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.exception;
2 |
3 | /*
4 | * #%L
5 | * File: QueryException.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import java.util.Objects;
24 |
25 | /**
26 | * The root of the checked exception hierarchy in the Query API.
27 | *
28 | * @author baxter
29 | */
30 | public class QueryException extends Exception {
31 |
32 | //====| Factory methods |=================================================================//
33 |
34 | /**
35 | * Converts a Throwable to a QueryException. If the Throwable is a QueryException, it will be
36 | * passed through unmodified; otherwise, it will be wrapped in a new QueryException.
37 | *
38 | * @param cause the Throwable to convert
39 | *
40 | * @return a QueryException
41 | */
42 | public static QueryException fromThrowable(Throwable cause) {
43 | return (cause instanceof QueryException)
44 | ? (QueryException) cause
45 | : new QueryException(cause);
46 | }
47 |
48 | /**
49 | * Converts a Throwable to a QueryException with the specified detail message. If the Throwable is
50 | * a QueryException and if the Throwable's message is identical to the one supplied, the Throwable
51 | * will be passed through unmodified; otherwise, it will be wrapped in a new QueryException with
52 | * the detail message.
53 | *
54 | * @param cause the Throwable to convert
55 | * @param message the specified detail message
56 | *
57 | * @return a QueryException
58 | */
59 | public static QueryException fromThrowable(String message, Throwable cause) {
60 | return (cause instanceof QueryException && Objects.equals(message, cause.getMessage()))
61 | ? (QueryException) cause
62 | : new QueryException(message, cause);
63 | }
64 |
65 | //====| Construction |====================================================================//
66 |
67 | public QueryException(final String message) {
68 | super(message);
69 | }
70 |
71 | protected QueryException(final String message, final Throwable cause) {
72 | super(message, cause);
73 | }
74 |
75 | protected QueryException(final Throwable cause) {
76 | super(cause);
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/exception/QueryRuntimeException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.exception;
2 |
3 | /*
4 | * #%L
5 | * File: QueryRuntimeException.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import java.util.Objects;
24 |
25 | /**
26 | * The root of the unchecked exception hierarchy in the Query API.
27 | *
28 | * @author baxter
29 | */
30 | public class QueryRuntimeException extends RuntimeException {
31 |
32 | //====| Factory methods |=================================================================//
33 |
34 | /**
35 | * Converts a Throwable to a QueryRuntimeException. If the Throwable is a QueryRuntimeException,
36 | * it will be passed through unmodified; otherwise, it will be wrapped in a new
37 | * QueryRuntimeException.
38 | *
39 | * @param t the Throwable to convert
40 | *
41 | * @return a QueryRuntimeException
42 | */
43 | public static QueryRuntimeException fromThrowable(Throwable t) {
44 | return (t instanceof QueryRuntimeException)
45 | ? (QueryRuntimeException) t
46 | : new QueryRuntimeException(t);
47 | }
48 |
49 | /**
50 | * Converts a Throwable to a QueryRuntimeException with the specified detail message. If the
51 | * Throwable is a QueryRuntimeException and if the Throwable's message is identical to the one
52 | * supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in a
53 | * new QueryRuntimeException with the detail message.
54 | *
55 | * @param t the Throwable to convert
56 | * @param message the specified detail message
57 | *
58 | * @return a QueryRuntimeException
59 | */
60 | public static QueryRuntimeException fromThrowable(String message, Throwable t) {
61 | return (t instanceof QueryRuntimeException && Objects.equals(message, t.getMessage()))
62 | ? (QueryRuntimeException) t
63 | : new QueryRuntimeException(message, t);
64 | }
65 |
66 | //====| Construction |====================================================================//
67 |
68 | public QueryRuntimeException(final String message) {
69 | super(message);
70 | }
71 |
72 | protected QueryRuntimeException(final String message, final Throwable cause) {
73 | super(message, cause);
74 | }
75 |
76 | protected QueryRuntimeException(final Throwable cause) {
77 | super(cause);
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Query API exception hierarchy.
3 | *
4 | * {@link com.cyc.query.exception.QueryException} and
5 | * {@link com.cyc.query.exception.QueryRuntimeException} are the root level
6 | * exceptions for Query API. All other exceptions thrown by the API are
7 | * sub-classes of these two classes.
8 | *
9 | * Refer to individual exception documentation for more details.
10 | */
11 | package com.cyc.query.exception;
12 |
13 | /*
14 | * #%L
15 | * File: package-info.java
16 | * Project: Core API
17 | * %%
18 | * Copyright (C) 2015 - 2019 Cycorp, Inc
19 | * %%
20 | * Licensed under the Apache License, Version 2.0 (the "License");
21 | * you may not use this file except in compliance with the License.
22 | * You may obtain a copy of the License at
23 | *
24 | * http://www.apache.org/licenses/LICENSE-2.0
25 | *
26 | * Unless required by applicable law or agreed to in writing, software
27 | * distributed under the License is distributed on an "AS IS" BASIS,
28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 | * See the License for the specific language governing permissions and
30 | * limitations under the License.
31 | * #L%
32 | */
33 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/graph/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Query API graph utilities.
3 | */
4 | package com.cyc.query.graph;
5 |
6 | /*
7 | * #%L
8 | * File: package-info.java
9 | * Project: Core API
10 | * %%
11 | * Copyright (C) 2015 - 2019 Cycorp, Inc
12 | * %%
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * #L%
25 | */
26 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/metrics/InferenceMetric.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.metrics;
2 |
3 | /*
4 | * #%L
5 | * File: InferenceMetric.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | /**
24 | * An interface representing an inference metric. Inference metrics are a way of telling Cyc's
25 | * inference engine to collect a certain type of data for later inspection. The most common metrics
26 | * are in {@link StandardInferenceMetric}.
27 | *
28 | * @author baxter
29 | */
30 | public interface InferenceMetric {
31 |
32 | /**
33 | * Return the name by which this metric is known to Cyc.
34 | *
35 | * @return the name
36 | */
37 | String getName();
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/metrics/InferenceMetrics.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.metrics;
2 |
3 | /*
4 | * #%L
5 | * File: InferenceMetrics.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import com.cyc.query.parameters.InferenceParameterValue;
24 | import java.util.Set;
25 |
26 | /**
27 | * A Set of {@link InferenceMetric} values.
28 | *
29 | * Inference metrics are a way of telling Cyc's inference engine to collect a certain type of data
30 | * for later inspection. The most common metrics are in {@link StandardInferenceMetric}.
31 | *
32 | * @author nwinant
33 | */
34 | public interface InferenceMetrics extends Set InferenceParameterValueDescription is designed to...
28 | *
29 | * @author zelal
30 | * @date August 14, 2005, 12:47 PM
31 | * @version $Id: InferenceParameterValueDescription.java 185299 2019-01-14 16:15:35Z daves $
32 | */
33 | public interface InferenceParameterValueDescription {
34 |
35 | void setValue(Object value);
36 |
37 | Object getValue();
38 |
39 | String getShortDescription();
40 |
41 | String getLongDescription();
42 | }
43 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/parameters/ProblemReusePolicy.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.parameters;
2 |
3 | /*
4 | * #%L
5 | * File: ProblemReusePolicy.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 |
24 | /**
25 | * Which problems are considered for reuse by the Worker (aka Problem Store).
26 | * Problems deemed "equal" are reused, but since equality reasoning can be
27 | * non-trivial, under some policies not all problems are checked.
28 | *
29 | * @author baxter
30 | */
31 | public enum ProblemReusePolicy implements InferenceParameterValue {
32 |
33 | /**
34 | * The worker tries to do equality reasoning on all problems.
35 | */
36 | ALL,
37 | /**
38 | * The worker tries to do equality reasoning only on single-literal problems.
39 | */
40 | SINGLE_LITERAL,
41 | /**
42 | * The worker doesn't try to do equality reasoning on any kind of problem.
43 | */
44 | NONE;
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/parameters/ProofValidationMode.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.parameters;
2 |
3 | /*
4 | * #%L
5 | * File: ProofValidationMode.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 |
24 |
25 | /**
26 | * How carefully to check proofs for semantic well-formedness.
27 | *
28 | * @author baxter
29 | */
30 | public enum ProofValidationMode implements InferenceParameterValue {
31 |
32 | /**
33 | * Full (most expensive). The intermediate proofs that are used in inference
34 | * are checked for all kinds of semantic well-formedness.
35 | */
36 | ALL,
37 | /**
38 | * Only arg-type. The intermediate proofs that are used in inference are
39 | * checked only for arg-type constraints.
40 | */
41 | ARG_TYPE,
42 | /**
43 | * Only HL validations. The intermediate proofs that are used in inference are
44 | * checked only for HL validations.
45 | */
46 | MINIMAL,
47 | /**
48 | * None (least expensive). No semantic well-formedness checks are performed on
49 | * the intermediate proofs that are used in inference.
50 | */
51 | NONE;
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/parameters/ResultUniqueness.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.parameters;
2 |
3 | /*
4 | * #%L
5 | * File: ResultUniqueness.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 |
24 | /**
25 | *
26 | * @author baxter
27 | */
28 | public enum ResultUniqueness implements InferenceParameterValue {
29 |
30 | /**
31 | * Two answers are considered the same if they assign the same bindings to all
32 | * open variables.
33 | */
34 | BINDINGS, /**
35 | * Results can have the same answers, as long as they have distinct proofs.
36 | */
37 | PROOF;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/parameters/TransitiveClosureMode.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.parameters;
2 |
3 | /*
4 | * #%L
5 | * File: TransitiveClosureMode.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 |
24 | /**
25 | * The degree to which modules (such as transitiveViaArg) should generate
26 | * transitive closures.
27 | *
28 | * @author baxter
29 | */
30 | public enum TransitiveClosureMode implements InferenceParameterValue {
31 |
32 | /**
33 | * Full closures (very expensive). Transitivity modules will provide the
34 | * minimal answers and full transitive closures on the minimal answers.
35 | */
36 | ALL, /**
37 | * Focused closures (expensive). Transitivity modules will provide the minimal
38 | * answers and focused transitive closures on the minimal answers.
39 | */
40 | FOCUSED,
41 | /**
42 | * No closures. Transitivity modules will only provide the minimal answers
43 | * (and no transitive closures on the minimal answers).
44 | *
45 | */
46 | NONE;
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/parameters/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Interfaces for inference parameters, which determine how Cyc performs an inference.
3 | */
4 | package com.cyc.query.parameters;
5 |
6 | /*
7 | * #%L
8 | * File: package-info.java
9 | * Project: Core API
10 | * %%
11 | * Copyright (C) 2015 - 2019 Cycorp, Inc
12 | * %%
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * #L%
25 | */
26 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/spi/ProofViewService.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query.spi;
2 |
3 | /*
4 | * #%L
5 | * File: ProofViewService.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import com.cyc.query.ProofView;
24 | import com.cyc.query.ProofViewGenerator;
25 | import com.cyc.query.ProofViewMarshaller;
26 | import com.cyc.query.ProofViewSpecification;
27 | import com.cyc.query.QueryAnswer;
28 | import com.cyc.query.QueryAnswerExplanationSpecification;
29 |
30 | /**
31 | * Service provider interface for factories which produce ProofViewGenerators.
32 | *
33 | * @author nwinant
34 | */
35 | public interface ProofViewService extends QueryAnswerExplanationService
4 | * The Session API defines simple, yet flexible configuration-driven management of Cyc sessions --
5 | * such as acquiring server addresses, managing connections, etc. -- so that library and application
6 | * developers don't need to write it into their own code. At the same time, the API is extensible
7 | * enough developers can reasonably write their own modules to address unique configuration needs.
8 | *
9 | * End users should only need to directly interact with the classes and interfaces defined in
10 | * com.cyc.session. Interfaces and classes in sub-packages are for implementation providers.
11 | */
12 | package com.cyc.session;
13 |
14 | /*
15 | * #%L
16 | * File: package-info.java
17 | * Project: Core API
18 | * %%
19 | * Copyright (C) 2015 - 2019 Cycorp, Inc
20 | * %%
21 | * Licensed under the Apache License, Version 2.0 (the "License");
22 | * you may not use this file except in compliance with the License.
23 | * You may obtain a copy of the License at
24 | *
25 | * http://www.apache.org/licenses/LICENSE-2.0
26 | *
27 | * Unless required by applicable law or agreed to in writing, software
28 | * distributed under the License is distributed on an "AS IS" BASIS,
29 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 | * See the License for the specific language governing permissions and
31 | * limitations under the License.
32 | * #L%
33 | */
34 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/session/spi/SessionApiService.java:
--------------------------------------------------------------------------------
1 | package com.cyc.session.spi;
2 |
3 | /*
4 | * #%L
5 | * File: SessionApiService.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import com.cyc.CycApiEntryPoint;
24 | import com.cyc.session.SessionManager;
25 | import com.cyc.session.SessionManagerConfiguration;
26 | import com.cyc.session.exception.SessionManagerConfigurationException;
27 | import com.cyc.session.exception.SessionManagerException;
28 | import com.cyc.session.exception.SessionServiceException;
29 |
30 | /**
31 | * The primary entrypoint for a Session API implementation.
32 | *
33 | * @author nwinant
34 | */
35 | public interface SessionApiService extends CycApiEntryPoint {
36 |
37 | /**
38 | * Returns the current SessionManager instance.
39 | *
40 | * @return
41 | */
42 | SessionManager getSessionManager();
43 |
44 | /**
45 | * Loads a new SessionManager, configured via the supplied SessionManagerConfiguration. The
46 | * previous SessionManager will be closed if it has not been closed already.
47 | *
48 | * @param configuration
49 | *
50 | * @return the new SessionManager
51 | *
52 | * @throws SessionServiceException
53 | * @throws SessionManagerException
54 | * @throws SessionManagerConfigurationException
55 | *
56 | * @see #reloadSessionManager()
57 | */
58 | SessionManager reloadSessionManager(SessionManagerConfiguration configuration)
59 | throws SessionServiceException, SessionManagerException, SessionManagerConfigurationException;
60 |
61 | /**
62 | * Loads a new SessionManager with the default SessionManagerConfiguration. The previous
63 | * SessionManager will be closed if it has not been closed already.
64 | *
65 | * @return the new SessionManager
66 | *
67 | * @throws SessionServiceException
68 | * @throws SessionManagerException
69 | *
70 | * @see #reloadSessionManager(com.cyc.session.manager.SessionManagerConfiguration)
71 | */
72 | SessionManager reloadSessionManager()
73 | throws SessionServiceException, SessionManagerException, SessionManagerConfigurationException;
74 |
75 | /* *
76 | * Returns the configuration for the SessionManager.
77 | *
78 | * @return
79 | * /
80 | SessionManagerConfiguration getConfiguration();
81 | */
82 | }
83 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/session/spi/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * All Session API service provider interfaces.
3 | */
4 | package com.cyc.session.spi;
5 |
6 | /*
7 | * #%L
8 | * File: package-info.java
9 | * Project: Core API
10 | * %%
11 | * Copyright (C) 2015 - 2019 Cycorp, Inc
12 | * %%
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * #L%
25 | */
26 |
--------------------------------------------------------------------------------
/core-api/src/main/resources/com/cyc/core/BuildInfo.properties:
--------------------------------------------------------------------------------
1 | ###
2 | # #%L
3 | # CoreAPISuite
4 | # %%
5 | # Copyright (C) 1995 - 2014 Cycorp, Inc
6 | # %%
7 | # This software is the proprietary information of Cycorp, Inc.
8 | # Use is subject to license terms.
9 | # #L%
10 | ###
11 | groupId = ${project.groupId}
12 | artifactId = ${project.artifactId}
13 | name = ${project.name}
14 | version = ${project.version}
15 | timeStamp = ${timestamp}
16 | scmRevision = ${cyc-core-api.revision}
17 |
--------------------------------------------------------------------------------
/core-api/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 | getParaphraser
methods of this class will return a paraphraser
38 | * that is more flexible. The BasicParaphraser
(returned if only the baseclient is
39 | * available) is compatible with all versions of Cyc (including OpenCyc).
40 | *
41 | * @author baxter
42 | * @param SecondOrderCollection
with the name nameOrId
. This static
41 | * method wraps a call to {@link SecondOrderCollectionService#get(java.lang.String) }; see that
42 | * method's documentation for more details.
43 | *
44 | * @param nameOrId the string representation or the HLID of the #$SecondOrderCollection
45 | *
46 | * @return a new SecondOrderCollection
47 | *
48 | * @throws KbTypeException
49 | * @throws CreateException
50 | */
51 | public static SecondOrderCollection get(String nameOrId)
52 | throws KbTypeException, CreateException {
53 | return Cyc.getSecondOrderCollectionService().get(nameOrId);
54 | }
55 |
56 | public static SecondOrderCollection findOrCreate(String nameOrId) throws CreateException, KbTypeException {
57 | return Cyc.getSecondOrderCollectionService().findOrCreate(nameOrId);
58 | }
59 |
60 | public static SecondOrderCollection findOrCreate(String nameOrId, String constraintColStr)
61 | throws CreateException, KbTypeException {
62 | return Cyc.getSecondOrderCollectionService().findOrCreate(nameOrId, constraintColStr);
63 | }
64 |
65 | public static SecondOrderCollection findOrCreate(String nameOrId, String constraintColStr, String ctxStr)
66 | throws CreateException, KbTypeException {
67 | return Cyc.getSecondOrderCollectionService().findOrCreate(nameOrId, constraintColStr, ctxStr);
68 | }
69 |
70 | public static SecondOrderCollection findOrCreate(String nameOrId, KbCollection constraintCol)
71 | throws CreateException, KbTypeException {
72 | return Cyc.getSecondOrderCollectionService().findOrCreate(nameOrId, constraintCol);
73 | }
74 |
75 | public static SecondOrderCollection findOrCreate(String nameOrId, KbCollection constraintCol, Context ctx)
76 | throws CreateException, KbTypeException {
77 | return Cyc.getSecondOrderCollectionService().findOrCreate(nameOrId, constraintCol, ctx);
78 | }
79 |
80 | public static boolean existsAsType(String nameOrId) {
81 | return Cyc.getSecondOrderCollectionService().existsAsType(nameOrId);
82 | }
83 |
84 | public static KbStatus getStatus(String nameOrId) {
85 | return Cyc.getSecondOrderCollectionService().getStatus(nameOrId);
86 | }
87 |
88 | //====| Interface methods |===============================================================//
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/Symbol.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb;
2 |
3 | import com.cyc.Cyc;
4 | import com.cyc.kb.exception.KbTypeException;
5 | import com.cyc.kb.spi.SymbolService;
6 |
7 |
8 | /*
9 | * #%L
10 | * File: Symbol.java
11 | * Project: Core API
12 | * %%
13 | * Copyright (C) 2015 - 2019 Cycorp, Inc
14 | * %%
15 | * Licensed under the Apache License, Version 2.0 (the "License");
16 | * you may not use this file except in compliance with the License.
17 | * You may obtain a copy of the License at
18 | *
19 | * http://www.apache.org/licenses/LICENSE-2.0
20 | *
21 | * Unless required by applicable law or agreed to in writing, software
22 | * distributed under the License is distributed on an "AS IS" BASIS,
23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | * See the License for the specific language governing permissions and
25 | * limitations under the License.
26 | * #L%
27 | */
28 |
29 | /**
30 | * The interface for symbols of the SubL
language. Symbols are
31 | * occasionally referenced in CycL
assertions, most notably those
32 | * that denote SubL
functions that test for membership in a
33 | * collection or perform simple functions like string manipulation or
34 | * arithmetic.
35 | *
36 | * @author baxter
37 | */
38 | public interface Symbol extends KbObject {
39 |
40 | //====| Factory methods |=================================================================//
41 |
42 | /**
43 | * Creates an instance of #$CycLSubLSymbol represented by symStr in the underlying KB. This static
44 | * method wraps a call to {@link SymbolService#get(java.lang.String) }; see that method's
45 | * documentation for more details.
46 | *
47 | * @param symStr the string representing an #$CycLSubLSymbol in the KB
48 | *
49 | * @return the Symbol representing an #$CycLSubLSymbol in the KB
50 | *
51 | * @throws KbTypeException Symbols are created on demand and are not expected to throw any
52 | * exception
53 | */
54 | public static Symbol get(String symStr) throws KbTypeException {
55 | return Cyc.getSymbolService().get(symStr);
56 | }
57 |
58 | //====| Interface methods |===============================================================//
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/Variable.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb;
2 |
3 | import com.cyc.Cyc;
4 | import com.cyc.kb.exception.KbTypeException;
5 | import com.cyc.kb.spi.VariableService;
6 |
7 | /*
8 | * #%L
9 | * File: Variable.java
10 | * Project: Core API
11 | * %%
12 | * Copyright (C) 2015 - 2019 Cycorp, Inc
13 | * %%
14 | * Licensed under the Apache License, Version 2.0 (the "License");
15 | * you may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at
17 | *
18 | * http://www.apache.org/licenses/LICENSE-2.0
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | * #L%
26 | */
27 | /**
28 | * The interface for CycL
variables. Variables are used in
29 | * quantified {@link Sentence}s and in Queries.
30 | *
31 | * @author vijay
32 | */
33 | public interface Variable extends KbObject {
34 |
35 | //====| Factory methods |=================================================================//
36 |
37 | /**
38 | * Creates an instance of #$CycLVariable represented by varStr in the underlying KB. This static
39 | * method wraps a call to {@link VariableService#get(java.lang.String) }; see that method's
40 | * documentation for more details.
41 | *
42 | * @param varStr the string representing an #$CycLVariable in the KB
43 | *
44 | * @return the Variable representing an #$CycLVariable in the KB
45 | *
46 | * @throws KbTypeException if the term represented by varStr is not an instance of #$CycLVariable
47 | * and cannot be made into one.
48 | *
49 | * Symbols are created on demand and are not expected to throw any exception
50 | */
51 | public static Variable get(String varStr) throws KbTypeException {
52 | return Cyc.getVariableService().get(varStr);
53 | }
54 |
55 | //====| Interface methods |===============================================================//
56 |
57 | /**
58 | * Get the name of this variable. Does not include the leading '?' character.
59 | *
60 | * @return the name.
61 | */
62 | String getName();
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/CreateException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: CreateException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Thrown when code fails to find or create something from the Cyc KB. {@link KbTypeException} and
28 | * {@link KbTypeConflictException} are not subclasses because they do not indicate if the underlying
29 | * object is not in the KB.
30 | *
31 | * @author Vijay Raj
32 | * @version $Id: CreateException.java 185299 2019-01-14 16:15:35Z daves $
33 | */
34 | public class CreateException extends KbException {
35 |
36 | //====| Factory methods |=================================================================//
37 |
38 | /**
39 | * Converts a Throwable to a CreateException. If the Throwable is a
40 | * CreateException, it will be passed through unmodified; otherwise, it will be wrapped
41 | * in a new CreateException.
42 | *
43 | * @param cause the Throwable to convert
44 | *
45 | * @return a CreateException
46 | */
47 | public static CreateException fromThrowable(Throwable cause) {
48 | return (cause instanceof CreateException)
49 | ? (CreateException) cause
50 | : new CreateException(cause);
51 | }
52 |
53 | /**
54 | * Converts a Throwable to a CreateException with the specified detail message. If the
55 | * Throwable is a CreateException and if the Throwable's message is identical to the
56 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
57 | * a new CreateException with the detail message.
58 | *
59 | * @param cause the Throwable to convert
60 | * @param message the specified detail message
61 | *
62 | * @return a CreateException
63 | */
64 | public static CreateException fromThrowable(String message, Throwable cause) {
65 | return (cause instanceof CreateException && Objects.equals(message, cause.getMessage()))
66 | ? (CreateException) cause
67 | : new CreateException(message, cause);
68 | }
69 |
70 | //====| Construction |====================================================================//
71 |
72 | protected CreateException(Throwable cause) {
73 | super(cause);
74 | }
75 |
76 | public CreateException(String msg) {
77 | super(msg);
78 | }
79 |
80 | protected CreateException(String msg, Throwable cause) {
81 | super(msg, cause);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/DeleteException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: DeleteException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Thrown when code fails to delete something from the Cyc KB.
28 | *
29 | * @author Nathan Winant
30 | * @version $Id: DeleteException.java 185299 2019-01-14 16:15:35Z daves $
31 | */
32 | public class DeleteException extends KbException {
33 |
34 | //====| Factory methods |=================================================================//
35 |
36 | /**
37 | * Converts a Throwable to a DeleteException. If the Throwable is a
38 | * DeleteException, it will be passed through unmodified; otherwise, it will be wrapped
39 | * in a new DeleteException.
40 | *
41 | * @param cause the Throwable to convert
42 | *
43 | * @return a DeleteException
44 | */
45 | public static DeleteException fromThrowable(Throwable cause) {
46 | return (cause instanceof DeleteException)
47 | ? (DeleteException) cause
48 | : new DeleteException(cause);
49 | }
50 |
51 | /**
52 | * Converts a Throwable to a DeleteException with the specified detail message. If the
53 | * Throwable is a DeleteException and if the Throwable's message is identical to the
54 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
55 | * a new DeleteException with the detail message.
56 | *
57 | * @param cause the Throwable to convert
58 | * @param message the specified detail message
59 | *
60 | * @return a DeleteException
61 | */
62 | public static DeleteException fromThrowable(String message, Throwable cause) {
63 | return (cause instanceof DeleteException && Objects.equals(message, cause.getMessage()))
64 | ? (DeleteException) cause
65 | : new DeleteException(message, cause);
66 | }
67 |
68 | //====| Construction |====================================================================//
69 |
70 | protected DeleteException(Throwable cause) {
71 | super(cause);
72 | }
73 |
74 | public DeleteException(String msg) {
75 | super(msg);
76 | }
77 |
78 | protected DeleteException(String msg, Throwable cause) {
79 | super(msg, cause);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/InvalidFormulaInContextException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: InvalidFormulaInContextException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Thrown when the Cyc does not allow the specified formula to be true in the specified context.
28 | * It does not distinguish between semantic and syntactic errors.
29 | *
30 | * @author Vijay Raj
31 | * @version $Id: InvalidFormulaInContextException.java 185299 2019-01-14 16:15:35Z daves $
32 | */
33 | public class InvalidFormulaInContextException extends CreateException {
34 |
35 | //====| Factory methods |=================================================================//
36 |
37 | /**
38 | * Converts a Throwable to a InvalidFormulaInContextException. If the Throwable is a
39 | * InvalidFormulaInContextException, it will be passed through unmodified; otherwise, it will be wrapped
40 | * in a new InvalidFormulaInContextException.
41 | *
42 | * @param cause the Throwable to convert
43 | *
44 | * @return a InvalidFormulaInContextException
45 | */
46 | public static InvalidFormulaInContextException fromThrowable(Throwable cause) {
47 | return (cause instanceof InvalidFormulaInContextException)
48 | ? (InvalidFormulaInContextException) cause
49 | : new InvalidFormulaInContextException(cause);
50 | }
51 |
52 | /**
53 | * Converts a Throwable to a InvalidFormulaInContextException with the specified detail message. If the
54 | * Throwable is a InvalidFormulaInContextException and if the Throwable's message is identical to the
55 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
56 | * a new InvalidFormulaInContextException with the detail message.
57 | *
58 | * @param cause the Throwable to convert
59 | * @param message the specified detail message
60 | *
61 | * @return a InvalidFormulaInContextException
62 | */
63 | public static InvalidFormulaInContextException fromThrowable(String message, Throwable cause) {
64 | return (cause instanceof InvalidFormulaInContextException && Objects.equals(message, cause.getMessage()))
65 | ? (InvalidFormulaInContextException) cause
66 | : new InvalidFormulaInContextException(message, cause);
67 | }
68 |
69 | //====| Construction |====================================================================//
70 |
71 | protected InvalidFormulaInContextException(Throwable cause) {
72 | super(cause);
73 | }
74 |
75 | public InvalidFormulaInContextException(String msg) {
76 | super(msg);
77 | }
78 |
79 | protected InvalidFormulaInContextException(String msg, Throwable cause) {
80 | super(msg, cause);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/InvalidNameException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: InvalidNameException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Thrown when code attempts to create a KB entity with an invalid name.
28 | *
29 | * @author Nathan Winant
30 | * @version $Id: InvalidNameException.java 185299 2019-01-14 16:15:35Z daves $
31 | */
32 | // @todo specify what the requirements are for a Constant name.
33 |
34 | public class InvalidNameException extends CreateException {
35 |
36 | //====| Factory methods |=================================================================//
37 |
38 | /**
39 | * Converts a Throwable to a InvalidNameException. If the Throwable is a
40 | * InvalidNameException, it will be passed through unmodified; otherwise, it will be wrapped
41 | * in a new InvalidNameException.
42 | *
43 | * @param cause the Throwable to convert
44 | *
45 | * @return a InvalidNameException
46 | */
47 | public static InvalidNameException fromThrowable(Throwable cause) {
48 | return (cause instanceof InvalidNameException)
49 | ? (InvalidNameException) cause
50 | : new InvalidNameException(cause);
51 | }
52 |
53 | /**
54 | * Converts a Throwable to a InvalidNameException with the specified detail message. If the
55 | * Throwable is a InvalidNameException and if the Throwable's message is identical to the
56 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
57 | * a new InvalidNameException with the detail message.
58 | *
59 | * @param cause the Throwable to convert
60 | * @param message the specified detail message
61 | *
62 | * @return a InvalidNameException
63 | */
64 | public static InvalidNameException fromThrowable(String message, Throwable cause) {
65 | return (cause instanceof InvalidNameException && Objects.equals(message, cause.getMessage()))
66 | ? (InvalidNameException) cause
67 | : new InvalidNameException(message, cause);
68 | }
69 |
70 | //====| Construction |====================================================================//
71 |
72 | protected InvalidNameException(Throwable cause) {
73 | super(cause);
74 | }
75 |
76 | public InvalidNameException(String msg) {
77 | super(msg);
78 | }
79 |
80 | protected InvalidNameException(String msg, Throwable cause) {
81 | super(msg, cause);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/KbException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: KbException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Root class for exceptions thrown by the KB API.
28 | *
29 | * @author David Baxter
30 | * @version $Id: KbException.java 185299 2019-01-14 16:15:35Z daves $
31 | */
32 | public class KbException extends Exception {
33 |
34 | //====| Factory methods |=================================================================//
35 |
36 | /**
37 | * Converts a Throwable to a KbException. If the Throwable is a
38 | * KbException, it will be passed through unmodified; otherwise, it will be wrapped
39 | * in a new KbException.
40 | *
41 | * @param cause the Throwable to convert
42 | *
43 | * @return a KbException
44 | */
45 | public static KbException fromThrowable(Throwable cause) {
46 | return (cause instanceof KbException)
47 | ? (KbException) cause
48 | : new KbException(cause);
49 | }
50 |
51 | /**
52 | * Converts a Throwable to a KbException with the specified detail message. If the
53 | * Throwable is a KbException and if the Throwable's message is identical to the
54 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
55 | * a new KbException with the detail message.
56 | *
57 | * @param cause the Throwable to convert
58 | * @param message the specified detail message
59 | *
60 | * @return a KbException
61 | */
62 | public static KbException fromThrowable(String message, Throwable cause) {
63 | return (cause instanceof KbException && Objects.equals(message, cause.getMessage()))
64 | ? (KbException) cause
65 | : new KbException(message, cause);
66 | }
67 |
68 | //====| Construction |====================================================================//
69 |
70 | protected KbException(Throwable cause) {
71 | super(cause);
72 | }
73 |
74 | public KbException(String msg) {
75 | super(msg);
76 | }
77 |
78 | protected KbException(String msg, Throwable cause) {
79 | super(msg, cause);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/KbObjectNotFoundException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: KbObjectNotFoundException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Thrown when a term or a formula cannot be found from the specified
28 | * context.
29 | *
30 | * @author Vijay Raj
31 | * @version $Id: KbObjectNotFoundException.java 185299 2019-01-14 16:15:35Z daves $
32 | */
33 | /*
34 | */
35 | public class KbObjectNotFoundException extends CreateException {
36 |
37 | //====| Factory methods |=================================================================//
38 |
39 | /**
40 | * Converts a Throwable to a KbObjectNotFoundException. If the Throwable is a
41 | * KbObjectNotFoundException, it will be passed through unmodified; otherwise, it will be wrapped
42 | * in a new KbObjectNotFoundException.
43 | *
44 | * @param cause the Throwable to convert
45 | *
46 | * @return a KbObjectNotFoundException
47 | */
48 | public static KbObjectNotFoundException fromThrowable(Throwable cause) {
49 | return (cause instanceof KbObjectNotFoundException)
50 | ? (KbObjectNotFoundException) cause
51 | : new KbObjectNotFoundException(cause);
52 | }
53 |
54 | /**
55 | * Converts a Throwable to a KbObjectNotFoundException with the specified detail message. If the
56 | * Throwable is a KbObjectNotFoundException and if the Throwable's message is identical to the
57 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
58 | * a new KbObjectNotFoundException with the detail message.
59 | *
60 | * @param cause the Throwable to convert
61 | * @param message the specified detail message
62 | *
63 | * @return a KbObjectNotFoundException
64 | */
65 | public static KbObjectNotFoundException fromThrowable(String message, Throwable cause) {
66 | return (cause instanceof KbObjectNotFoundException && Objects.equals(message, cause.getMessage()))
67 | ? (KbObjectNotFoundException) cause
68 | : new KbObjectNotFoundException(message, cause);
69 | }
70 |
71 | //====| Construction |====================================================================//
72 |
73 | protected KbObjectNotFoundException(Throwable cause) {
74 | super(cause);
75 | }
76 |
77 | public KbObjectNotFoundException(String msg) {
78 | super(msg);
79 | }
80 |
81 | protected KbObjectNotFoundException(String msg, Throwable cause) {
82 | super(msg, cause);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/KbRuntimeException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.io.IOException;
4 | import java.net.UnknownHostException;
5 | import java.util.Objects;
6 |
7 | /*
8 | * #%L
9 | * File: KbRuntimeException.java
10 | * Project: Core API
11 | * %%
12 | * Copyright (C) 2015 - 2019 Cycorp, Inc
13 | * %%
14 | * Licensed under the Apache License, Version 2.0 (the "License");
15 | * you may not use this file except in compliance with the License.
16 | * You may obtain a copy of the License at
17 | *
18 | * http://www.apache.org/licenses/LICENSE-2.0
19 | *
20 | * Unless required by applicable law or agreed to in writing, software
21 | * distributed under the License is distributed on an "AS IS" BASIS,
22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | * See the License for the specific language governing permissions and
24 | * limitations under the License.
25 | * #L%
26 | */
27 | /**
28 | * Root class for runtime exceptions thrown by the KB API.
29 | *
30 | * For now, all {@link UnknownHostException}s and {@link IOException}s from
31 | * OpenCyc API will be wrapped with KbRuntimeException. This is because the
32 | * KB API user is not expected to handle such exceptions.
33 | *
34 | * @author Vijay Raj
35 | * @version $Id: KbRuntimeException.java 151668 2014-06-03 21:46:52Z jmoszko
36 | * $
37 | */
38 | public class KbRuntimeException extends RuntimeException {
39 |
40 | //====| Factory methods |=================================================================//
41 |
42 | /**
43 | * Converts a Throwable to a KbRuntimeException. If the Throwable is a
44 | * KbRuntimeException, it will be passed through unmodified; otherwise, it will be wrapped
45 | * in a new KbRuntimeException.
46 | *
47 | * @param cause the Throwable to convert
48 | *
49 | * @return a KbRuntimeException
50 | */
51 | public static KbRuntimeException fromThrowable(Throwable cause) {
52 | return (cause instanceof KbRuntimeException)
53 | ? (KbRuntimeException) cause
54 | : new KbRuntimeException(cause);
55 | }
56 |
57 | /**
58 | * Converts a Throwable to a KbRuntimeException with the specified detail message. If the
59 | * Throwable is a KbRuntimeException and if the Throwable's message is identical to the
60 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
61 | * a new KbRuntimeException with the detail message.
62 | *
63 | * @param cause the Throwable to convert
64 | * @param message the specified detail message
65 | *
66 | * @return a KbRuntimeException
67 | */
68 | public static KbRuntimeException fromThrowable(String message, Throwable cause) {
69 | return (cause instanceof KbRuntimeException && Objects.equals(message, cause.getMessage()))
70 | ? (KbRuntimeException) cause
71 | : new KbRuntimeException(message, cause);
72 | }
73 |
74 | //====| Construction |====================================================================//
75 |
76 | protected KbRuntimeException(Throwable cause) {
77 | super(cause);
78 | }
79 |
80 | public KbRuntimeException(String msg) {
81 | super(msg);
82 | }
83 |
84 | protected KbRuntimeException(String msg, Throwable cause) {
85 | super(msg, cause);
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/KbServerSideException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: KbServerSideException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Wraps all Cyc server errors, when a more specific semantic error can not be thrown.
28 | *
29 | * @author Vijay Raj
30 | * @version $Id: KbServerSideException.java 185299 2019-01-14 16:15:35Z daves $
31 | */
32 | public class KbServerSideException extends KbRuntimeException{
33 |
34 | //====| Factory methods |=================================================================//
35 |
36 | /**
37 | * Converts a Throwable to a KbServerSideException. If the Throwable is a
38 | * KbServerSideException, it will be passed through unmodified; otherwise, it will be wrapped
39 | * in a new KbServerSideException.
40 | *
41 | * @param cause the Throwable to convert
42 | *
43 | * @return a KbServerSideException
44 | */
45 | public static KbServerSideException fromThrowable(Throwable cause) {
46 | return (cause instanceof KbServerSideException)
47 | ? (KbServerSideException) cause
48 | : new KbServerSideException(cause);
49 | }
50 |
51 | /**
52 | * Converts a Throwable to a KbServerSideException with the specified detail message. If the
53 | * Throwable is a KbServerSideException and if the Throwable's message is identical to the
54 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
55 | * a new KbServerSideException with the detail message.
56 | *
57 | * @param cause the Throwable to convert
58 | * @param message the specified detail message
59 | *
60 | * @return a KbServerSideException
61 | */
62 | public static KbServerSideException fromThrowable(String message, Throwable cause) {
63 | return (cause instanceof KbServerSideException && Objects.equals(message, cause.getMessage()))
64 | ? (KbServerSideException) cause
65 | : new KbServerSideException(message, cause);
66 | }
67 |
68 | //====| Construction |====================================================================//
69 |
70 | protected KbServerSideException(Throwable cause) {
71 | super(cause);
72 | }
73 |
74 | public KbServerSideException(String msg) {
75 | super(msg);
76 | }
77 |
78 | protected KbServerSideException(String msg, Throwable cause) {
79 | super(msg, cause);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/KbTypeConflictException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: KbTypeConflictException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 | /**
26 | * Thrown when an entity exists in the KB, but is incompatible with a particular semantic object
27 | * type. The difference between this exception and {@link com.cyc.kb.exception.KbTypeException } is
28 | * that in this case, the KB entity cannot be turned into the expected type by addition of
29 | * assertions--instead, there is an existing assertion on the KB entity that specifically conflicts
30 | * with the desired type. In contrast, a KbTypeException
signals that the KB entity is
31 | * not of the desired type, but does not signal that there is a conflict between some existing
32 | * assertion and the desired type. For a simple KbTypeException
, it is possible that
33 | * simply adding more assertions will turn the KB entity into the desired type of entity.
34 | *
35 | * @author Nathan Winant
36 | * @version $Id: KbTypeConflictException.java 185299 2019-01-14 16:15:35Z daves $
37 | */
38 | public class KbTypeConflictException extends KbTypeException {
39 |
40 | //====| Factory methods |=================================================================//
41 |
42 | /**
43 | * Converts a Throwable to a KbTypeConflictException. If the Throwable is a
44 | * KbTypeConflictException, it will be passed through unmodified; otherwise, it will be wrapped
45 | * in a new KbTypeConflictException.
46 | *
47 | * @param cause the Throwable to convert
48 | *
49 | * @return a KbTypeConflictException
50 | */
51 | public static KbTypeConflictException fromThrowable(Throwable cause) {
52 | return (cause instanceof KbTypeConflictException)
53 | ? (KbTypeConflictException) cause
54 | : new KbTypeConflictException(cause);
55 | }
56 |
57 | /**
58 | * Converts a Throwable to a KbTypeConflictException with the specified detail message. If the
59 | * Throwable is a KbTypeConflictException and if the Throwable's message is identical to the
60 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
61 | * a new KbTypeConflictException with the detail message.
62 | *
63 | * @param cause the Throwable to convert
64 | * @param message the specified detail message
65 | *
66 | * @return a KbTypeConflictException
67 | */
68 | public static KbTypeConflictException fromThrowable(String message, Throwable cause) {
69 | return (cause instanceof KbTypeConflictException && Objects.equals(message, cause.getMessage()))
70 | ? (KbTypeConflictException) cause
71 | : new KbTypeConflictException(message, cause);
72 | }
73 |
74 | //====| Construction |====================================================================//
75 |
76 | protected KbTypeConflictException(Throwable cause) {
77 | super(cause);
78 | }
79 |
80 | public KbTypeConflictException(String msg) {
81 | super(msg);
82 | }
83 |
84 | protected KbTypeConflictException(String msg, Throwable cause) {
85 | super(msg, cause);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/KbTypeException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: KbTypeException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Thrown when an entity exists in the KB, but does not currently meet the
28 | * requirements of a particular semantic object type.
29 | *
30 | * @author Nathan Winant
31 | * @version $Id: KbTypeException.java 185299 2019-01-14 16:15:35Z daves $
32 | */
33 | public class KbTypeException extends KbException {
34 |
35 | //====| Factory methods |=================================================================//
36 |
37 | /**
38 | * Converts a Throwable to a KbTypeException. If the Throwable is a
39 | * KbTypeException, it will be passed through unmodified; otherwise, it will be wrapped
40 | * in a new KbTypeException.
41 | *
42 | * @param cause the Throwable to convert
43 | *
44 | * @return a KbTypeException
45 | */
46 | public static KbTypeException fromThrowable(Throwable cause) {
47 | return (cause instanceof KbTypeException)
48 | ? (KbTypeException) cause
49 | : new KbTypeException(cause);
50 | }
51 |
52 | /**
53 | * Converts a Throwable to a KbTypeException with the specified detail message. If the
54 | * Throwable is a KbTypeException and if the Throwable's message is identical to the
55 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
56 | * a new KbTypeException with the detail message.
57 | *
58 | * @param cause the Throwable to convert
59 | * @param message the specified detail message
60 | *
61 | * @return a KbTypeException
62 | */
63 | public static KbTypeException fromThrowable(String message, Throwable cause) {
64 | return (cause instanceof KbTypeException && Objects.equals(message, cause.getMessage()))
65 | ? (KbTypeException) cause
66 | : new KbTypeException(message, cause);
67 | }
68 |
69 | //====| Construction |====================================================================//
70 |
71 | protected KbTypeException(Throwable cause) {
72 | super(cause);
73 | }
74 |
75 | public KbTypeException(String msg) {
76 | super(msg);
77 | }
78 |
79 | protected KbTypeException(String msg, Throwable cause) {
80 | super(msg, cause);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/kb/exception/StaleKbObjectException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.kb.exception;
2 |
3 | /*
4 | * #%L
5 | * File: StaleKbObjectException.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import com.cyc.kb.Assertion;
24 | import com.cyc.kb.KbObject;
25 | import com.cyc.kb.KbTerm;
26 | import com.cyc.kb.spi.KbService;
27 | import java.util.Objects;
28 |
29 | /**
30 | * Thrown when a stale {@link KbObject} is passed to a method.
31 | *
25 | * Context.get("SomeMt");
26 | *
27 | * KbTerm.findOrCreate("SomeTerm");
28 | *
29 | * Sentence.get(predicate, arg1, arg2);
30 | *
31 | * Assertion.get("someassertionid");
32 | *
33 | * Query.get(sentence, context);
34 | *
35 | * Assertion
and its sub-class factories are a convenient way to
42 | * create assertions without needing to first create the KbCollection
and
43 | * KbIndividual
objects, but they do require correct syntax, and the terms must already
44 | * exist on the Cyc server.
45 | *
46 | * ProofView
instance is also a ProofViewNode
, and serves as the root of
37 | * the tree. A suggested rendering algorithm would be to display this node, and recurse on all child
38 | * nodes for whom {@link ProofViewNode#isExpandInitially()} returns true
.
39 | *
40 | * @author daves
41 | */
42 | public interface ProofView extends ProofViewNode, QueryAnswerExplanation {
43 |
44 | //====| Factory methods |=================================================================//
45 |
46 | /**
47 | * Returns a ProofView
for an answer, generating one if necessary via a call to
48 | * {@link ProofViewGenerator#generate()}.
49 | *
50 | * @param answer the answer for which to generate a ProofView.
51 | * @param spec the configuration parameters for ProofView generation.
52 | *
53 | * @return a ProofView.
54 | */
55 | public static ProofView getProofView(QueryAnswer answer, ProofViewSpecification spec) {
56 | return Cyc.getProofViewService().getExplanation(answer, spec);
57 | }
58 |
59 | //====| Methods |=========================================================================//
60 |
61 | default IteratorProofViewGenerator
instance.
37 | *
38 | * @param answer the answer for which to generate a ProofView.
39 | * @param spec the configuration parameters for ProofView generation.
40 | *
41 | * @return a ProofViewGenerator
42 | */
43 | public static ProofViewGenerator get(QueryAnswer answer, ProofViewSpecification spec) {
44 | return Cyc.getProofViewService().getExplanationGenerator(answer, spec);
45 | }
46 |
47 | //====| Methods |=========================================================================//
48 |
49 | /**
50 | * Marshal this explanation into a DOM tree.
51 | *
52 | * @param destination
53 | */
54 | void marshal(org.w3c.dom.Node destination);
55 |
56 | ProofViewMarshaller getMarshaller() throws ProofViewException;
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/ProofViewMarshaller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Cycorp, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.cyc.query;
17 |
18 | /*
19 | * #%L
20 | * File: ProofViewMarshaller.java
21 | * Project: Core API
22 | * %%
23 | * Copyright (C) 2015 - 2019 Cycorp, Inc
24 | * %%
25 | * Licensed under the Apache License, Version 2.0 (the "License");
26 | * you may not use this file except in compliance with the License.
27 | * You may obtain a copy of the License at
28 | *
29 | * http://www.apache.org/licenses/LICENSE-2.0
30 | *
31 | * Unless required by applicable law or agreed to in writing, software
32 | * distributed under the License is distributed on an "AS IS" BASIS,
33 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 | * See the License for the specific language governing permissions and
35 | * limitations under the License.
36 | * #L%
37 | */
38 |
39 | import com.cyc.query.exception.ProofViewException;
40 | import java.io.OutputStream;
41 | import java.io.Writer;
42 |
43 | /**
44 | *
45 | * @author nwinant
46 | */
47 | public interface ProofViewMarshaller {
48 |
49 | //====| Methods |=========================================================================//
50 |
51 | /**
52 | * Output the specified ProofView to the specified DOM Node.
53 | *
54 | * @param destination
55 | * @throws com.cyc.query.exception.ProofViewException
56 | */
57 | void marshal(org.w3c.dom.Node destination) throws ProofViewException;
58 |
59 | /**
60 | * Output the specified ProofView to the specified writer.
61 | *
62 | * @param destination
63 | * @throws com.cyc.query.exception.ProofViewException
64 | */
65 | void marshal(Writer destination) throws ProofViewException;
66 |
67 | /**
68 | * Output the specified ProofView to the specified stream.
69 | *
70 | * @param destination
71 | * @throws com.cyc.query.exception.ProofViewException
72 | */
73 | void marshal(OutputStream destination) throws ProofViewException;
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/query/ProofViewNode.java:
--------------------------------------------------------------------------------
1 | package com.cyc.query;
2 |
3 | /*
4 | * #%L
5 | * File: ProofViewNode.java
6 | * Project: Core API
7 | * %%
8 | * Copyright (C) 2015 - 2019 Cycorp, Inc
9 | * %%
10 | * Licensed under the Apache License, Version 2.0 (the "License");
11 | * you may not use this file except in compliance with the License.
12 | * You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing, software
17 | * distributed under the License is distributed on an "AS IS" BASIS,
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 | * See the License for the specific language governing permissions and
20 | * limitations under the License.
21 | * #L%
22 | */
23 | import com.cyc.query.graph.GraphNodeAbsolutePath;
24 | import java.util.List;
25 |
26 | /**
27 | *
28 | * @author daves
29 | */
30 | public interface ProofViewNode {
31 |
32 | public interface ProofViewNodePath extends GraphNodeAbsolutePathQueryAnswerExplanationGenerator
suitable for
41 | * generating and returning a QueryAnswerExplanation
for a given
42 | * QueryAnswerExplanationSpecification
.
43 | *
44 | * @param ProofViewGenerator
instance.
46 | *
47 | * @param answer the answer for which to generate a ProofView.
48 | * @param spec the configuration parameters for ProofView generation.
49 | *
50 | * @return a ProofViewGenerator.
51 | */
52 | @Override
53 | ProofViewGenerator getExplanationGenerator(QueryAnswer answer,
54 | QueryAnswerExplanationSpecificationProofView
for an answer, generating one if necessary via a call to
58 | * {@link ProofViewGenerator#generate()}.
59 | *
60 | * @param answer the answer for which to generate a ProofView.
61 | * @param spec the configuration parameters for ProofView generation.
62 | *
63 | * @return a ProofView.
64 | */
65 | @Override
66 | ProofView getExplanation(QueryAnswer answer, QueryAnswerExplanationSpecificationQueryAnswerExplanationGenerator
suitable for
62 | * generating and returning a QueryAnswerExplanation
for a given
63 | * QueryAnswerExplanationSpecification
.
64 | *
65 | * @param answer the answer for which to generate a QueryAnswerExplanation.
66 | * @param spec the configuration parameters for QueryAnswerExplanation generation.
67 | *
68 | * @return a QueryAnswerExplanationGenerator.
69 | */
70 | QueryAnswerExplanationGeneratorlocalhost:3600
.
52 | *
53 | * @see CycSessionConfiguration#getCycAddress()
54 | */
55 | public static final String SERVER_KEY = "cyc.session.server";
56 |
57 | /**
58 | * Returns an array of all property names.
59 | */
60 | public static final String[] ALL_KEYS = {
61 | CONFIGURATION_FILE_KEY,
62 | CONFIGURATION_LOADER_KEY,
63 | SERVER_KEY
64 | };
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/session/exception/SessionCommandException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.session.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: SessionCommandException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * SessionCommandException indicates that Session implementation code could communicate with a Cyc
28 | * server, but encountered a problem issuing a command or interpreting a result.
29 | *
30 | * @author nwinant
31 | */
32 | public class SessionCommandException extends SessionRuntimeException {
33 |
34 |
35 | //====| Factory methods |=================================================================//
36 |
37 | /**
38 | * Converts a Throwable to a SessionCommandException. If the Throwable is a
39 | * SessionCommandException, it will be passed through unmodified; otherwise, it will be wrapped
40 | * in a new SessionCommandException.
41 | *
42 | * @param cause the Throwable to convert
43 | *
44 | * @return a SessionCommandException
45 | */
46 | public static SessionCommandException fromThrowable(Throwable cause) {
47 | return (cause instanceof SessionCommandException)
48 | ? (SessionCommandException) cause
49 | : new SessionCommandException(cause);
50 | }
51 |
52 | /**
53 | * Converts a Throwable to a SessionCommandException with the specified detail message. If the
54 | * Throwable is a SessionCommandException and if the Throwable's message is identical to the
55 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
56 | * a new SessionCommandException with the detail message.
57 | *
58 | * @param cause the Throwable to convert
59 | * @param message the specified detail message
60 | *
61 | * @return a SessionCommandException
62 | */
63 | public static SessionCommandException fromThrowable(String message, Throwable cause) {
64 | return (cause instanceof SessionCommandException && Objects.equals(message, cause.getMessage()))
65 | ? (SessionCommandException) cause
66 | : new SessionCommandException(message, cause);
67 | }
68 |
69 | //====| Construction |====================================================================//
70 |
71 |
72 | /**
73 | * Construct a SessionCommandException object with no specified message.
74 | */
75 | public SessionCommandException() {
76 | super();
77 | }
78 |
79 | /**
80 | * Construct a SessionCommandException object with a specified message.
81 | * @param msg a message describing the exception.
82 | */
83 | public SessionCommandException(String msg) {
84 | super(msg);
85 | }
86 |
87 | /**
88 | * Construct a SessionCommandException object with a specified message
89 | * and throwable.
90 | * @param msg the message string
91 | * @param cause the throwable that caused this exception
92 | */
93 | protected SessionCommandException(String msg, Throwable cause) {
94 | super(msg, cause);
95 | }
96 |
97 | /**
98 | * Construct a SessionCommandException object with a specified throwable.
99 | * @param cause the throwable that caused this exception
100 | */
101 | protected SessionCommandException(Throwable cause) {
102 | super(cause);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/session/exception/SessionException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.session.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: SessionException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 | /**
26 | * SessionException is the base exception which indicates that an application library has
27 | * encountered a problem in interacting with a Cyc server. Subclasses of CycSessionException
28 | * indicate specific types of issues which the calling application might reasonably be expected to
29 | * prevent or respond to, such as misconfigured sessions.
30 | *
31 | * @see com.cyc.session.exception.SessionRuntimeException
32 | *
33 | * @author nwinant
34 | */
35 | public class SessionException extends Exception {
36 |
37 | //====| Factory methods |=================================================================//
38 |
39 | /**
40 | * Converts a Throwable to a SessionException. If the Throwable is a
41 | * SessionException, it will be passed through unmodified; otherwise, it will be wrapped
42 | * in a new SessionException.
43 | *
44 | * @param cause the Throwable to convert
45 | *
46 | * @return a SessionException
47 | */
48 | public static SessionException fromThrowable(Throwable cause) {
49 | return (cause instanceof SessionException)
50 | ? (SessionException) cause
51 | : new SessionException(cause);
52 | }
53 |
54 | /**
55 | * Converts a Throwable to a SessionException with the specified detail message. If the
56 | * Throwable is a SessionException and if the Throwable's message is identical to the
57 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
58 | * a new SessionException with the detail message.
59 | *
60 | * @param cause the Throwable to convert
61 | * @param message the specified detail message
62 | *
63 | * @return a SessionException
64 | */
65 | public static SessionException fromThrowable(String message, Throwable cause) {
66 | return (cause instanceof SessionException && Objects.equals(message, cause.getMessage()))
67 | ? (SessionException) cause
68 | : new SessionException(message, cause);
69 | }
70 |
71 | //====| Construction |====================================================================//
72 |
73 | /**
74 | * Constructs a new exception with no specified message.
75 | */
76 | public SessionException() {
77 | super();
78 | }
79 |
80 | /**
81 | * Constructs a new exception with a specified message.
82 | * @param message a message describing the exception.
83 | */
84 | public SessionException(String message) {
85 | super(message);
86 | }
87 |
88 | /**
89 | * Constructs a new exception with a specified message and throwable.
90 | * @param message the message string
91 | * @param cause the Throwable that caused this exception
92 | */
93 | protected SessionException(String message, Throwable cause) {
94 | super(message, cause);
95 | }
96 |
97 | /**
98 | * Constructs a new exception with a specified throwable.
99 | * @param cause the throwable that caused this exception
100 | */
101 | protected SessionException(Throwable cause) {
102 | super(cause);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/session/exception/SessionManagerException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.session.exception;
2 |
3 | import com.cyc.session.SessionManager;
4 | import java.util.Objects;
5 |
6 | /*
7 | * #%L
8 | * File: SessionManagerException.java
9 | * Project: Core API
10 | * %%
11 | * Copyright (C) 2015 - 2019 Cycorp, Inc
12 | * %%
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * #L%
25 | */
26 |
27 | /**
28 | * Indicates an error with an existing {@link SessionManager}.
29 | *
30 | * @author nwinant
31 | */
32 | public class SessionManagerException extends SessionException {
33 |
34 | //====| Factory methods |=================================================================//
35 |
36 | /**
37 | * Converts a Throwable to a SessionManagerException. If the Throwable is a
38 | * SessionManagerException, it will be passed through unmodified; otherwise, it will be wrapped
39 | * in a new SessionManagerException.
40 | *
41 | * @param cause the Throwable to convert
42 | *
43 | * @return a SessionManagerException
44 | */
45 | public static SessionManagerException fromThrowable(Throwable cause) {
46 | return (cause instanceof SessionManagerException)
47 | ? (SessionManagerException) cause
48 | : new SessionManagerException(cause);
49 | }
50 |
51 | /**
52 | * Converts a Throwable to a SessionManagerException with the specified detail message. If the
53 | * Throwable is a SessionManagerException and if the Throwable's message is identical to the
54 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
55 | * a new SessionManagerException with the detail message.
56 | *
57 | * @param cause the Throwable to convert
58 | * @param message the specified detail message
59 | *
60 | * @return a SessionManagerException
61 | */
62 | public static SessionManagerException fromThrowable(String message, Throwable cause) {
63 | return (cause instanceof SessionManagerException && Objects.equals(message, cause.getMessage()))
64 | ? (SessionManagerException) cause
65 | : new SessionManagerException(message, cause);
66 | }
67 |
68 | //====| Construction |====================================================================//
69 |
70 |
71 | /**
72 | * Construct a SessionManagerException object with no specified message.
73 | */
74 | public SessionManagerException() {
75 | super();
76 | }
77 |
78 | /**
79 | * Construct a SessionManagerException object with a specified message.
80 | *
81 | * @param msg a message describing the exception.
82 | */
83 | public SessionManagerException(String msg) {
84 | super(msg);
85 | }
86 |
87 | /**
88 | * Construct a SessionManagerException object with a specified message and throwable.
89 | *
90 | * @param msg the message string
91 | * @param cause the throwable that caused this exception
92 | */
93 | protected SessionManagerException(String msg, Throwable cause) {
94 | super(msg, cause);
95 | }
96 |
97 | /**
98 | * Construct a SessionManagerException object with a specified throwable.
99 | *
100 | * @param cause the throwable that caused this exception
101 | */
102 | protected SessionManagerException(Throwable cause) {
103 | super(cause);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/session/exception/UnsupportedCycOperationException.java:
--------------------------------------------------------------------------------
1 | package com.cyc.session.exception;
2 |
3 | import java.util.Objects;
4 |
5 | /*
6 | * #%L
7 | * File: UnsupportedCycOperationException.java
8 | * Project: Core API
9 | * %%
10 | * Copyright (C) 2015 - 2019 Cycorp, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * Thrown to indicate that a Cyc server does not support a particular operation.
28 | *
29 | * @author nwinant
30 | */
31 | public class UnsupportedCycOperationException extends SessionRuntimeException {
32 |
33 | //====| Factory methods |=================================================================//
34 |
35 | /**
36 | * Converts a Throwable to a UnsupportedCycOperationException. If the Throwable is a
37 | * UnsupportedCycOperationException, it will be passed through unmodified; otherwise, it will be wrapped
38 | * in a new UnsupportedCycOperationException.
39 | *
40 | * @param cause the Throwable to convert
41 | *
42 | * @return a UnsupportedCycOperationException
43 | */
44 | public static UnsupportedCycOperationException fromThrowable(Throwable cause) {
45 | return (cause instanceof UnsupportedCycOperationException)
46 | ? (UnsupportedCycOperationException) cause
47 | : new UnsupportedCycOperationException(cause);
48 | }
49 |
50 | /**
51 | * Converts a Throwable to a UnsupportedCycOperationException with the specified detail message. If the
52 | * Throwable is a UnsupportedCycOperationException and if the Throwable's message is identical to the
53 | * one supplied, the Throwable will be passed through unmodified; otherwise, it will be wrapped in
54 | * a new UnsupportedCycOperationException with the detail message.
55 | *
56 | * @param cause the Throwable to convert
57 | * @param message the specified detail message
58 | *
59 | * @return a UnsupportedCycOperationException
60 | */
61 | public static UnsupportedCycOperationException fromThrowable(String message, Throwable cause) {
62 | return (cause instanceof UnsupportedCycOperationException && Objects.equals(message, cause.getMessage()))
63 | ? (UnsupportedCycOperationException) cause
64 | : new UnsupportedCycOperationException(message, cause);
65 | }
66 |
67 | //====| Construction |====================================================================//
68 |
69 | /**
70 | * Constructs a new exception with no specified message.
71 | */
72 | public UnsupportedCycOperationException() {
73 | super();
74 | }
75 |
76 | /**
77 | * Constructs a new exception with a specified message.
78 | * @param message a message describing the exception.
79 | */
80 | public UnsupportedCycOperationException(String message) {
81 | super(message);
82 | }
83 |
84 | /**
85 | * Constructs a new exception with a specified message and throwable.
86 | * @param message the message string
87 | * @param cause the throwable that caused this exception
88 | */
89 | protected UnsupportedCycOperationException(String message, Throwable cause) {
90 | super(message, cause);
91 | }
92 |
93 | /**
94 | * Constructs a new exception with a specified throwable.
95 | * @param cause the throwable that caused this exception
96 | */
97 | protected UnsupportedCycOperationException(Throwable cause) {
98 | super(cause);
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/session/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Session API exception hierarchy.
3 | */
4 | package com.cyc.session.exception;
5 |
6 | /*
7 | * #%L
8 | * File: package-info.java
9 | * Project: Core API
10 | * %%
11 | * Copyright (C) 2015 - 2019 Cycorp, Inc
12 | * %%
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * #L%
25 | */
26 |
--------------------------------------------------------------------------------
/core-api/src/main/java/com/cyc/session/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Interfaces for configuring and managing connections to a Cyc server.
3 | *