コード例 #1
1
 public PropertyAction(RADProperty<?> aProperty) {
   super();
   property = (RADProperty<Object>) aProperty;
   String name = (String) aProperty.getValue("actionName"); // NOI18N
   if (name == null) {
     StringBuilder sb = new StringBuilder(aProperty.getName());
     sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
     name = sb.toString();
   }
   putValue(Action.NAME, name);
 }
コード例 #2
0
 @Override
 public void endElement(String uri, String localName, String qName) throws SAXException {
   if (qName.equalsIgnoreCase("class")) {
     classInfo.put(className, oci);
     className = null;
     oci = null;
   } else if (qName.equalsIgnoreCase("comment") && oci != null) {
     if (methodName != null) {
       // do nothing
       if (isGetter(methodName)) {
         MethodInfo mi = oci.getMethods.get(methodName);
         if (mi == null) {
           mi = new MethodInfo();
           oci.getMethods.put(methodName, mi);
         }
         mi.comment = comment.toString();
       } else if (isSetter(methodName)) {
         MethodInfo mi = oci.setMethods.get(methodName);
         if (mi == null) {
           mi = new MethodInfo();
           oci.setMethods.put(methodName, mi);
         }
         mi.comment = comment.toString();
       }
     } else if (fieldName != null) {
       oci.fields.put(fieldName, comment.toString());
     } else {
       oci.comment = comment.toString();
     }
     comment = null;
   } else if (qName.equalsIgnoreCase("field")) {
     fieldName = null;
   } else if (qName.equalsIgnoreCase("method")) {
     methodName = null;
   }
 }
コード例 #3
0
 public String getJavaInitializationString() {
   double[] values = (double[]) getValue();
   StringBuilder s = new StringBuilder();
   s.append("new double[] {");
   for (int i = 0; i < values.length; i++) {
     if (i > 0) s.append(", ");
     s.append(values[i]);
   }
   s.append("}");
   return s.toString();
 }
コード例 #4
0
 private static String decamelizeClassName(String className) {
   Matcher match = CAPS.matcher(className);
   StringBuilder deCameled = new StringBuilder();
   while (match.find()) {
     if (deCameled.length() == 0) {
       deCameled.append(match.group());
     } else {
       deCameled.append(" ");
       deCameled.append(match.group().toLowerCase());
     }
   }
   return deCameled.toString();
 }
コード例 #5
0
  public void paintValue(Graphics g, Rectangle box) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    double[] values = (double[]) getValue();
    StringBuilder s = new StringBuilder();
    for (int i = 0; i < 3; i++) {
      if (values.length > i) s.append(values[i]);
      if (values.length > i + 1) s.append(", ");
    }
    if (values.length > 3) s.append("...");

    g2.setPaint(Color.white);
    g2.fill(box);
    g2.setPaint(Color.black);
    FontRenderContext context = g2.getFontRenderContext();
    Rectangle2D stringBounds = g2.getFont().getStringBounds(s.toString(), context);
    double w = stringBounds.getWidth();
    double x = box.x;
    if (w < box.width) x += (box.width - w) / 2;
    double ascent = -stringBounds.getY();
    double y = box.y + (box.height - stringBounds.getHeight()) / 2 + ascent;
    g2.drawString(s.toString(), (float) x, (float) y);
  }
コード例 #6
0
 public static String getNextName(String base) {
   StringBuilder sb = new StringBuilder();
   sb.append(base);
   sb.append(nextEntryNumber++);
   return sb.toString();
 }
