com.marklogic.client.query.CountedDistinctValue Maven / Gradle / Ivy
/*
* Copyright 2012-2015 MarkLogic Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.marklogic.client.query;
import com.marklogic.client.impl.ValueConverter;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
/**
* A CountedDistinctValue is a value that includes a frequency.
*/
public class CountedDistinctValue {
@XmlAttribute(name = "frequency")
long frequency;
@XmlValue
String value;
/**
* Returns the frequency associated with this value.
* @return The frequency.
*/
public long getCount() {
return frequency;
}
/**
* Returns the value cast to the specified type.
*
* This method converts the value according to the supplied type and then casts it
* to the specified class.
*
* The following types are supported:
* xs:anySimpleType
,
* xs:base64Binary
, xs:boolean
,
* xs:byte
, xs:date
,
* xs:dateTime
, xs:dayTimeDuration
,
* xs:decimal
, xs:double
,
* xs:duration
, xs:float
,
* xs:int
, xs:integer
,
* xs:long
, xs:short
,
* xs:string
, xs:time
,
* xs:unsignedInt
, xs:unsignedLong
,
* xs:unsignedShort
, and
* xs:yearMonthDuration
.
*
* @see ValueConverter#convertToJava(String,String) label
* @param type The name of the XSD type to use for conversion.
* @param as The class parameter
* @param The class to cast to
* @return The value, cast to the specified type or
*/
public T get(String type, Class as) {
return ValueConverter.convertToJava(type, value, as);
}
}