Examples of MappingStartEvent


Examples of com.esotericsoftware.yamlbeans.parser.MappingStartEvent

      emitter.emit(Event.SEQUENCE_END);
      return;
    }

    if (object instanceof Map) {
      emitter.emit(new MappingStartEvent(anchor, tag, !showTag, false));
      for (Object item : ((Map)object).entrySet()) {
        Entry entry = (Entry)item;
        writeValue(entry.getKey(), null, null, null);
        if (isRoot && !config.writeConfig.writeRootElementTags) elementType = entry.getValue().getClass();
        writeValue(entry.getValue(), elementType, null, null);
      }
      emitter.emit(Event.MAPPING_END);
      return;
    }

    if (fieldClass.isArray()) {
      elementType = fieldClass.getComponentType();
      emitter.emit(new SequenceStartEvent(anchor, null, true, false));
      for (int i = 0, n = Array.getLength(object); i < n; i++)
        writeValue(Array.get(object, i), elementType, null, null);
      emitter.emit(Event.SEQUENCE_END);
      return;
    }

    // Value must be a bean.

    Object prototype = null;
    if (!config.writeConfig.writeDefaultValues && valueClass != Class.class) {
      prototype = defaultValuePrototypes.get(valueClass);
      if (prototype == null && Beans.getDeferredConstruction(valueClass, config) == null) {
        try {
          prototype = Beans.createObject(valueClass, config.privateConstructors);
        } catch (InvocationTargetException ex) {
          throw new YamlException("Error creating object prototype to determine default values.", ex);
        }
        defaultValuePrototypes.put(valueClass, prototype);
      }
    }

    Set<Property> properties;
    try {
      properties = Beans.getProperties(valueClass, config.beanProperties, config.privateFields, config);
    } catch (IntrospectionException ex) {
      throw new YamlException("Error inspecting class: " + valueClass.getName(), ex);
    }
    emitter.emit(new MappingStartEvent(anchor, tag, !showTag, false));
    for (Property property : properties) {
      try {
        Object propertyValue = property.get(object);
        if (prototype != null) {
          // Don't output properties that have the default value for the prototype.
View Full Code Here

Examples of com.esotericsoftware.yamlbeans.parser.MappingStartEvent

      emitter.emit(Event.SEQUENCE_END);
      return;
    }

    if (object instanceof Map) {
      emitter.emit(new MappingStartEvent(anchor, tag, !showTag, false));
      for (Object item : ((Map)object).entrySet()) {
        Entry entry = (Entry)item;
        writeValue(entry.getKey(), null, null, null);
        if (isRoot && !config.writeConfig.writeRootElementTags) elementType = entry.getValue().getClass();
        writeValue(entry.getValue(), elementType, null, null);
      }
      emitter.emit(Event.MAPPING_END);
      return;
    }

    if (fieldClass.isArray()) {
      elementType = fieldClass.getComponentType();
      emitter.emit(new SequenceStartEvent(anchor, null, true, false));
      for (int i = 0, n = Array.getLength(object); i < n; i++)
        writeValue(Array.get(object, i), elementType, null, null);
      emitter.emit(Event.SEQUENCE_END);
      return;
    }

    // Value must be a bean.

    Object prototype = null;
    if (!config.writeConfig.writeDefaultValues && valueClass != Class.class) {
      prototype = defaultValuePrototypes.get(valueClass);
      if (prototype == null && Beans.getDeferredConstruction(valueClass, config) == null) {
        try {
          prototype = Beans.createObject(valueClass, config.privateConstructors);
        } catch (InvocationTargetException ex) {
          throw new YamlException("Error creating object prototype to determine default values.", ex);
        }
        defaultValuePrototypes.put(valueClass, prototype);
      }
    }

    Set<Property> properties;
    try {
      properties = Beans.getProperties(valueClass, config.beanProperties, config.privateFields, config);
    } catch (IntrospectionException ex) {
      throw new YamlException("Error inspecting class: " + valueClass.getName(), ex);
    }
    emitter.emit(new MappingStartEvent(anchor, tag, !showTag, false));
    for (Property property : properties) {
      try {
        Object propertyValue = property.get(object);
        if (prototype != null) {
          // Don't output properties that have the default value for the prototype.
View Full Code Here

Examples of org.yaml.snakeyaml.events.MappingStartEvent

        IRubyObject anchor = args[0];
        IRubyObject tag = args[1];
        IRubyObject implicit = args[2];
        IRubyObject style = args[3];

        MappingStartEvent event = new MappingStartEvent(
                anchor.isNil() ? null : anchor.asJavaString(),
                tag.isNil() ? null : tag.asJavaString(),
                implicit.isTrue(),
                NULL_MARK,
                NULL_MARK,
View Full Code Here

Examples of org.yaml.snakeyaml.events.MappingStartEvent

                    invoke(
                            context,
                            handler,
                            "end_sequence");
                } else if (event.is(ID.MappingStart)) {
                    MappingStartEvent mse = (MappingStartEvent)event;
                    IRubyObject anchor = mse.getAnchor() == null ?
                        runtime.getNil() :
                        RubyString.newString(runtime, mse.getAnchor());
                    IRubyObject tag = mse.getTag() == null ?
                        runtime.getNil() :
                        RubyString.newString(runtime, mse.getTag());
                    IRubyObject implicit = runtime.newBoolean(mse.getImplicit());
                    IRubyObject style = runtime.newFixnum(mse.getFlowStyle() ? 1 : 0);

                    invoke(
                            context,
                            handler,
                            "start_mapping",
View Full Code Here

Examples of org.yaml.snakeyaml.events.MappingStartEvent

        IRubyObject implicit = args[2];
        IRubyObject style = args[3];

        final int MAPPING_BLOCK = 1; // see psych/nodes/mapping.rb

        MappingStartEvent event = new MappingStartEvent(
                anchor.isNil() ? null : anchor.asJavaString(),
                tag.isNil() ? null : tag.asJavaString(),
                implicit.isTrue(),
                NULL_MARK,
                NULL_MARK,
View Full Code Here

Examples of org.yaml.snakeyaml.events.MappingStartEvent

                        .getValue(), null, null, null));
            } else if (scanner.checkToken(Token.ID.FlowSequenceStart)) {
                events.add(new SequenceStartEvent(anchor, tag, false, null, null, null));
                parseSequence();
            } else if (scanner.checkToken(Token.ID.FlowMappingStart)) {
                events.add(new MappingStartEvent(anchor, tag, false, null, null, null));
                parseMapping();
            } else {
                throw new CanonicalException("SCALAR, '[', or '{' is expected, got "
                        + scanner.tokens.get(0));
            }
View Full Code Here

Examples of org.yaml.snakeyaml.events.MappingStartEvent

                String tag = (String) mapping.get("tag");
                Boolean implicit = (Boolean) mapping.get("implicit");
                if (implicit == null) {
                    implicit = true;
                }
                value = new MappingStartEvent((String) mapping.get("anchor"), tag, implicit, null,
                        null, false);
            } else if (className.equals("DocumentEndEvent")) {
                value = new DocumentEndEvent(null, null, false);
            } else if (className.equals("DocumentStartEvent")) {
                Map<String, String> tags = (Map<String, String>) mapping.get("tags");
View Full Code Here

Examples of org.yaml.snakeyaml.events.MappingStartEvent

        Parser parser = new ParserImpl(reader);
        Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
        LinkedList<Event> etalonEvents = new LinkedList<Event>();
        etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
        etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
        etalonEvents.add(new MappingStartEvent(null, null, true, dummyMark, dummyMark,
                Boolean.FALSE));
        etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "string",
                dummyMark, dummyMark, (char) 0));
        etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "abcd",
                dummyMark, dummyMark, (char) 0));
View Full Code Here

Examples of org.yaml.snakeyaml.events.MappingStartEvent

        Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
        LinkedList<Event> etalonEvents = new LinkedList<Event>();
        etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
        etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
        etalonEvents
                .add(new MappingStartEvent(null, null, true, dummyMark, dummyMark, Boolean.TRUE));
        etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "american",
                dummyMark, dummyMark, (char) 0));
        etalonEvents.add(new SequenceStartEvent(null, null, true, dummyMark, dummyMark,
                Boolean.FALSE));
        etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false),
View Full Code Here

Examples of org.yaml.snakeyaml.events.MappingStartEvent

                                SequenceStartEvent seqStart = (SequenceStartEvent) event;
                                event = new SequenceStartEvent(seqStart.getAnchor(),
                                        seqStart.getTag(), seqStart.getImplicit(),
                                        seqStart.getStartMark(), seqStart.getEndMark(), flowStyle);
                            } else if (event instanceof MappingStartEvent) {
                                MappingStartEvent mapStart = (MappingStartEvent) event;
                                event = new MappingStartEvent(mapStart.getAnchor(),
                                        mapStart.getTag(), mapStart.getImplicit(),
                                        mapStart.getStartMark(), mapStart.getEndMark(), flowStyle);
                            }
                            styledEvents.add(event);
                        }
                        // emit
                        String data = emit(styledEvents);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.