コード例 #7
0
 public String getPublicMethodsForClasses(String classNames[]) {
   StringBuilder result = new StringBuilder();
   String className = null;
   result.append("<classDefinitions>");
   if (classNames != null && classNames.length > 0) {
     for (int i = 0; i < classNames.length; i++) {
       className = classNames[i];
       if (className != null) {
         result.append("<classDefinition>");
         try {
           Class c = Class.forName(className);
           result.append(
               (new StringBuilder("<classSimpleName>"))
                   .append(c.getSimpleName())
                   .append("</classSimpleName>")
                   .toString());
           result.append(
               (new StringBuilder("<classFullName>"))
                   .append(c.getName())
                   .append("</classFullName>")
                   .toString());
           Package pack = c.getPackage();
           String packStr = "";
           if (pack != null) packStr = pack.getName();
           result.append(
               (new StringBuilder("<packageName>"))
                   .append(packStr)
                   .append("</packageName>")
                   .toString());
           Method methods[] = c.getMethods();
           Method method = null;
           result.append("<methods>");
           if (methods != null) {
             for (int j = 0; j < methods.length; j++) {
               method = methods[j];
               if (method != null && !methodsExclude.contains(method.getName())) {
                 result.append("<method>");
                 result.append(
                     (new StringBuilder("<methodSignature>"))
                         .append(method.toString())
                         .append("</methodSignature>")
                         .toString());
                 result.append(
                     (new StringBuilder("<methodName>"))
                         .append(method.getName())
                         .append("</methodName>")
                         .toString());
                 result.append(
                     (new StringBuilder("<returnType>"))
                         .append(method.getReturnType().getName())
                         .append("</returnType>")
                         .toString());
                 Class paramClasses[] = method.getParameterTypes();
                 result.append("<params>");
                 if (paramClasses != null) {
                   for (int l = 0; l < paramClasses.length; l++)
                     if (paramClasses[l] != null)
                       result.append(
                           (new StringBuilder("<param>"))
                               .append(paramClasses[l].getName())
                               .append("</param>")
                               .toString());
                 }
                 result.append("</params>");
                 result.append("</method>");
               }
             }
           }
           result.append("</methods>");
         } catch (ClassNotFoundException e) {
           result.append(
               (new StringBuilder("<classFullName>"))
                   .append(className)
                   .append("</classFullName>")
                   .toString());
           result.append(
               (new StringBuilder("<error>Problem retrieving "))
                   .append(className)
                   .append(" information</error>")
                   .toString());
           System.out.println(e.getMessage());
         }
         result.append("</classDefinition>");
       }
     }
   }
   result.append("</classDefinitions>");
   return result.toString();
 }
コード例 #8
0
  public String getDestinations(String messageBrokerId) {
    StringBuilder result = new StringBuilder();
    MessageBroker broker = MessageBroker.getMessageBroker(messageBrokerId);
    result.append("<remotingDestinations>");
    if (broker != null) {
      Service remotingService = broker.getServiceByType("flex.messaging.services.RemotingService");
      if (remotingService != null) {
        Map destinations = remotingService.getDestinations();
        Iterator destinationsIterator = destinations.keySet().iterator();
        result.append("<destinations>");
        if (destinationsIterator != null) {
          while (destinationsIterator.hasNext()) {
            RemotingDestination destination =
                (RemotingDestination) destinations.get(destinationsIterator.next());
            if (destination != null) {
              result.append("<destination>");
              result.append(
                  (new StringBuilder("<destinationId>"))
                      .append(destination.getId())
                      .append("</destinationId>")
                      .toString());
              result.append(
                  (new StringBuilder("<adapterName>"))
                      .append(destination.getAdapter().getClass().getName())
                      .append("</adapterName>")
                      .toString());
              result.append(
                  (new StringBuilder("<source>"))
                      .append(destination.getSource())
                      .append("</source>")
                      .toString());
              List channelIds = destination.getChannels();
              Iterator channelIdsIterator = channelIds.iterator();
              result.append("<channels>");
              for (;
                  channelIdsIterator.hasNext();
                  result.append(
                      (new StringBuilder("<channel>"))
                          .append((String) channelIdsIterator.next())
                          .append("</channel>")
                          .toString())) ;
              result.append("</channels>");
              SecurityConstraint secConstraint = destination.getSecurityConstraint();
              result.append("<securityConstraint>");
              if (secConstraint != null) {
                result.append(
                    (new StringBuilder("<securityMethod>"))
                        .append(secConstraint.getMethod())
                        .append("</securityMethod>")
                        .toString());
                result.append(
                    (new StringBuilder("<securityRoles>"))
                        .append(secConstraint.getRoles())
                        .append("</securityRoles>")
                        .toString());
              }
              result.append("</securityConstraint>");
              String className = destination.getSource();
              if (className != null)
                try {
                  Class c = Class.forName("com.adams.dt.util.Abstract");
                  Field fields[] = c.getFields();
                  result.append("<fields>");
                  if (fields != null) {
                    for (int i = 0; i < fields.length; i++)
                      result.append(
                          (new StringBuilder("<field>"))
                              .append(fields[i].toString())
                              .append("</field>")
                              .toString());
                  }
                  result.append("</fields>");

                  Method methods[] = c.getMethods();
                  result.append("<methods>");
                  if (methods != null) {
                    for (int i = 0; i < methods.length; i++)
                      if (methods[i] != null && !methodsExclude.contains(methods[i].getName())) {
                        result.append("<method>");
                        result.append(
                            (new StringBuilder("<methodSignature>"))
                                .append(methods[i].toString())
                                .append("</methodSignature>")
                                .toString());
                        result.append(
                            (new StringBuilder("<methodName>"))
                                .append(methods[i].getName())
                                .append("</methodName>")
                                .toString());
                        result.append(
                            (new StringBuilder("<returnType>"))
                                .append(methods[i].getReturnType().getName())
                                .append("</returnType>")
                                .toString());
                        Class paramClasses[] = methods[i].getParameterTypes();
                        result.append("<params>");
                        if (paramClasses != null) {
                          for (int j = 0; j < paramClasses.length; j++)
                            if (paramClasses[j] != null)
                              result.append(
                                  (new StringBuilder("<param>"))
                                      .append(paramClasses[j].getName())
                                      .append("</param>")
                                      .toString());
                        }
                        result.append("</params>");
                        result.append("</method>");
                      }
                  }
                  result.append("</methods>");
                } catch (ClassNotFoundException e) {
                  System.out.println(e.getMessage());
                }
              result.append("</destination>");
            }
          }
          result.append("</destinations>");
        }
      }
    }
    result.append("</remotingDestinations>");
    return result.toString();
  }
