org.osgi.framework.Filter类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(135)

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

Filter介绍

[英]An RFC 1960-based Filter.

Filters can be created by calling BundleContext#createFilter(String) or FrameworkUtil#createFilter(String) with a filter string.

A Filter can be used numerous times to determine if the match argument matches the filter string that was used to create the Filter.

Some examples of LDAP filters are:

"(cn=Babs Jensen)" 
"(!(cn=Tim Howes))" 
"(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))" 
"(o=univ*of*mich*)"

[中]基于RFC 1960的筛选器。
可以通过使用筛选器字符串调用BundleContext#createFilter(字符串)或FrameworkUtil#createFilter(字符串)来创建筛选器。
可以多次使用筛选器来确定match参数是否与用于创建筛选器的筛选器字符串匹配。
LDAP筛选器的一些示例包括:

"(cn=Babs Jensen)" 
"(!(cn=Tim Howes))" 
"(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))" 
"(o=univ*of*mich*)"

代码示例

代码示例来源:origin: org.osgi/org.osgi.core

matchProps.put("location", bundleLocation);
boolean negate = (args.length == 2) ? "!".equals(args[1]) : false;
return (negate ^ filter.match(matchProps)) ? Condition.TRUE : Condition.FALSE;

代码示例来源:origin: org.osgi/org.osgi.core

/**
 * Internal implies method. Used by the implies and the permission
 * collection implies methods.
 * 
 * @param requested The requested AdaptPermission which has already be
 *        validated as a proper argument. The requested AdaptPermission must
 *        not have a filter expression.
 * @param effective The effective actions with which to start.
 * @return {@code true} if the specified permission is implied by this
 *         object; {@code false} otherwise.
 */
boolean implies0(AdaptPermission requested, int effective) {
  /* check actions first - much faster */
  effective |= action_mask;
  final int desired = requested.action_mask;
  if ((effective & desired) != desired) {
    return false;
  }
  /* Get filter */
  Filter f = filter;
  if (f == null) {
    // it's "*"
    return true;
  }
  return f.matches(requested.getProperties());
}

代码示例来源:origin: org.osgi/org.osgi.compendium

/**
 * Tests this event's properties against the given filter using a case
 * sensitive match.
 * 
 * @param filter The filter to test.
 * @return true If this event's properties match the filter, false
 *         otherwise.
 */
public final boolean matches(Filter filter) {
  return filter.matchCase(new FilterProperties(topic, properties));
}

代码示例来源:origin: apache/felix

public String getFilter()
{
  if (m_filter != null)
  {
    return m_filter.toString();
  }
  return null;
}

代码示例来源:origin: org.eclipse/org.eclipse.osgi

/**
 * Determines the equality of two {@code AdminPermission} objects.
 * 
 * @param obj The object being compared for equality with this object.
 * @return {@code true} if {@code obj} is equivalent to this
 *         {@code AdminPermission}; {@code false} otherwise.
 */
public boolean equals(Object obj) {
  if (obj == this) {
    return true;
  }
  if (!(obj instanceof AdminPermission)) {
    return false;
  }
  AdminPermission ap = (AdminPermission) obj;
  return (action_mask == ap.action_mask) && ((bundle == ap.bundle) || ((bundle != null) && bundle.equals(ap.bundle))) && (filter == null ? ap.filter == null : filter.equals(ap.filter));
}

代码示例来源:origin: org.eclipse.equinox.p2.artifact/repository

public String[][] serialize() {
    String[][] result = new String[filters.length][2];
    for (int i = 0; i < filters.length; i++) {
      result[i][0] = filters[i].toString();
      result[i][1] = outputStrings[i];
    }
    return result;
  }
}

代码示例来源:origin: org.eclipse/osgi

/**
 * Determines the equality of two {@code AdminPermission} objects.
 * 
 * @param obj The object being compared for equality with this object.
 * @return {@code true} if {@code obj} is equivalent to this
 *         {@code AdminPermission}; {@code false} otherwise.
 */
@Override
public boolean equals(Object obj) {
  if (obj == this) {
    return true;
  }
  if (!(obj instanceof AdminPermission)) {
    return false;
  }
  AdminPermission ap = (AdminPermission) obj;
  return (action_mask == ap.action_mask) && ((bundle == ap.bundle) || ((bundle != null) && bundle.equals(ap.bundle))) && (filter == null ? ap.filter == null : filter.equals(ap.filter));
}

代码示例来源:origin: org.osgi/org.osgi.compendium

return false;
if (!flt.match(props))
  return false;

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.p2.artifact.repository

public String[][] serialize() {
    String[][] result = new String[filters.length][2];
    for (int i = 0; i < filters.length; i++) {
      result[i][0] = filters[i].toString();
      result[i][1] = outputStrings[i];
    }
    return result;
  }
}

代码示例来源:origin: org.osgi/org.osgi.compendium

