コード例 #1
0
ファイル: JdtUtils.java プロジェクト: himanshu28/spring-ide
  /** @since 3.2.0 */
  public static IMethod getMethod(
      IType type, String methodName, String[] parameterTypes, boolean includeHierarchy) {
    int index = methodName.indexOf('(');
    if (index >= 0) {
      methodName = methodName.substring(0, index);
    }
    try {
      while (type != null) {
        for (IMethod method : Introspector.getMethods(type)) {
          if (method.getElementName().equals(methodName)
              && method.getParameterTypes().length == parameterTypes.length) {
            String[] methodParameterTypes = getParameterTypesAsStringArray(method);
            if (Arrays.deepEquals(parameterTypes, methodParameterTypes)) {
              return method;
            }
          }
        }
        if (!includeHierarchy) break;
        type = Introspector.getSuperType(type);
      }

      return Introspector.findMethod(
          type, methodName, parameterTypes.length, Public.YES, Static.DONT_CARE);
    } catch (JavaModelException e) {
    }
    return null;
  }
コード例 #2
0
ファイル: JdtUtils.java プロジェクト: himanshu28/spring-ide
 /** Returns a flat list of all interfaces and super types for the given {@link IType}. */
 public static List<String> getFlatListOfClassAndInterfaceNames(IType parameterType, IType type) {
   List<String> requiredTypes = new ArrayList<String>();
   if (parameterType != null) {
     do {
       try {
         requiredTypes.add(parameterType.getFullyQualifiedName());
         String[] interfaceNames = parameterType.getSuperInterfaceNames();
         for (String interfaceName : interfaceNames) {
           if (interfaceName != null) {
             if (type.isBinary()) {
               requiredTypes.add(interfaceName);
             }
             String resolvedName = resolveClassName(interfaceName, type);
             if (resolvedName != null) {
               requiredTypes.add(resolvedName);
             }
           }
         }
         parameterType = Introspector.getSuperType(parameterType);
       } catch (JavaModelException e) {
       }
     } while (parameterType != null
         && !parameterType.getFullyQualifiedName().equals(Object.class.getName()));
   }
   return requiredTypes;
 }
コード例 #3
0
 private static String[] getMandatoryServiceNames(String _sServiceName) {
   String[] sMandatoryServiceNames = new String[] {};
   try {
     TypeClass[] eTypeClasses = new com.sun.star.uno.TypeClass[1];
     eTypeClasses[0] = com.sun.star.uno.TypeClass.SERVICE;
     XTypeDescriptionEnumeration xTDEnumeration =
         getXTypeDescriptionEnumerationAccess()
             .createTypeDescriptionEnumeration(
                 Introspector.getModuleName(_sServiceName),
                 eTypeClasses,
                 TypeDescriptionSearchDepth.INFINITE);
     while (xTDEnumeration.hasMoreElements()) {
       XTypeDescription xTD = xTDEnumeration.nextTypeDescription();
       if (xTD.getName().equals(_sServiceName)) {
         XServiceTypeDescription xServiceTypeDescription =
             UnoRuntime.queryInterface(XServiceTypeDescription.class, xTD);
         XServiceTypeDescription[] xMandatoryServiceTypeDescriptions =
             xServiceTypeDescription.getMandatoryServices();
         int nlength = xMandatoryServiceTypeDescriptions.length;
         sMandatoryServiceNames = new String[nlength];
         for (int i = 0; i < nlength; i++) {
           sMandatoryServiceNames[i] = xMandatoryServiceTypeDescriptions[i].getName();
         }
       }
     }
   } catch (java.lang.Exception e) {
     System.out.println(System.out);
   }
   return sMandatoryServiceNames;
 }
コード例 #4
0
 public void openIdlDescription(String _sIDLUrl, String _sClassName, String _sAnchor) {
   try {
     String sIDLUrl = _sIDLUrl;
     String sAnchor = ""; // TODO find out how the Anchor may be set at the html file;  //_sAnchor;
     boolean bExists = Introspector.getIntrospector().getXSimpleFileAccess().exists(sIDLUrl);
     if (sIDLUrl.equals("") || (!bExists)) {
       sIDLUrl = "http://api.libreoffice.org/" + Inspector.sIDLDOCUMENTSUBFOLDER;
     }
     if (!sIDLUrl.endsWith("/")) {
       sIDLUrl += "/";
     }
     if (_sClassName.equals("")) {
       sIDLUrl += "index";
       sAnchor = "";
     } else {
       sIDLUrl += _sClassName.replace(".", "_1_1");
     }
     sIDLUrl += ".html";
     if (sAnchor != null) {
       if (!sAnchor.equals("")) {
         sIDLUrl += "#" + sAnchor;
       }
     }
     URL openHyperlink = getDispatchURL(".uno:OpenHyperlink");
     PropertyValue pv = new PropertyValue();
     pv.Name = "URL";
     pv.Value = sIDLUrl;
     getXDispatcher(openHyperlink).dispatch(openHyperlink, new PropertyValue[] {pv});
   } catch (Exception exception) {
     exception.printStackTrace(System.err);
   }
 }
