1 /* Copyright 2002-2025 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 /** ACM constituent. */ 57 acm((token, parser) -> parser.manageAcmConstituent()), 58 59 /** CDM constituent. */ 60 cdm((token, parser) -> parser.manageCdmConstituent()); 61 62 /** Processing method. */ 63 private final transient TokenProcessor processor; 64 65 /** Simple constructor. 66 * @param processor processing method 67 */ 68 NdmStructureKey(final TokenProcessor processor) { 69 this.processor = processor; 70 } 71 72 /** Process one token. 73 * @param token token to process 74 * @param parser OPM file parser 75 * @return true of token was accepted 76 */ 77 public boolean process(final ParseToken token, final NdmParser parser) { 78 return processor.process(token, parser); 79 } 80 81 /** Interface for processing one token. */ 82 interface TokenProcessor { 83 /** Process one token. 84 * @param token token to process 85 * @param parser NDM file parser 86 * @return true of token was accepted 87 */ 88 boolean process(ParseToken token, NdmParser parser); 89 } 90 91 }