/**
 * Internal implies method. Used by the implies and the permission
 * collection implies methods.
 * 
 * @param requested The requested CoordinationPermission which has already
 *        be validated as a proper argument. The requested
 *        CoordinationPermission must not have a filter expression.
 * @param effective The effective actions with which to start.
 * @return {@code true} if the specified permission is implied by this
 *         object; {@code false} otherwise.
 */
boolean implies0(CoordinationPermission requested, int effective) {
  /* check actions first - much faster */
  effective |= action_mask;
  final int desired = requested.action_mask;
  if ((effective & desired) != desired) {
    return false;
  }
  /* Get filter */
  Filter f = filter;
  if (f == null) {
    // it's "*"
    return true;
  }
  return f.matches(requested.getProperties());
}

代码示例来源:origin: org.osgi/org.osgi.compendium

/**
 * Internal implies method. Used by the implies and the permission
 * collection implies methods.
 * 
 * @param requested The requested EndpointPermission which has already be
 *        validated as a proper argument. The requested EndpointPermission
 *        must not have a filter expression.
 * @param effective The effective actions with which to start.
 * @return {@code true} if the specified permission is implied by this
 *         object; {@code false} otherwise.
 */
boolean implies0(EndpointPermission requested, int effective) {
  /* check actions first - much faster */
  effective |= action_mask;
  final int desired = requested.action_mask;
  if ((effective & desired) != desired) {
    return false;
  }
  /* if we have no filter */
  Filter f = filter;
  if (f == null) {
    // it's "*"
    return true;
  }
  return f.matchCase(requested.getProperties());
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.osgi

/**
 * Determines the equality of two {@code AdminPermission} objects.
 * 
 * @param obj The object being compared for equality with this object.
 * @return {@code true} if {@code obj} is equivalent to this
 *         {@code AdminPermission}; {@code false} otherwise.
 */
@Override
public boolean equals(Object obj) {
  if (obj == this) {
    return true;
  }
  if (!(obj instanceof AdminPermission)) {
    return false;
  }
  AdminPermission ap = (AdminPermission) obj;
  return (action_mask == ap.action_mask) && ((bundle == ap.bundle) || ((bundle != null) && bundle.equals(ap.bundle))) && (filter == null ? ap.filter == null : filter.equals(ap.filter));
}

代码示例来源:origin: org.apache.felix/org.osgi.compendium

return false;
if( !flt.match( props ) )
  return false;

代码示例来源:origin: org.ops4j.pax.wicket/org.ops4j.pax.wicket.service

private String getFilterString(Filter baseFilter) {
  if (baseFilter != null) {
    return baseFilter.toString();
  } else {
    return null;
  }
}

代码示例来源:origin: org.osgi/org.osgi.core

return f.matches(requestedProperties);

代码示例来源:origin: org.osgi/org.osgi.compendium

/**
 * Tests the properties of this {@code EndpointDescription} against the
 * given filter using a case insensitive match.
 * 
 * @param filter The filter to test.
 * @return {@code true} If the properties of this
 *         {@code EndpointDescription} match the filter, {@code false}
 *         otherwise.
 * @throws IllegalArgumentException If {@code filter} contains an invalid
 *         filter string that cannot be parsed.
 */
public boolean matches(String filter) {
  Filter f;
  try {
    f = FrameworkUtil.createFilter(filter);
  } catch (InvalidSyntaxException e) {
    IllegalArgumentException iae = new IllegalArgumentException(e.getMessage());
    iae.initCause(e);
    throw iae;
  }
  Dictionary<String, Object> d = new UnmodifiableDictionary<String, Object>(properties);
  /*
   * we can use matchCase here since properties already supports case
   * insensitive key lookup.
   */
  return f.matchCase(d);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.osgi

/**
 * Determines the equality of two {@code AdminPermission} objects.
 * 
 * @param obj The object being compared for equality with this object.
 * @return {@code true} if {@code obj} is equivalent to this
 *         {@code AdminPermission}; {@code false} otherwise.
 */
@Override
public boolean equals(Object obj) {
  if (obj == this) {
    return true;
  }
  if (!(obj instanceof AdminPermission)) {
    return false;
  }
  AdminPermission ap = (AdminPermission) obj;
  return (action_mask == ap.action_mask) && ((bundle == ap.bundle) || ((bundle != null) && bundle.equals(ap.bundle))) && (filter == null ? ap.filter == null : filter.equals(ap.filter));
}

代码示例来源:origin: apache/aries

public boolean match(Dictionary dictionary)
{
 boolean result = delgate.match(dictionary);
 return result;
}

代码示例来源:origin: apache/felix

private void writeObject(ObjectOutputStream out) throws IOException
{
  out.defaultWriteObject();
  if (m_filter != null)
  {
    out.writeUTF(m_filter.toString());
  }
  else
  {
    out.writeUTF("");
  }
}

代码示例来源:origin: org.osgi/org.osgi.compendium

return f.matches(requestedProperties);

相关文章

微信公众号

最新文章

更多