1 /* Copyright 2002-2021 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.files.ccsds.ndm;
18
19 import org.orekit.files.ccsds.utils.lexical.ParseToken;
20 import org.orekit.files.ccsds.utils.lexical.TokenType;
21
22 /** Keywords for NDM structure in XML files.
23 * @author Luc Maisonobe
24 * @since 11.0
25 */
26 enum NdmStructureKey {
27
28 /** Comment entry. */
29 COMMENT((token, parser) ->
30 token.getType() == TokenType.ENTRY ? parser.addComment(token.getContentAsNormalizedString()) : true),
31
32 /** Root element. */
33 ndm((token, parser) -> true),
34
35 /** TDM constituent. */
36 tdm((token, parser) -> parser.manageTdmConstituent()),
37
38 /** OPM constituent. */
39 opm((token, parser) -> parser.manageOpmConstituent()),
40
41 /** OMM constituent. */
42 omm((token, parser) -> parser.manageOmmConstituent()),
43
44 /** OEM constituent. */
45 oem((token, parser) -> parser.manageOemConstituent()),
46
47 /** OCM constituent. */
48 ocm((token, parser) -> parser.manageOcmConstituent()),
49
50 /** APM constituent. */
51 apm((token, parser) -> parser.manageApmConstituent()),
52
53 /** AEM constituent. */
54 aem((token, parser) -> parser.manageAemConstituent());
55
56 /** Processing method. */
57 private final TokenProcessor processor;
58
59 /** Simple constructor.
60 * @param processor processing method
61 */
62 NdmStructureKey(final TokenProcessor processor) {
63 this.processor = processor;
64 }
65
66 /** Process one token.
67 * @param token token to process
68 * @param parser OPM file parser
69 * @return true of token was accepted
70 */
71 public boolean process(final ParseToken token, final NdmParser parser) {
72 return processor.process(token, parser);
73 }
74
75 /** Interface for processing one token. */
76 interface TokenProcessor {
77 /** Process one token.
78 * @param token token to process
79 * @param parser NDM file parser
80 * @return true of token was accepted
81 */
82 boolean process(ParseToken token, NdmParser parser);
83 }
84
85 }