org.datanucleus.store.query.Query.getImplicitParameters()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(100)

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

Query.getImplicitParameters介绍

暂无

代码示例

代码示例来源:origin: org.datanucleus/datanucleus-jpa

public Object getParameterValue(int position)
{
  if (query.getImplicitParameters().containsKey(position))
  {
    return query.getImplicitParameters().get(position);
  }
  return null;
}

代码示例来源:origin: org.datanucleus/datanucleus-jpa

public Object getParameterValue(String name)
{
  if (query.getImplicitParameters().containsKey(name))
  {
    return query.getImplicitParameters().get(name);
  }
  return null;
}

代码示例来源:origin: org.datanucleus/datanucleus-jpa

public Parameter<?> getParameter(String name)
{
  Set paramKeys = query.getImplicitParameters().keySet();
  Iterator iter = paramKeys.iterator();
  while (iter.hasNext())
  {
    Object paramKey = iter.next();
    if (paramKey instanceof String && ((String)paramKey).equals(name))
    {
      Object value = query.getImplicitParameters().get(paramKey);
      return new JPAQueryParameter((String)paramKey, value != null ? value.getClass() : null);
    }
  }
  throw new IllegalArgumentException("No parameter with name " + name);
}

代码示例来源:origin: org.datanucleus/datanucleus-jpa

public Parameter<?> getParameter(int position)
{
  Set paramKeys = query.getImplicitParameters().keySet();
  Iterator iter = paramKeys.iterator();
  while (iter.hasNext())
  {
    Object paramKey = iter.next();
    if (paramKey instanceof Integer && ((Integer)paramKey).intValue() == position)
    {
      Object value = query.getImplicitParameters().get(paramKey);
      return new JPAQueryParameter((Integer)paramKey, value != null ? value.getClass() : null);
    }
  }
  throw new IllegalArgumentException("No parameter at position=" + position);
}

代码示例来源:origin: org.datanucleus/datanucleus-jpa

/**
 * Get the parameter of the given name and type.
 * @return parameter object
 * @throws IllegalArgumentException if the parameter of the specified name and type doesn't exist
 */
public <T> Parameter<T> getParameter(String name, Class<T> type)
{
  Set paramKeys = query.getImplicitParameters().keySet();
  Iterator iter = paramKeys.iterator();
  while (iter.hasNext())
  {
    Object paramKey = iter.next();
    if (paramKey instanceof String && ((String)paramKey).equals(name))
    {
      Object value = query.getImplicitParameters().get(paramKey);
      if (value != null && type.isAssignableFrom(value.getClass()))
      {
        return new JPAQueryParameter((String)paramKey, type);
      }
    }
  }
  throw new IllegalArgumentException("No parameter with name " + name + " and type=" + type.getName());
}

代码示例来源:origin: org.datanucleus/datanucleus-jpa

/**
 * Get the positional parameter with the given position and type.
 * @return parameter object
 * @throws IllegalArgumentException if the parameter with the specified position and type doesn't exist
 */
public <T> Parameter<T> getParameter(int position, Class<T> type)
{
  Set paramKeys = query.getImplicitParameters().keySet();
  Iterator iter = paramKeys.iterator();
  while (iter.hasNext())
  {
    Object paramKey = iter.next();
    if (paramKey instanceof Integer && ((Integer)paramKey).intValue() == position)
    {
      Object value = query.getImplicitParameters().get(paramKey);
      if (value != null && type.isAssignableFrom(value.getClass()))
      {
        return new JPAQueryParameter((Integer)paramKey, type);
      }
    }
  }
  throw new IllegalArgumentException("No parameter at position=" + position + " and type=" + type.getName());
}

代码示例来源:origin: org.datanucleus/datanucleus-java5

/**
 * Get the parameters names and associated values of the parameters that are bound for the query instance.
 * Returns empty map if no parameters have been bound or if the query does not use named parameters.
 * @return named parameters
 */
@SuppressWarnings("unchecked")
public Map getNamedParameters()
{
  Map params = query.getImplicitParameters();
  Map map = new HashMap();
  if (params != null && params.size() > 0)
  {
    boolean named = true;
    Iterator iter = params.keySet().iterator();
    while (iter.hasNext())
    {
      Object obj = iter.next();
      if (obj instanceof Integer) // Check for positional params
      {
        named = false;
        break;
      }
    }
    if (named)
    {
      map.putAll(params);
    }
  }
  return map;
}

代码示例来源:origin: org.datanucleus/datanucleus-jpa

public boolean isBound(Parameter<?> param)
{
  if (param.getName() != null)
  {
    if (query.getImplicitParameters().containsKey(param.getName()))
    {
      return true;
    }
  }
  else
  {
    if (query.getImplicitParameters().containsKey(param.getPosition()))
    {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.datanucleus/datanucleus-jpa

/**
 * Get the query parameter objects.
 * Returns empty set if the query has no parameters.
 * @return parameter objects
 */
public Set<Parameter<?>> getParameters()
{
  Set paramKeys = query.getImplicitParameters().keySet();
  Set<Parameter<?>> parameters = new HashSet();
  Iterator iter = paramKeys.iterator();
  while (iter.hasNext())
  {
    Object paramKey = iter.next();
    Object value = query.getImplicitParameters().get(paramKey);
    if (paramKey instanceof String)
    {
      parameters.add(new JPAQueryParameter((String)paramKey, value != null ? value.getClass() : null));
    }
    else if (paramKey instanceof Integer)
    {
      parameters.add(new JPAQueryParameter((Integer)paramKey, value != null ? value.getClass() : null));
    }
  }
  return parameters;
}

代码示例来源:origin: org.datanucleus/datanucleus-java5

public List getPositionalParameters()
  Map params = query.getImplicitParameters();
  List list = new ArrayList();
  if (params != null && params.size() > 0)

代码示例来源:origin: org.datanucleus/datanucleus-jpa

/**
 * Return the value that has been bound to the parameter.
 * @param param parameter object
 * @return parameter value
 * @throws IllegalStateException if the parameter has not been bound
 */
public <T> T getParameterValue(Parameter<T> param)
{
  if (param.getName() != null)
  {
    if (query.getImplicitParameters().containsKey(param.getName()))
    {
      return (T)query.getImplicitParameters().get(param.getName());
    }
  }
  else
  {
    if (query.getImplicitParameters().containsKey(param.getPosition()))
    {
      return (T)query.getImplicitParameters().get(param.getPosition());
    }
  }
  throw new IllegalStateException("No parameter matching " + param + " bound to this query");
}

相关文章