Example usage for com.google.gwt.dev.cfg DynamicPropertyOracle getPrescribedPropertyValuesByName

List of usage examples for com.google.gwt.dev.cfg DynamicPropertyOracle getPrescribedPropertyValuesByName

Introduction

In this page you can find the example usage for com.google.gwt.dev.cfg DynamicPropertyOracle getPrescribedPropertyValuesByName.

Prototype

public Map<String, String> getPrescribedPropertyValuesByName() 

Source Link

Document

Returns the mapping from property names to its currently prescribed value.

Usage

From source file:xapi.dev.util.GenDebug.java

License:Open Source License

/**
 * In case you're too lazy to step through the debugger to find all set
 * properties, just make a call here to print out all known properties at gwt
 * compile time.//from w w  w  .  ja v  a  2  s. co  m
 *
 * @param oracle
 *          - The property oracle to inspect and print out
 */
public static void dumpProperties(final PropertyOracle oracle) {
    if (oracle instanceof SubsetFilteringPropertyOracle) {
        try {
            Field field = SubsetFilteringPropertyOracle.class.getDeclaredField("wrappedPropertyOracle");
            field.setAccessible(true);
            PropertyOracle subOracle = (PropertyOracle) field.get(oracle);
            dumpProperties(subOracle);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return;
    }
    if (oracle instanceof ModuleSpacePropertyOracle) {
        ModuleSpacePropertyOracle mod = (ModuleSpacePropertyOracle) oracle;
        Properties props;
        try {
            Field field = mod.getClass().getDeclaredField("props");
            field.setAccessible(true);
            props = (Properties) field.get(mod);
            for (BindingProperty binding : props.getBindingProperties()) {
                System.out.println(binding.getName() + " : " + binding.getConstrainedValue());
            }
            System.out.println();
            for (ConfigurationProperty prop : props.getConfigurationProperties()) {
                System.out.print(prop.getName() + " : ");
                System.out.println((prop.isMultiValued() || prop.allowsMultipleValues() ? prop.getValues()
                        : prop.getValue()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (oracle instanceof DynamicPropertyOracle) {
        DynamicPropertyOracle stat = (DynamicPropertyOracle) oracle;
        System.out.println("Prescribed props: " + Arrays.asList(stat.getPrescribedPropertyValuesByName()));
        try {
            Properties configProps;
            Field field = stat.getClass().getDeclaredField("properties");
            field.setAccessible(true);
            configProps = (Properties) field.get(stat);
            System.out.println("Properties: ");
            for (ConfigurationProperty prop : configProps.getConfigurationProperties()) {
                System.out.print(prop.getName() + " : ");
                System.out.println((prop.isMultiValued() || prop.allowsMultipleValues() ? prop.getValues()
                        : prop.getValue()));
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
    } else {
        System.out.println("Unhandled properties type: " + oracle.getClass() + ":\n" + oracle);
    }
}