コード例 #9
0
  public String getPublicPropertiesForClasses(String classNames[]) {
    StringBuilder result = new StringBuilder();
    String className = null;
    ArrayList publicFields = new ArrayList();
    result.append("<classDefinitions>");
    if (classNames != null && classNames.length > 0) {
      for (int i = 0; i < classNames.length; i++) {
        className = classNames[i];
        if (className != null) {
          result.append("<classDefinition>");
          try {
            Class c = Class.forName(className);
            Field fields[] = c.getFields();
            Field field = null;
            if (fields != null) {
              for (int k = 0; k < fields.length; k++) {
                field = fields[k];
                if (field != null)
                  publicFields.add(
                      (new StringBuilder(String.valueOf(field.getName())))
                          .append(",")
                          .append(field.getType().getName())
                          .toString());
              }
            }
            try {
              BeanInfo b = Introspector.getBeanInfo(c);
              result.append(
                  (new StringBuilder("<classSimpleName>"))
                      .append(c.getSimpleName())
                      .append("</classSimpleName>")
                      .toString());
              result.append(
                  (new StringBuilder("<classFullName>"))
                      .append(c.getName())
                      .append("</classFullName>")
                      .toString());
              Package pack = c.getPackage();
              String packStr = "";
              if (pack != null) packStr = pack.getName();
              result.append(
                  (new StringBuilder("<packageName>"))
                      .append(packStr)
                      .append("</packageName>")
                      .toString());
              PropertyDescriptor pds[] = b.getPropertyDescriptors();
              if (pds != null) {
                for (int propCount = 0; propCount < pds.length; propCount++) {
                  PropertyDescriptor pd = pds[propCount];
                  String propertyName = pd.getName();
                  Method readMethod = pd.getReadMethod();
                  Method writeMethod = pd.getWriteMethod();
                  if (readMethod != null
                      && isPublicAccessor(readMethod.getModifiers())
                      && writeMethod != null
                      && isPublicAccessor(writeMethod.getModifiers()))
                    publicFields.add(
                        (new StringBuilder(String.valueOf(propertyName)))
                            .append(",")
                            .append(pd.getPropertyType().getName())
                            .toString());
                }
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
            if (publicFields != null && publicFields.size() > 0) {
              String temp = null;
              result.append("<publicFields>");
              for (int counter = 0; counter < publicFields.size(); counter++) {
                temp = (String) publicFields.get(counter);
                if (temp != null) {
                  String pubTemp[] = temp.split(",");
                  if (pubTemp.length == 2) {
                    result.append("<publicField>");
                    result.append(
                        (new StringBuilder("<publicFieldName>"))
                            .append(pubTemp[0])
                            .append("</publicFieldName>")
                            .toString());
                    result.append(
                        (new StringBuilder("<publicFieldType>"))
                            .append(pubTemp[1])
                            .append("</publicFieldType>")
                            .toString());
                    result.append("</publicField>");
                  }
                }
              }

              result.append("</publicFields>");
            }
          } catch (ClassNotFoundException e) {
            result.append(
                (new StringBuilder("<classFullName>"))
                    .append(className)
                    .append("</classFullName>")
                    .toString());
            result.append(
                (new StringBuilder("<error>Problem retrieving "))
                    .append(className)
                    .append(" information</error>")
                    .toString());
            System.out.println(e.getMessage());
          }
          result.append("</classDefinition>");
        }
      }
    }
    result.append("</classDefinitions>");
    return result.toString();
  }
コード例 #10
0
ファイル: Splitter.java プロジェクト: hwh/nota.oxygen
  private void createNewEpubDoc(Node section) throws AuthorOperationException {
    docNumber = docNumber + 1;

    StringBuilder xmlTemplate = new StringBuilder();

    xmlTemplate.append("<html");

    for (Map.Entry<String, String> entry : splitHandler.getHtmlAttributes().entrySet()) {
      xmlTemplate.append(" " + entry.getKey() + "='" + entry.getValue() + "'");
    }

    xmlTemplate.append(">");

    xmlTemplate.append("<head>");
    xmlTemplate.append("<meta charset='UTF-8'/>");

    if (packageHandler.getTitle() != null) {
      xmlTemplate.append("<title>" + packageHandler.getTitle() + "</title>");
    } else {
      xmlTemplate.append("<title>" + splitHandler.getTitle() + "</title>");
    }

    for (Map.Entry<String, String> entry : splitHandler.getMetaNodes().entrySet()) {
      xmlTemplate.append(
          "<meta content='" + entry.getValue() + "' name='" + entry.getKey() + "'/>");
    }

    for (String cssLink : splitHandler.getCssLinks()) {
      xmlTemplate.append("<link href='" + cssLink + "' rel='stylesheet' type='text/css'/>");
    }

    xmlTemplate.append("</head>");
    xmlTemplate.append("<body/>");
    xmlTemplate.append("</html>");

    Document template = Utils.deserializeDocument(xmlTemplate.toString(), null);

    Node templateBody = template.getElementsByTagName("body").item(0);

    // Read Section Node
    // Section Classname
    String className = getAttributeFromNode(section, "class");
    if (!className.equals("")) {
      // Add class to body
      Attr attrClass = template.createAttribute("class");
      attrClass.setValue(className);
      NamedNodeMap bodyAttrs = templateBody.getAttributes();
      bodyAttrs.setNamedItem(attrClass);
    }

    // Section Id
    String id = getAttributeFromNode(section, "id");
    if (!id.equals("")) {
      // Add id to body
      Attr attrID = template.createAttribute("id");
      attrID.setValue(id);
      NamedNodeMap bodyAttrs = templateBody.getAttributes();
      bodyAttrs.setNamedItem(attrID);
    }

    // Section epub:type
    String epubType = getAttributeFromNode(section, "epub:type");

    // Add epub:type to body
    Attr attrEpubType = template.createAttributeNS("http://www.idpf.org/2007/ops", "epub:type");
    attrEpubType.setValue(epubType);
    NamedNodeMap bodyAttrs = templateBody.getAttributes();
    bodyAttrs.setNamedItemNS(attrEpubType);

    // epub:type might be divided by spaces - only 1 value will be used

    String epubMainType = getEpubMainType(epubType);
    if (epubMainType.equals("")) {
      epubMainType = "unknown";
    }

    // Add Nodes to body
    NodeList sectionNodes = section.getChildNodes();
    for (int i = 0; i < sectionNodes.getLength(); i++) {
      Node sectionNode = sectionNodes.item(i);

      // Import the node
      Node importedNode = template.importNode(sectionNode, true);
      templateBody.appendChild(importedNode);
    }

    // Create FileName
    String strNum = "00" + Integer.toString(docNumber);
    strNum = strNum.substring(strNum.length() - 3);
    String newFileName = idPrefix + "-" + strNum + "-" + epubMainType + ".xhtml";

    docList.put(newFileName, template);
    stop = false;
    collectIds(newFileName, templateBody);
  }
コード例 #11
0
 @Override
 public void characters(char ch[], int start, int length) throws SAXException {
   if (comment != null) {
     comment.append(ch, start, length);
   }
 }