コード例 #5
0
ファイル: ManyToMany.java プロジェクト: anoiaque/Hermes
  public void delete(Hermes parent) {
    if (!cascadeDelete) return;
    Set<Hermes> objects = (Set<Hermes>) Introspector.get(attributeName, parent);

    if (objects == null) return;
    jointure.delete("parentId=" + parent.getId());
    for (Hermes obj : objects) obj.delete();
  }
コード例 #6
0
ファイル: JChannelFactory.java プロジェクト: jbliznak/wildfly
  /**
   * {@inheritDoc}
   *
   * @see org.jgroups.conf.ProtocolStackConfigurator#getProtocolStack()
   */
  @Override
  public List<org.jgroups.conf.ProtocolConfiguration> getProtocolStack() {
    List<org.jgroups.conf.ProtocolConfiguration> stack =
        new ArrayList<>(this.configuration.getProtocols().size() + 1);
    TransportConfiguration transport = this.configuration.getTransport();
    org.jgroups.conf.ProtocolConfiguration protocol = createProtocol(this.configuration, transport);
    Map<String, String> properties = protocol.getProperties();

    Introspector introspector = new Introspector(protocol);

    SocketBinding binding = transport.getSocketBinding();
    if (binding != null) {
      configureBindAddress(introspector, protocol, binding);
      configureServerSocket(introspector, protocol, "bind_port", binding);
      configureMulticastSocket(introspector, protocol, "mcast_addr", "mcast_port", binding);
    }

    SocketBinding diagnosticsSocketBinding = transport.getDiagnosticsSocketBinding();
    boolean diagnostics = (diagnosticsSocketBinding != null);
    properties.put("enable_diagnostics", String.valueOf(diagnostics));
    if (diagnostics) {
      configureMulticastSocket(
          introspector, protocol, "diagnostics_addr", "diagnostics_port", diagnosticsSocketBinding);
    }

    stack.add(protocol);

    final Class<? extends TP> transportClass = introspector.getProtocolClass().asSubclass(TP.class);
    PrivilegedExceptionAction<TP> action =
        new PrivilegedExceptionAction<TP>() {
          @Override
          public TP run() throws InstantiationException, IllegalAccessException {
            return transportClass.newInstance();
          }
        };

    try {
      stack.addAll(
          createProtocols(
              this.configuration, WildFlySecurityManager.doChecked(action).isMulticastCapable()));
    } catch (PrivilegedActionException e) {
      throw new IllegalStateException(e.getCause());
    }

    return stack;
  }
コード例 #7
0
ファイル: JChannelFactory.java プロジェクト: jbliznak/wildfly
 private static void setProperty(
     Introspector introspector,
     org.jgroups.conf.ProtocolConfiguration config,
     String name,
     String value) {
   if (introspector.hasProperty(name)) {
     config.getProperties().put(name, value);
   }
 }
コード例 #8
0
  /**
   * Discovers the method for a {@link PropertySet}.
   *
   * <p>The method to be found should be named "set{P,p}property.
   *
   * @param is the introspector
   * @param clazz the class to find the get method from
   * @param property the name of the property to set
   * @param arg the value to assign to the property
   * @return the method if found, null otherwise
   */
  private static java.lang.reflect.Method discover(
      Introspector is, final Class<?> clazz, String property, Object arg) {
    // first, we introspect for the set<identifier> setter method
    Object[] params = {arg};
    StringBuilder sb = new StringBuilder("set");
    sb.append(property);
    // uppercase nth char
    char c = sb.charAt(SET_START_INDEX);
    sb.setCharAt(SET_START_INDEX, Character.toUpperCase(c));
    java.lang.reflect.Method method = is.getMethod(clazz, sb.toString(), params);
    // lowercase nth char
    if (method == null) {
      sb.setCharAt(SET_START_INDEX, Character.toLowerCase(c));
      method = is.getMethod(clazz, sb.toString(), params);
    }

    return method;
  }
コード例 #9
0
ファイル: ManyToMany.java プロジェクト: anoiaque/Hermes
  public boolean save(Hermes parent) {
    Set<Hermes> set = (Set<Hermes>) Introspector.get(attributeName, parent);

    if (set == null) return true;
    jointure.clear(parent);

    for (Hermes occurence : set) {
      if (!occurence.save()) return false;
      if (!jointure.save(parent.getId(), occurence.getId())) return false;
    }
    return true;
  }
