Class MiniBundleParser


  • public class MiniBundleParser
    extends Object

    Parse and validate mini-bundles for SAS. Does an ugly double load so we can produce human readable error messages for the common bundle syntax errors. SnakeYAML doesn’t make it easy to return your own error messages for things like misnamed or mistyped fields. A typical exception from SnakeYAML is

    Can't construct a java object for tag:yaml.org,2002:com.opencloud.rhino.facilities.sas.bundle.MiniBundle; exception=Cannot create property=avents for JavaBean=com.opencloud.rhino.facilities.sas.bundle.MiniBundle@0; Unable to find property 'avents' on class: com.opencloud.rhino.facilities.sas.bundle.MiniBundle
    in 'reader', line 2, column 1:
       avents:
       ^

    Stripping the layers of wrapping gives:

    Unable to find property 'avents' on class: com.opencloud.rhino.facilities.sas.bundle.MiniBundle.

    This loses the position of the error. What we want is to report errors with the position and a clear explanation. We can give the explanation by performing semantic validation on a Map representation of the bundle and preserve position data for unexpected cases by wrapping the initial cause of the ConstructorException. This class is not thread safe.