gpt4 book ai didi

com.google.gwt.uibinder.rebind.XMLElement.getAttribute()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 09:01:05 25 4
gpt4 key购买 nike

本文整理了Java中com.google.gwt.uibinder.rebind.XMLElement.getAttribute()方法的一些代码示例,展示了XMLElement.getAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLElement.getAttribute()方法的具体详情如下:
包路径:com.google.gwt.uibinder.rebind.XMLElement
类名称:XMLElement
方法名:getAttribute

XMLElement.getAttribute介绍

[英]Get the attribute at the given index. If you are consuming attributes, remember to traverse them in reverse.
[中]获取给定索引处的属性。如果您正在使用属性,请记住反向遍历它们。

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
  * An element will require a placeholder if the user has called it out with a
  * ui:ph attribute, or if it will require run time swizzling (e.g. has a
  * ui:field). These latter we can identify easily because they'll have an
  * attribute that holds a tokenator token that was vended by
  * {@link UiBinderWriter}, typically in id.
  *
  * @return true if it has an ui:ph attribute, or has a token in any attribute
  */
 private boolean isDomPlaceholder(XMLElement elem) {
  MessagesWriter mw = uiWriter.getMessages();
  if (mw.hasMessageAttribute("ph", elem)) {
   return true;
  }
  for (int i = elem.getAttributeCount() - 1; i >= 0; i--) {
   if (elem.getAttribute(i).hasToken()) {
    return true;
   }
  }
  return false;
 }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

public String interpretElement(XMLElement elem)
  throws UnableToCompleteException {
 // Must be in the format: <ui:string from="{myMsg.message}" />
 if (writer.isBinderElement(elem) && getLocalName().equals(elem.getLocalName())) {
  if (!elem.hasAttribute("from")) {
   logger.die(elem, "Attribute 'from' not found.");
  }
  if (!elem.getAttribute("from").hasComputedValue()) {
   logger.die(elem, "Attribute 'from' does not have a computed value");
  }
  // Make sure all computed attributes are interpreted first
  computedAttributeInterpreter.interpretElement(elem);
    String fieldRef = elem.consumeStringAttribute("from");
  // Make sure that "from" was the only attribute
  elem.assertNoAttributes();
  return "\" + " + fieldRef + " + \"";
 }
 return null;
}

代码示例来源:origin: com.google.gwt/gwt-servlet

public String interpretElement(XMLElement elem)
   throws UnableToCompleteException {
  Map<String, String> attNameToToken = new HashMap<String, String>();

  for (int i = elem.getAttributeCount() - 1; i >= 0; i--) {
   XMLAttribute att = elem.getAttribute(i);

   if (att.hasComputedValue()) {
    String attToken = delegate.getAttributeToken(att);
    attNameToToken.put(att.getName(), attToken);
   } else {
    /*
     * No computed value, but make sure that any {{ madness gets escaped.
     * TODO(rjrjr) Move this to XMLElement RSN
     */
    String n = att.getName();
    String v = att.consumeRawValue().replace("\\{", "{");
    elem.setAttribute(n, v);
   }
  }

  for (Map.Entry<String, String> attr : attNameToToken.entrySet()) {
   elem.setAttribute(attr.getKey(), attr.getValue());
  }

  // Return null because we don't want to replace the dom element
  return null;
 }
}

代码示例来源:origin: com.jhickman/gxt-uibinder

@Override
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException {
  // need to grab the "value" attribute as it's ambiguous
  XMLAttribute attribute = elem.getAttribute("value");
  if (attribute != null) {
    String value = attribute.consumeRawValue();
    writer.addStatement("%s.setValue(%s);", fieldName, value);
  }
}

代码示例来源:origin: com.google.gwt/gwt-servlet

XMLAttribute attribute = elem.getAttribute(i);

代码示例来源:origin: com.jhickman/gxt-uibinder

protected void handleLayoutData(XMLElement layoutDataElem, String fieldName, UiBinderWriter writer) throws UnableToCompleteException {
  XMLAttribute typeAttribute = layoutDataElem.getAttribute("type");
  if (typeAttribute != null) {
    String layoutDataField = LayoutDataFieldFactory.declareField(layoutDataElem, typeAttribute.consumeRawValue(), writer);
    for(XMLElement child : layoutDataElem.consumeChildElements()) {
      String childField = writer.parseElementToField(child);
      writer.addStatement("%s.add(%s, %s);", fieldName, childField, layoutDataField);
    }
  } else {
    writer.die(layoutDataElem, "layoutdata missing type attribute");
  }
}