コード例 #10
0
 public static String getNodeDescription(Object _oUnoObject) {
   XServiceInfo xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, _oUnoObject);
   if (xServiceInfo != null) {
     return xServiceInfo.getImplementationName();
   }
   String sClassName = _oUnoObject.getClass().getName();
   if (Introspector.isObjectPrimitive(
       _oUnoObject)) { // super.isO{sObjectClassName.equals("java.lang.String"))issClassName.equals("java.lang.String"))
     return _oUnoObject.toString();
   } else {
     return _oUnoObject.getClass().getName();
   }
 }
コード例 #11
0
  public static Field discover(Introspector is, Class<?> clazz, String property, Class arg) {
    Field field = is.getField(clazz, property); // 直接通过class获取属性
    if (field != null) {
      if (arg != null && field.getType() != arg) { // 判断类型是否匹配
        return null;
      }

      field.setAccessible(true); // 设置为true
      return field;
    } else {
      return null;
    }
  }
コード例 #12
0
ファイル: JdtUtils.java プロジェクト: himanshu28/spring-ide
 /** @since 3.2.0 */
 public static IField getField(IType type, String fieldName, boolean includeHierarchy) {
   try {
     while (type != null) {
       for (IField field : type.getFields()) {
         if (field.getElementName().equals(fieldName)) {
           return field;
         }
       }
       if (!includeHierarchy) break;
       type = Introspector.getSuperType(type);
     }
   } catch (JavaModelException e) {
   }
   return null;
 }
コード例 #13
0
ファイル: JdtUtils.java プロジェクト: himanshu28/spring-ide
 public static IMethod getConstructor(IType type, String[] parameterTypes) {
   try {
     Set<IMethod> methods = Introspector.getAllConstructors(type);
     for (IMethod method : methods) {
       if (method.getParameterTypes().length == parameterTypes.length) {
         String[] methodParameterTypes = getParameterTypesAsStringArray(method);
         if (Arrays.deepEquals(parameterTypes, methodParameterTypes)) {
           return method;
         }
       }
     }
   } catch (JavaModelException e) {
   }
   return null;
 }
コード例 #14
0
 /** Creates a new instance of UnoNode */
 public UnoNode(Object _oUnoObject) {
   m_xComponentContext = Introspector.getIntrospector().getXComponentContext();
   m_xMultiComponentFactory = m_xComponentContext.getServiceManager();
   m_oUnoObject = _oUnoObject;
 }
コード例 #15
0
 /**
  * Returns true if the wrapped ClassDescriptor was created by introspection.
  *
  * @return true if the wrapped ClassDescriptor was created by introspection.
  */
 public boolean introspected() {
   return Introspector.introspected(_classDesc);
 } // -- introspected
 public String toString() {
   return detail.toString();
 }
 public Contact getContact() {
   return detail.getContact();
 }
 public String getEntry() {
   if (detail.isEmpty(entry)) {
     entry = detail.getEntry();
   }
   return entry;
 }
 public Expression getExpression() {
   return detail.getExpression();
 }
 public String getName() {
   return detail.getName();
 }
コード例 #21
0
 /**
  * This method is used to return an XPath expression that is used to represent the position of
  * this label. If there is no XPath expression associated with this then an empty path is
  * returned. This will never return a null expression.
  *
  * @return the XPath expression identifying the location
  */
 public Expression getExpression() throws Exception {
   return detail.getExpression();
 }
 public String getName(Context paramContext) {
   return paramContext.getStyle().getElement(detail.getName());
 }
コード例 #23
0
 /**
  * This is used to either provide the entry value provided within the annotation or compute a
  * entry value. If the entry string is not provided the the entry value is calculated as the type
  * of primitive the object is as a simplified class name.
  *
  * @return this returns the name of the XML entry element used
  */
 public String getEntry() throws Exception {
   if (detail.isEmpty(entry)) {
     entry = detail.getEntry();
   }
   return entry;
 }
コード例 #24
0
 /**
  * This is used to acquire the name of the element or attribute that is used by the class schema.
  * The name is determined by checking for an override within the annotation. If it contains a name
  * then that is used, if however the annotation does not specify a name the the field or method
  * name is used instead.
  *
  * @return returns the name that is used for the XML property
  */
 public String getName() throws Exception {
   return detail.getName();
 }
コード例 #25
0
 private static XTypeDescriptionEnumerationAccess getXTypeDescriptionEnumerationAccess() {
   return Introspector.getIntrospector().getXTypeDescriptionEnumerationAccess();
 }
コード例 #26
0
  /**
   * This is used to acquire the name of the element or attribute that is used by the class schema.
   * The name is determined by checking for an override within the annotation. If it contains a name
   * then that is used, if however the annotation does not specify a name the the field or method
   * name is used instead.
   *
   * @param context this is the context used to style the name
   * @return returns the name that is used for the XML property
   */
  public String getName(Context context) throws Exception {
    Style style = context.getStyle();
    String name = detail.getName();

    return style.getElement(name);
  }