コード例 #1
0
 @Override
 public void endElement(String uri, String localName, String qName) throws SAXException {
   addElementErrors();
   FxNode node = nodeStack.pop();
   i(node).endsAt(contentLocator.getEndOffset()).endContent(contentLocator.getElementOffset());
   if (node instanceof PropertySetter) {
     PropertySetter s = (PropertySetter) node;
     if (s.isImplicit()) {
       // actually the outer element ends
       node = nodeStack.pop();
       // copy the offset information
       i(node).endsAt(contentLocator.getEndOffset()).endContent(contentLocator.getElementOffset());
     }
   }
   String tn = node.getSourceName();
   if (!tn.equals(localName)) {
     throw new IllegalStateException();
   }
   // special hack for parent nodes, which are implicit property setters:
   FxNode parentNode = nodeStack.peek();
   if (parentNode instanceof PropertySetter) {
     PropertySetter ps = (PropertySetter) parentNode;
     if (ps.isImplicit() && ps.getContent() == null) {
       i(ps).endsAt(contentLocator.getEndOffset()).endContent(contentLocator.getEndOffset());
     }
   }
   if (!nodeStack.isEmpty() && nodeStack.peek().getKind() == Kind.Instance) {
     current = (FxInstance) nodeStack.peek();
   } else {
     current = null;
   }
 }
コード例 #2
0
 @NbBundle.Messages({
   "ERR_mixedContentNotAllowed=Mixed content is not allowed in property elements"
 })
 private FxNode handlePropertyContent(CharSequence seq) {
   FxNode node = nodeStack.peek();
   if (!(node instanceof PropertySetter)) {
     addError("unexpected-characters", ERR_unexpectedCharacters());
     return null;
   }
   // if the property has already received some bean instances, report
   // invalid content
   PropertySetter ps = (PropertySetter) node;
   if (ps.getValues() != null) {
     addError("mixed-content-not-allowed", ERR_mixedContentNotAllowed());
   }
   accessor.addContent((PropertySetter) node, seq);
   return node;
 }
コード例 #3
0
  private FxNode handleInstanceContent(CharSequence seq) {
    // find among properties as setter, which is marked as implicit. If there's none, create one.
    PropertySetter defaultSetter = null;

    for (PropertyValue p : current.getProperties()) {
      if (p instanceof PropertySetter) {
        PropertySetter ps = (PropertySetter) p;
        if (ps.isImplicit()) {
          defaultSetter = ps;
        }
      }
    }

    if (defaultSetter == null) {
      defaultSetter = accessor.createProperty(null, true);
      i(defaultSetter).startAt(contentLocator.getElementOffset());
      attachProperty(defaultSetter);
      attachChildNode(defaultSetter);
    }
    accessor.addContent(defaultSetter, seq);
    return defaultSetter;
  }