代码示例来源:origin: org.vectomatic/lib-gwt-svg

/**
 * Consumes all attributes, and returns a string representing the entire
 * opening tag. E.g., "<div able='baker'>"
 */
public String consumeOpeningTag() {
 String rtn = getOpeningTag();
 for (int i = getAttributeCount() - 1; i >= 0; i--) {
  getAttribute(i).consumeRawValue();
 }
 return rtn;
}

代码示例来源:origin: net.wetheinter/gwt-user

public String interpretElement(XMLElement elem)
  throws UnableToCompleteException {
 // Must be in the format: <ui:string from="{myMsg.message}" />
 if (writer.isBinderElement(elem) && getLocalName().equals(elem.getLocalName())) {
  if (!elem.hasAttribute("from")) {
   logger.die(elem, "Attribute 'from' not found.");
  }
  if (!elem.getAttribute("from").hasComputedValue()) {
   logger.die(elem, "Attribute 'from' does not have a computed value");
  }
  // Make sure all computed attributes are interpreted first
  computedAttributeInterpreter.interpretElement(elem);
    String fieldRef = elem.consumeStringAttribute("from");
  // Make sure that "from" was the only attribute
  elem.assertNoAttributes();
  return "\" + " + fieldRef + " + \"";
 }
 return null;
}

代码示例来源:origin: laaglu/lib-gwt-svg

/**
 * Consumes all attributes, and returns a string representing the entire
 * opening tag. E.g., "<div able='baker'>"
 */
