Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ mvn install -DskipTests

# Generate binding classes using bootstrap POM (choose the appropriate module)
# Each bootstrap POM generates classes directly into src/main/java
mvn -f metaschema-testing/pom-bootstrap.xml generate-sources
mvn -f databind/pom-bootstrap-config.xml generate-sources
mvn -f databind/pom-bootstrap-model.xml generate-sources
mvn -f metaschema-testing/pom-bootstrap.xml process-sources
mvn -f databind/pom-bootstrap-config.xml process-sources
mvn -f databind/pom-bootstrap-model.xml process-sources
```

See the README.md files in each module for detailed instructions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
public class CommandExecutionException
extends Exception {
/**
* The exit code indicating the type of error that occurred.
*/
private final ExitCode exitCode;

/**
Expand Down
35 changes: 35 additions & 0 deletions cli-processor/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SPDX-FileCopyrightText: none
* SPDX-License-Identifier: CC0-1.0
*/

import gov.nist.secauto.metaschema.cli.processor.command.ICommand;

/**
* Provides a command-line interface processing framework for Metaschema tools.
*
* @uses ICommand to discover CLI commands via service loader
*/
module gov.nist.secauto.metaschema.cli.processor {
// requirements
requires java.base;

requires transitive gov.nist.secauto.metaschema.core;

requires static org.eclipse.jdt.annotation;
requires static com.github.spotbugs.annotations;

requires org.apache.commons.cli;
requires org.jansi.core;
requires nl.talsmasoftware.lazy4j;
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
requires org.apache.logging.log4j.jul;

exports gov.nist.secauto.metaschema.cli.processor;
exports gov.nist.secauto.metaschema.cli.processor.command;
exports gov.nist.secauto.metaschema.cli.processor.command.impl;
exports gov.nist.secauto.metaschema.cli.processor.completion;

uses ICommand;
}
5 changes: 3 additions & 2 deletions core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* implementing
* {@link gov.nist.secauto.metaschema.core.metapath.function.IFunction}
*/
@SuppressWarnings("requires-transitive-automatic")
module gov.nist.secauto.metaschema.core {
// requirements
requires java.base;
Expand All @@ -42,8 +43,8 @@
requires transitive org.json;
requires org.jsoup;

// dependencies without a module descriptor
requires transitive everit.json.schema; // needed for validation details
// dependencies without a module descriptor (automatic modules)
requires transitive everit.json.schema;
requires transitive flexmark;
requires flexmark.ext.escaped.character;
requires flexmark.ext.gfm.strikethrough;
Expand Down
2 changes: 1 addition & 1 deletion databind-metaschema/modules
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,23 @@ public String getLabel() {

@NonNull
static final String SARIF_NS = "https://docs.oasis-open.org/sarif/sarif/v2.1.0";
/**
* The property key for specifying a URL that provides help information for a
* constraint.
*/
@NonNull
public static final IAttributable.Key SARIF_HELP_URL_KEY
= IAttributable.key("help-url", SARIF_NS);
/**
* The property key for specifying plain text help content for a constraint.
*/
@NonNull
public static final IAttributable.Key SARIF_HELP_TEXT_KEY
= IAttributable.key("help-text", SARIF_NS);
/**
* The property key for specifying markdown-formatted help content for a
* constraint.
*/
@NonNull
public static final IAttributable.Key SARIF_HELP_MARKDOWN_KEY
= IAttributable.key("help-markdown", SARIF_NS);
Expand Down
27 changes: 27 additions & 0 deletions databind-metaschema/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: none
* SPDX-License-Identifier: CC0-1.0
*/

/**
* Provides Metaschema module bindings and validation handlers including SARIF
* output support.
*/
module gov.nist.secauto.metaschema.databind.modules {
// requirements
requires java.base;

requires transitive gov.nist.secauto.metaschema.core;
requires transitive gov.nist.secauto.metaschema.databind;
requires transitive gov.nist.secauto.metaschema.schemagen;

requires static org.eclipse.jdt.annotation;
requires static com.github.spotbugs.annotations;

requires json.schema;

exports gov.nist.secauto.metaschema.modules.sarif;

// open generated binding classes for reflection
opens org.schemastore.json.sarif.x210;
}
6 changes: 3 additions & 3 deletions databind/pom-bootstrap-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This POM is used to regenerate the metaschema-bindings binding classes.
It is NOT part of the normal build due to circular dependencies.

Usage: mvn -f databind/pom-bootstrap-config.xml generate-sources
Usage: mvn -f databind/pom-bootstrap-config.xml process-sources

This will:
1. Delete existing generated classes in the config/binding package
Expand Down Expand Up @@ -93,7 +93,7 @@
<executions>
<execution>
<id>add-license-headers</id>
<phase>generate-sources</phase>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
Expand All @@ -116,7 +116,7 @@
<executions>
<execution>
<id>format-generated-sources</id>
<phase>generate-sources</phase>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
Expand Down
6 changes: 3 additions & 3 deletions databind/pom-bootstrap-model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This POM is used to regenerate the Metaschema model binding classes.
It is NOT part of the normal build due to circular dependencies.

Usage: mvn -f databind/pom-bootstrap-model.xml generate-sources
Usage: mvn -f databind/pom-bootstrap-model.xml process-sources

This will:
1. Delete existing generated classes in the model/metaschema/binding package
Expand Down Expand Up @@ -98,7 +98,7 @@
<executions>
<execution>
<id>add-license-headers</id>
<phase>generate-sources</phase>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
Expand All @@ -121,7 +121,7 @@
<executions>
<execution>
<id>format-generated-sources</id>
<phase>generate-sources</phase>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public <CLASS extends IBoundObject> CLASS deepCopy(@NonNull CLASS other, IBoundO
*/
@Override
@SuppressWarnings({
"deprecation",
"PMD.EmptyFinalizer",
"checkstyle:NoFinalizer" })
protected final void finalize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ default IConstraintValidator newValidator(
* the validation configuration
* @return the validation result
* @throws ConstraintValidationException
* if a constraint violation prevents validation from completing
* @throws IllegalArgumentException
* if the node item is not valid for validation
*/
default IValidationResult validate(
@NonNull IDocumentNodeItem nodeItem,
Expand All @@ -541,7 +543,9 @@ default IValidationResult validate(
* the validation configuration
* @return the validation result
* @throws ConstraintValidationException
* if a constraint violation prevents validation from completing
* @throws IllegalArgumentException
* if the node item is not valid for validation
*/
default IValidationResult validate(
@NonNull IDefinitionNodeItem<?, ?> nodeItem,
Expand Down Expand Up @@ -577,6 +581,7 @@ default IValidationResult validate(
* @throws IOException
* if an error occurred while reading the target
* @throws ConstraintValidationException
* if a constraint violation prevents validation from completing
*/
default IValidationResult validate(
@NonNull URI target,
Expand Down Expand Up @@ -605,6 +610,7 @@ default IValidationResult validate(
* @throws IOException
* if an error occurred while parsing the target
* @throws ConstraintValidationException
* if a constraint violation prevents validation from completing
*/
default IValidationResult validateWithConstraints(
@NonNull URI target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Represents a generated Java class for a Metaschema definition.
*/
public interface IGeneratedDefinitionClass extends IGeneratedClass {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;

/**
* Default implementation of {@link IBindingConfiguration} that provides binding
* configuration for Java class generation from Metaschema modules.
* <p>
* This implementation supports loading configuration from XML files and
* provides namespace-to-package mappings and definition-specific binding
* configurations.
*/
public class DefaultBindingConfiguration implements IBindingConfiguration {
private static final Logger LOGGER = LogManager.getLogger(DefaultBindingConfiguration.class);

Expand Down Expand Up @@ -659,6 +667,12 @@ private static IMutableDefinitionBindingConfiguration processDefinitionBindingCo
return config;
}

/**
* Holds binding configurations for a specific Metaschema module.
* <p>
* This class maintains mappings from definition names to their binding
* configurations for both assembly and field definitions.
*/
public static final class MetaschemaBindingConfiguration {
private final Map<String, IDefinitionBindingConfiguration> assemblyBindingConfigs = new ConcurrentHashMap<>();
private final Map<String, IDefinitionBindingConfiguration> fieldBindingConfigs = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;

/**
* Default implementation of {@link IMutableDefinitionBindingConfiguration} that
* provides mutable binding configuration for a specific Metaschema definition.
*/
public class DefaultDefinitionBindingConfiguration implements IMutableDefinitionBindingConfiguration {
@Nullable
private String className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;

/**
* Provides configuration for Java class binding generation from Metaschema
* modules.
* <p>
* This interface defines how Metaschema module elements are mapped to Java
* classes, including package names, class names, base classes, and
* superinterfaces.
*/
public interface IBindingConfiguration {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;

/**
* Provides binding configuration for a specific Metaschema definition.
* <p>
* This interface defines how an individual field or assembly definition is
* mapped to a generated Java class, including the class name, base class, and
* interfaces to implement.
*/
public interface IDefinitionBindingConfiguration {
/**
* Get the class name to use for the generated class associated with this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public IGeneratedClass generatePackageInfoClass(
writer.format(" * version %s%n", module.getVersion());
MarkupMultiline remarks = module.getRemarks();
if (remarks != null) {
writer.format(" * <p>%n");
// Remarks already include proper HTML formatting
writer.format(" * %s%n", remarks.toHtml());
}
}
Expand Down Expand Up @@ -691,9 +691,19 @@ protected Set<IModelDefinition> buildClass(
protected Set<IModelDefinition> buildClass(
@NonNull IModelDefinitionTypeInfo typeInfo,
@NonNull TypeSpec.Builder builder) {
MarkupLine description = typeInfo.getDefinition().getDescription();
IModelDefinition definition = typeInfo.getDefinition();
MarkupLine description = definition.getDescription();
if (description != null) {
builder.addJavadoc(description.toHtml());
} else {
// Fallback to formal-name or definition name when description is missing
String formalName = definition.getEffectiveFormalName();
if (formalName != null) {
builder.addJavadoc("$L.", formalName);
} else {
// Last resort: use the definition name
builder.addJavadoc("A binding class for the {@code $L} definition.", definition.getName());
}
}

Set<IModelDefinition> additionalChildClasses = new LinkedHashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;

Expand Down Expand Up @@ -72,4 +73,19 @@ protected Set<IModelDefinition> buildField(
fieldBuilder.addAnnotation(fieldValue.build());
return retval;
}

@Override
public void buildFieldJavadoc(@NonNull FieldSpec.Builder builder) {
builder.addJavadoc("The field value.");
}

@Override
public void buildGetterJavadoc(@NonNull MethodSpec.Builder builder) {
builder.addJavadoc("Get the field value.\n\n@return the value");
}

@Override
public void buildSetterJavadoc(@NonNull MethodSpec.Builder builder, @NonNull String paramName) {
builder.addJavadoc("Set the field value.\n\n@param $L\n the value to set", paramName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,9 @@ public static class ItemType implements IBoundObject {
typeAdapter = BooleanAdapter.class)
private Boolean _useWildcard;

/**
* The field value.
*/
@BoundFieldValue(
valueKeyName = "STRVALUE",
typeAdapter = TokenAdapter.class)
Expand Down Expand Up @@ -1540,11 +1543,22 @@ public void setUseWildcard(@Nullable Boolean value) {
_useWildcard = value;
}

/**
* Get the field value.
*
* @return the value
*/
@Nullable
public String getValue() {
return _value;
}

/**
* Set the field value.
*
* @param value
* the value to set
*/
public void setValue(@Nullable String value) {
_value = value;
}
Expand Down
Loading