public String consumeOpeningTag() {
 String rtn = getOpeningTag();
 for (int i = getAttributeCount() - 1; i >= 0; i--) {
  getAttribute(i).consumeRawValue();
 }
 return rtn;
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

public String interpretElement(XMLElement elem)
  throws UnableToCompleteException {
 // Must be in the format: <ui:string from="{myMsg.message}" />
 if (writer.isBinderElement(elem) && getLocalName().equals(elem.getLocalName())) {
  if (!elem.hasAttribute("from")) {
   logger.die(elem, "Attribute 'from' not found.");
  }
  if (!elem.getAttribute("from").hasComputedValue()) {
   logger.die(elem, "Attribute 'from' does not have a computed value");
  }
  // Make sure all computed attributes are interpreted first
  computedAttributeInterpreter.interpretElement(elem);
    String fieldRef = elem.consumeStringAttribute("from");
  // Make sure that "from" was the only attribute
  elem.assertNoAttributes();
  return "\" + " + fieldRef + " + \"";
 }
 return null;
}

代码示例来源:origin: net.wetheinter/gwt-user

/**
 * Consumes all attributes, and returns a string representing the entire
 * opening tag. E.g., "<div able='baker'>"
 */
public String consumeOpeningTag() {
 String rtn = getOpeningTag();
 for (int i = getAttributeCount() - 1; i >= 0; i--) {
  getAttribute(i).consumeRawValue();
 }
 return rtn;
}

代码示例来源:origin: com.jhickman/gxt-uibinder

@Override
public void parse(XMLElement elem, String fieldName, JClassType type, UiBinderWriter writer) throws UnableToCompleteException {
  
  String parameterizedType = elem.consumeRawAttribute("type", "java.lang.String");
  JClassType valueType = writer.getOracle().findType(parameterizedType);
  if (valueType == null) {
    writer.die(elem, "Found type attribute, but unable to resolve the value: %s", parameterizedType);
  }
  
  for(XMLElement child : elem.consumeChildElements()) {
    if ( ! child.getNamespaceUri().equals(elem.getNamespaceUri())) {
      writer.die(elem, "Children of SimpleComboBox must be in the same namespace.  Expected '%s' but found '%s'", elem.getPrefix(), child.getPrefix());
    }
      
    String data = parseChildElement(child, valueType, writer);
    
    writer.addStatement("%s.add(%s);", fieldName, data);
  }
  
  if (elem.getAttribute("simpleValue") != null) {
    writer.addStatement("%s.setSimpleValue(%s);", fieldName, elem.consumeAttribute("simpleValue", valueType));
  }
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * Consumes all attributes, and returns a string representing the entire
 * opening tag. E.g., "<div able='baker'>"
 */
public String consumeOpeningTag() {
 String rtn = getOpeningTag();
 for (int i = getAttributeCount() - 1; i >= 0; i--) {
  getAttribute(i).consumeRawValue();
 }
 return rtn;
}

代码示例来源:origin: com.jhickman/gxt-uibinder

XMLAttribute layoutAttribute = elem.getAttribute("layout");
if (layoutAttribute != null) {
  if (layoutFound) {

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * Ensure that the receiver has no attributes left.
 * 
 * @throws UnableToCompleteException if it does
 */
public void assertNoAttributes() throws UnableToCompleteException {
 int numAtts = getAttributeCount();
 if (numAtts == 0) {
  return;
 }
 StringBuilder b = new StringBuilder();
 for (int i = 0; i < numAtts; i++) {
  if (i > 0) {
   b.append(", ");
  }
  b.append('"').append(getAttribute(i).getName()).append('"');
 }
 logger.die(this, "Unexpected attributes: %s", b);
}

代码示例来源:origin: org.vectomatic/lib-gwt-svg

/**
 * Ensure that the receiver has no attributes left.
 * 
 * @throws UnableToCompleteException if it does
 */
public void assertNoAttributes() throws UnableToCompleteException {
 int numAtts = getAttributeCount();
 if (numAtts == 0) {
  return;
 }
 StringBuilder b = new StringBuilder();
 for (int i = 0; i < numAtts; i++) {
  if (i > 0) {
   b.append(", ");
  }
  b.append('"').append(getAttribute(i).getName()).append('"');
 }
 logger.die(this, "Unexpected attributes: %s", b);
}

代码示例来源:origin: net.wetheinter/gwt-user

/**
 * Ensure that the receiver has no attributes left.
 * 
 * @throws UnableToCompleteException if it does
 */
public void assertNoAttributes() throws UnableToCompleteException {
 int numAtts = getAttributeCount();
 if (numAtts == 0) {
  return;
 }
 StringBuilder b = new StringBuilder();
 for (int i = 0; i < numAtts; i++) {
  if (i > 0) {
   b.append(", ");
  }
  b.append('"').append(getAttribute(i).getName()).append('"');
 }
 logger.die(this, "Unexpected attributes: %s", b);
}

代码示例来源:origin: laaglu/lib-gwt-svg

/**
 * Ensure that the receiver has no attributes left.
 * 
 * @throws UnableToCompleteException if it does
 */
public void assertNoAttributes() throws UnableToCompleteException {
 int numAtts = getAttributeCount();
 if (numAtts == 0) {
  return;
 }
 StringBuilder b = new StringBuilder();
 for (int i = 0; i < numAtts; i++) {
  if (i > 0) {
   b.append(", ");
  }
  b.append('"').append(getAttribute(i).getName()).append('"');
 }
 logger.die(this, "Unexpected attributes: %s", b);
}

代码示例来源:origin: com.jhickman/gxt-uibinder

protected void applyColumnConfigProperties(UiBinderWriter writer,
    Map<String, JType> columnConfigSetterTypes, XMLElement child,
    String columnConfig) throws UnableToCompleteException {
  
  int attributeCount = child.getAttributeCount();
  for(int i = 0; i < attributeCount; i++) {
    // always get 0 because we're consuming them
    XMLAttribute attribute = child.getAttribute(0);
    String setterMethod = "set" + initialCap(attribute.getName());
    String value = child.consumeAttribute(attribute.getName(), columnConfigSetterTypes.get(setterMethod));
    writer.addStatement("%s.%s(%s);", columnConfig, setterMethod, value);
  }
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
  * An element will require a placeholder if the user has called it out with a
  * ui:ph attribute, or if it will require run time swizzling (e.g. has a
  * ui:field). These latter we can identify easily because they'll have an
  * attribute that holds a tokenator token that was vended by
  * {@link UiBinderWriter}, typically in id.
  *
  * @return true if it has an ui:ph attribute, or has a token in any attribute
  */
 private boolean isDomPlaceholder(XMLElement elem) {
  MessagesWriter mw = uiWriter.getMessages();
  if (mw.hasMessageAttribute("ph", elem)) {
   return true;
  }
  for (int i = elem.getAttributeCount() - 1; i >= 0; i--) {
   if (elem.getAttribute(i).hasToken()) {
    return true;
   }
  }
  return false;
 }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com