code
stringlengths 67
466k
| docstring
stringlengths 1
13.2k
|
---|---|
public static base_responses flush(nitro_service client, cachecontentgroup resources[]) throws Exception {
base_responses result = null;
if (resources != null && resources.length > 0) {
cachecontentgroup flushresources[] = new cachecontentgroup[resources.length];
for (int i=0;i<resources.length;i++){
flushresources[i] = new cachecontentgroup();
flushresources[i].name = resources[i].name;
flushresources[i].query = resources[i].query;
flushresources[i].host = resources[i].host;
flushresources[i].selectorvalue = resources[i].selectorvalue;
flushresources[i].force = resources[i].force;
}
result = perform_operation_bulk_request(client, flushresources,"flush");
}
return result;
} | Use this API to flush cachecontentgroup resources. |
public static base_response save(nitro_service client, cachecontentgroup resource) throws Exception {
cachecontentgroup saveresource = new cachecontentgroup();
saveresource.name = resource.name;
return saveresource.perform_operation(client,"save");
} | Use this API to save cachecontentgroup. |
public static base_responses save(nitro_service client, cachecontentgroup resources[]) throws Exception {
base_responses result = null;
if (resources != null && resources.length > 0) {
cachecontentgroup saveresources[] = new cachecontentgroup[resources.length];
for (int i=0;i<resources.length;i++){
saveresources[i] = new cachecontentgroup();
saveresources[i].name = resources[i].name;
}
result = perform_operation_bulk_request(client, saveresources,"save");
}
return result;
} | Use this API to save cachecontentgroup resources. |
public static cachecontentgroup[] get(nitro_service service) throws Exception{
cachecontentgroup obj = new cachecontentgroup();
cachecontentgroup[] response = (cachecontentgroup[])obj.get_resources(service);
return response;
} | Use this API to fetch all the cachecontentgroup resources that are configured on netscaler. |
public static cachecontentgroup get(nitro_service service, String name) throws Exception{
cachecontentgroup obj = new cachecontentgroup();
obj.set_name(name);
cachecontentgroup response = (cachecontentgroup) obj.get_resource(service);
return response;
} | Use this API to fetch cachecontentgroup resource of given name . |
public static cachecontentgroup[] get_filtered(nitro_service service, String filter) throws Exception{
cachecontentgroup obj = new cachecontentgroup();
options option = new options();
option.set_filter(filter);
cachecontentgroup[] response = (cachecontentgroup[]) obj.getfiltered(service, option);
return response;
} | Use this API to fetch filtered set of cachecontentgroup resources.
filter string should be in JSON format.eg: "port:80,servicetype:HTTP". |
public static lbvserver_auditnslogpolicy_binding[] get(nitro_service service, String name) throws Exception{
lbvserver_auditnslogpolicy_binding obj = new lbvserver_auditnslogpolicy_binding();
obj.set_name(name);
lbvserver_auditnslogpolicy_binding response[] = (lbvserver_auditnslogpolicy_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch lbvserver_auditnslogpolicy_binding resources of given name . |
public static base_response update(nitro_service client, csparameter resource) throws Exception {
csparameter updateresource = new csparameter();
updateresource.stateupdate = resource.stateupdate;
return updateresource.update_resource(client);
} | Use this API to update csparameter. |
public static base_response unset(nitro_service client, csparameter resource, String[] args) throws Exception{
csparameter unsetresource = new csparameter();
return unsetresource.unset_resource(client,args);
} | Use this API to unset the properties of csparameter resource.
Properties that need to be unset are specified in args array. |
public static csparameter get(nitro_service service) throws Exception{
csparameter obj = new csparameter();
csparameter[] response = (csparameter[])obj.get_resources(service);
return response[0];
} | Use this API to fetch all the csparameter resources that are configured on netscaler. |
public static vpnvserver_rewritepolicy_binding[] get(nitro_service service, String name) throws Exception{
vpnvserver_rewritepolicy_binding obj = new vpnvserver_rewritepolicy_binding();
obj.set_name(name);
vpnvserver_rewritepolicy_binding response[] = (vpnvserver_rewritepolicy_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch vpnvserver_rewritepolicy_binding resources of given name . |
public static auditnslogpolicy_systemglobal_binding[] get(nitro_service service, String name) throws Exception{
auditnslogpolicy_systemglobal_binding obj = new auditnslogpolicy_systemglobal_binding();
obj.set_name(name);
auditnslogpolicy_systemglobal_binding response[] = (auditnslogpolicy_systemglobal_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch auditnslogpolicy_systemglobal_binding resources of given name . |
public static responderpolicy_binding get(nitro_service service, String name) throws Exception{
responderpolicy_binding obj = new responderpolicy_binding();
obj.set_name(name);
responderpolicy_binding response = (responderpolicy_binding) obj.get_resource(service);
return response;
} | Use this API to fetch responderpolicy_binding resource of given name . |
public void setLabels(Collection<LabelType> labels) {
this.labels.clear();
if (labels != null) {
this.labels.addAll(labels);
}
} | Removes all currently assigned labels for this Datum then adds all
of the given Labels. |
public List<Address> getClusterMembers() {
if (currentView != null) {
return Collections.unmodifiableList(currentView);
}
else {
final Address localAddress = getLocalAddress();
if (localAddress == null) {
return Collections.emptyList();
}
else {
final List<Address> list = new ArrayList<Address>();
list.add(localAddress);
return Collections.unmodifiableList(list);
}
}
} | /* (non-Javadoc)
@see MobicentsCluster#getClusterMembers() |
public boolean isHeadMember() {
final Address localAddress = getLocalAddress();
if (localAddress != null) {
final List<Address> clusterMembers = getClusterMembers();
return !clusterMembers.isEmpty() && clusterMembers.get(0).equals(localAddress);
}
else {
return true;
}
} | /* (non-Javadoc)
@see MobicentsCluster#isHeadMember() |
public boolean isSingleMember() {
final Address localAddress = getLocalAddress();
if (localAddress != null) {
final List<Address> clusterMembers = getClusterMembers();
return clusterMembers.size() == 1;
}
else {
return true;
}
} | /*
(non-Javadoc)
@see MobicentsCluster#isSingleMember() |
@ViewChanged
public synchronized void onViewChangeEvent(ViewChangedEvent event) {
if (logger.isDebugEnabled()) {
logger.debug("onViewChangeEvent : pre[" + event.isPre() + "] : event local address[" + event.getCache().getLocalAddress() + "]");
}
final List<Address> oldView = currentView;
currentView = new ArrayList<Address>(event.getNewView().getMembers());
final Address localAddress = getLocalAddress();
//just a precaution, it can be null!
if (oldView != null) {
final Cache jbossCache = mobicentsCache.getJBossCache();
final Configuration config = jbossCache.getConfiguration();
final boolean isBuddyReplicationEnabled = config.getBuddyReplicationConfig() != null && config.getBuddyReplicationConfig().isEnabled();
// recover stuff from lost members
Runnable runnable = new Runnable() {
public void run() {
for (Address oldMember : oldView) {
if (!currentView.contains(oldMember)) {
if (logger.isDebugEnabled()) {
logger.debug("onViewChangeEvent : processing lost member " + oldMember);
}
for (FailOverListener localListener : failOverListeners) {
ClientLocalListenerElector localListenerElector = localListener.getElector();
if (localListenerElector != null && !isBuddyReplicationEnabled) {
// going to use the local listener elector instead, which gives results based on data
performTakeOver(localListener,oldMember,localAddress, true, isBuddyReplicationEnabled);
}
else {
List<Address> electionView = getElectionView(oldMember);
if(electionView!=null && elector.elect(electionView).equals(localAddress))
{
performTakeOver(localListener, oldMember, localAddress, false, isBuddyReplicationEnabled);
}
cleanAfterTakeOver(localListener, oldMember);
}
}
}
}
}
};
Thread t = new Thread(runnable);
t.start();
}
} | Method handle a change on the cluster members set
@param event |
public boolean addFailOverListener(FailOverListener localListener) {
if (logger.isDebugEnabled()) {
logger.debug("Adding local listener " + localListener);
}
for(FailOverListener failOverListener : failOverListeners) {
if (failOverListener.getBaseFqn().getFqn().equals(localListener.getBaseFqn().getFqn())) {
return false;
}
}
return failOverListeners.add(localListener);
} | /*
(non-Javadoc)
@see MobicentsCluster#addFailOverListener(FailOverListener) |
public boolean removeFailOverListener(FailOverListener localListener) {
if (logger.isDebugEnabled()) {
logger.debug("Removing local listener " + localListener);
}
return failOverListeners.remove(localListener);
} | /*
(non-Javadoc)
@see MobicentsCluster#removeFailOverListener(FailOverListener) |
public boolean addDataRemovalListener(DataRemovalListener listener) {
return dataRemovalListeners.putIfAbsent(listener.getBaseFqn().getFqn(), listener) == null;
} | /*
(non-Javadoc)
@see MobicentsCluster#addDataRemovalListener(DataRemovalListener) |
public static appfwpolicy_stats[] get(nitro_service service) throws Exception{
appfwpolicy_stats obj = new appfwpolicy_stats();
appfwpolicy_stats[] response = (appfwpolicy_stats[])obj.stat_resources(service);
return response;
} | Use this API to fetch the statistics of all appfwpolicy_stats resources that are configured on netscaler. |
public static appfwpolicy_stats get(nitro_service service, String name) throws Exception{
appfwpolicy_stats obj = new appfwpolicy_stats();
obj.set_name(name);
appfwpolicy_stats response = (appfwpolicy_stats) obj.stat_resource(service);
return response;
} | Use this API to fetch statistics of appfwpolicy_stats resource of given name . |
@Override
public MtasDataItemNumberComparator<Double> getCompareValue1() {
switch (sortType) {
case CodecUtil.STATS_TYPE_SUM:
return new MtasDataItemNumberComparator<Double>(valueSum, sortDirection);
default:
return null;
}
} | /*
(non-Javadoc)
@see mtas.codec.util.collector.MtasDataItem#getCompareValue() |
public MtasDataItemNumberComparator<Double> getCompareValue2() {
switch (sortType) {
case CodecUtil.STATS_TYPE_MEAN:
return new MtasDataItemNumberComparator<Double>(getValue(sortType),
sortDirection);
default:
return null;
}
} | /*
(non-Javadoc)
@see mtas.codec.util.collector.MtasDataItem#getCompareValue2() |
public static pqbinding[] get(nitro_service service, pqbinding_args args) throws Exception{
pqbinding obj = new pqbinding();
options option = new options();
option.set_args(nitro_util.object_to_string_withoutquotes(args));
pqbinding[] response = (pqbinding[])obj.get_resources(service, option);
return response;
} | Use this API to fetch all the pqbinding resources that are configured on netscaler.
This uses pqbinding_args which is a way to provide additional arguments while fetching the resources. |
public void addNodeToIndexMap(int index, TreeGraphNode node) {
indexMap.put(Integer.valueOf(index), node);
} | Store a mapping from an arbitrary integer index to a node in
this treegraph. Normally a client shouldn't need to use this,
as the nodes are automatically indexed by the
<code>TreeGraph</code> constructor.
@param index the arbitrary integer index
@param node the <code>TreeGraphNode</code> to be indexed |
public static void main(String[] args) {
Tree t;
try {
t = Tree.valueOf("(S (NP (NNP Sam)) (VP (VBD died) (NP-TMP (NN today))))");
} catch (Exception e) {
System.err.println("Horrible error: " + e);
e.printStackTrace();
return;
}
t.pennPrint();
System.out.println("----------------------------");
TreeGraph tg = new TreeGraph(t);
System.out.println(tg);
tg.root.percolateHeads(new SemanticHeadFinder());
System.out.println("----------------------------");
System.out.println(tg);
// TreeGraphNode node1 = tg.getNodeByIndex(1);
// TreeGraphNode node4 = tg.getNodeByIndex(4);
// node1.addArc("1to4", node4);
// node1.addArc("1TO4", node4);
// node4.addArc("4to1", node1);
// System.out.println("----------------------------");
// System.out.println("arcs from 1 to 4: " + node1.arcLabelsToNode(node4));
// System.out.println("arcs from 4 to 1: " + node4.arcLabelsToNode(node1));
// System.out.println("arcs from 0 to 4: " + tg.root.arcLabelsToNode(node4));
// for (int i = 0; i <= 9; i++) {
// System.out.println("parent of " + i + ": " + tg.getNodeByIndex(i).parent());
// System.out.println("highest node with same head as " + i + ": " + tg.getNodeByIndex(i).highestNodeWithSameHead());
// }
} | Just for testing. |
public void addAllOfFromTo(ObjectArrayList other, int from, int to) {
beforeInsertAllOfFromTo(size, other, from, to);
} | Appends the part of the specified list between <code>from</code> (inclusive) and <code>to</code> (inclusive) to the receiver.
@param other the list to be added to the receiver.
@param from the index of the first element to be appended (inclusive).
@param to the index of the last element to be appended (inclusive).
@exception IndexOutOfBoundsException index is out of range (<tt>other.size()>0 && (from<0 || from>to || to>=other.size())</tt>). |
public void beforeInsert(int index, Object element) {
// overridden for performance only.
if (index > size || index < 0)
throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size);
ensureCapacity(size + 1);
System.arraycopy(elements, index, elements, index+1, size-index);
elements[index] = element;
size++;
} | Inserts the specified element before the specified position into the receiver.
Shifts the element currently at that position (if any) and
any subsequent elements to the right.
@param index index before which the specified element is to be inserted (must be in [0,size]).
@param element element to be inserted.
@exception IndexOutOfBoundsException index is out of range (<tt>index < 0 || index > size()</tt>). |
protected void beforeInsertDummies(int index, int length) {
if (index > size || index < 0)
throw new IndexOutOfBoundsException("Index: "+index+", Size: "+size);
if (length > 0) {
ensureCapacity(size + length);
System.arraycopy(elements, index, elements, index + length, size-index);
size += length;
}
} | Inserts length dummies before the specified position into the receiver.
Shifts the element currently at that position (if any) and
any subsequent elements to the right.
@param index index before which to insert dummies (must be in [0,size])..
@param length number of dummies to be inserted. |
public int binarySearchFromTo(Object key, int from, int to) {
int low = from;
int high = to;
while (low <= high) {
int mid =(low + high)/2;
Object midVal = elements[mid];
int cmp = ((Comparable)midVal).compareTo(key);
if (cmp < 0) low = mid + 1;
else if (cmp > 0) high = mid - 1;
else return mid; // key found
}
return -(low + 1); // key not found.
} | Searches the receiver for the specified value using
the binary search algorithm. The receiver must be sorted into ascending order
according to the <i>natural ordering</i> of its elements (as by the sort method)
prior to making this call.
If it is not sorted, the results are undefined: in particular, the call
may enter an infinite loop. If the receiver contains multiple elements
equal to the specified object, there is no guarantee which instance
will be found.
@param key the value to be searched for.
@param from the leftmost search position, inclusive.
@param to the rightmost search position, inclusive.
@return index of the search key, if it is contained in the receiver;
otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
point</i> is defined as the the point at which the value would
be inserted into the receiver: the index of the first
element greater than the key, or <tt>receiver.size()</tt>, if all
elements in the receiver are less than the specified key. Note
that this guarantees that the return value will be >= 0 if
and only if the key is found.
@see Comparable
@see java.util.Arrays |
public int binarySearchFromTo(Object key, int from, int to, java.util.Comparator comparator) {
//return cern.colt.Sorting.binarySearchFromTo(this.elements,key,from,to,comparator);
return java.util.Arrays.binarySearch(this.elements,key);
} | Searches the receiver for the specified value using
the binary search algorithm. The receiver must be sorted into ascending order
according to the specified comparator. All elements in the
range must be <i>mutually comparable</i> by the specified comparator
(that is, <tt>c.compare(e1, e2)</tt> must not throw a
<tt>ClassCastException</tt> for any elements <tt>e1</tt> and
<tt>e2</tt> in the range).<p>
If the receiver is not sorted, the results are undefined: in particular, the call
may enter an infinite loop. If the receiver contains multiple elements
equal to the specified object, there is no guarantee which instance
will be found.
@param key the value to be searched for.
@param from the leftmost search position, inclusive.
@param to the rightmost search position, inclusive.
@param comparator the comparator by which the receiver is sorted.
@throws ClassCastException if the receiver contains elements that are not
<i>mutually comparable</i> using the specified comparator.
@return index of the search key, if it is contained in the receiver;
otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The <i>insertion
point</i> is defined as the the point at which the value would
be inserted into the receiver: the index of the first
element greater than the key, or <tt>receiver.size()</tt>, if all
elements in the receiver are less than the specified key. Note
that this guarantees that the return value will be >= 0 if
and only if the key is found.
@see cern.colt.Sorting
@see java.util.Arrays
@see java.util.Comparator |
public void delete(Object element, boolean testForEquality) {
int index = indexOfFromTo(element, 0, size-1, testForEquality);
if (index>=0) removeFromTo(index,index);
} | Deletes the first element from the receiver that matches the specified element.
Does nothing, if no such matching element is contained.
Tests elements for equality or identity as specified by <tt>testForEquality</tt>.
When testing for equality, two elements <tt>e1</tt> and
<tt>e2</tt> are <i>equal</i> if <tt>(e1==null ? e2==null :
e1.equals(e2))</tt>.)
@param testForEquality if true -> tests for equality, otherwise for identity.
@param element the element to be deleted. |
public void fillFromToWith(int from, int to, Object val) {
checkRangeFromTo(from,to,this.size);
for (int i=from; i<=to;) setQuick(i++,val);
} | Sets the specified range of elements in the specified array to the specified value.
@param from the index of the first element (inclusive) to be filled with the specified value.
@param to the index of the last element (inclusive) to be filled with the specified value.
@param val the value to be stored in the specified elements of the receiver. |
public boolean forEach(ObjectProcedure procedure) {
Object[] theElements = elements;
int theSize = size;
for (int i=0; i<theSize;) if (! procedure.apply(theElements[i++])) return false;
return true;
} | Applies a procedure to each element of the receiver, if any.
Starts at index 0, moving rightwards.
@param procedure the procedure to be applied. Stops iteration if the procedure returns <tt>false</tt>, otherwise continues.
@return <tt>false</tt> if the procedure stopped before all elements where iterated over, <tt>true</tt> otherwise. |
public int indexOfFromTo(Object element, int from, int to, boolean testForEquality) {
if (size==0) return -1;
checkRangeFromTo(from, to, size);
Object[] theElements = elements;
if (testForEquality && element!=null) {
for (int i = from ; i <= to; i++) {
if (element.equals(theElements[i])) {return i;} //found
}
}
else {
for (int i = from ; i <= to; i++) {
if (element==theElements[i]) {return i;} //found
}
}
return -1; //not found
} | Returns the index of the first occurrence of the specified
element. Returns <code>-1</code> if the receiver does not contain this element.
Searches between <code>from</code>, inclusive and <code>to</code>, inclusive.
Tests for equality or identity as specified by <code>testForEquality</code>.
@param element element to search for.
@param from the leftmost search position, inclusive.
@param to the rightmost search position, inclusive.
@param testForEquality if </code>true</code> -> test for equality, otherwise for identity.
@return the index of the first occurrence of the element in the receiver; returns <code>-1</code> if the element is not found.
@exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). |
public boolean isSortedFromTo(int from, int to) {
if (size==0) return true;
checkRangeFromTo(from, to, size);
Object[] theElements = elements;
for (int i=from+1; i<=to; i++ ) {
if (((Comparable)theElements[i]).compareTo((Comparable) theElements[i-1]) < 0) return false;
}
return true;
} | Determines whether the receiver is sorted ascending, according to the <i>natural ordering</i> of its
elements. All elements in this range must implement the
<tt>Comparable</tt> interface. Furthermore, all elements in this range
must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt>
must not throw a <tt>ClassCastException</tt> for any elements
<tt>e1</tt> and <tt>e2</tt> in the array).<p>
@param from the index of the first element (inclusive) to be sorted.
@param to the index of the last element (inclusive) to be sorted.
@return <tt>true</tt> if the receiver is sorted ascending, <tt>false</tt> otherwise.
@exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). |
public void mergeSortFromTo(int from, int to) {
if (size==0) return;
checkRangeFromTo(from, to, size);
java.util.Arrays.sort(elements, from, to+1);
} | Sorts the specified range of the receiver into
ascending order, according to the <i>natural ordering</i> of its
elements. All elements in this range must implement the
<tt>Comparable</tt> interface. Furthermore, all elements in this range
must be <i>mutually comparable</i> (that is, <tt>e1.compareTo(e2)</tt>
must not throw a <tt>ClassCastException</tt> for any elements
<tt>e1</tt> and <tt>e2</tt> in the array).<p>
This sort is guaranteed to be <i>stable</i>: equal elements will
not be reordered as a result of the sort.<p>
The sorting algorithm is a modified mergesort (in which the merge is
omitted if the highest element in the low sublist is less than the
lowest element in the high sublist). This algorithm offers guaranteed
n*log(n) performance, and can approach linear performance on nearly
sorted lists.
<p><b>You should never call this method unless you are sure that this particular sorting algorithm is the right one for your data set.</b>
It is generally better to call <tt>sort()</tt> or <tt>sortFromTo(...)</tt> instead, because those methods automatically choose the best sorting algorithm.
@param from the index of the first element (inclusive) to be sorted.
@param to the index of the last element (inclusive) to be sorted.
@exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). |
public ObjectArrayList partFromTo(int from, int to) {
if (size==0) return new ObjectArrayList(0);
checkRangeFromTo(from, to, size);
Object[] part = new Object[to-from+1];
System.arraycopy(elements, from, part, 0, to-from+1);
return new ObjectArrayList(part);
} | Returns a new list of the part of the receiver between <code>from</code>, inclusive, and <code>to</code>, inclusive.
@param from the index of the first element (inclusive).
@param to the index of the last element (inclusive).
@return a new list
@exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). |
public boolean removeAll(ObjectArrayList other, boolean testForEquality) {
if (other.size==0) return false; //nothing to do
int limit = other.size-1;
int j=0;
Object[] theElements = elements;
for (int i=0; i<size ; i++) {
if (other.indexOfFromTo(theElements[i], 0, limit, testForEquality) < 0) theElements[j++]=theElements[i];
}
boolean modified = (j!=size);
setSize(j);
return modified;
} | Removes from the receiver all elements that are contained in the specified list.
Tests for equality or identity as specified by <code>testForEquality</code>.
@param other the other list.
@param testForEquality if <code>true</code> -> test for equality, otherwise for identity.
@return <code>true</code> if the receiver changed as a result of the call. |
public void removeFromTo(int from, int to) {
checkRangeFromTo(from, to, size);
int numMoved = size - to - 1;
if (numMoved >= 0) {
System.arraycopy(elements, to+1, elements, from, numMoved);
fillFromToWith(from+numMoved, size-1, null); //delta
}
int width = to-from+1;
if (width>0) size -= width;
} | Removes from the receiver all elements whose index is between
<code>from</code>, inclusive and <code>to</code>, inclusive. Shifts any succeeding
elements to the left (reduces their index).
This call shortens the list by <tt>(to - from + 1)</tt> elements.
@param from index of first element to be removed.
@param to index of last element to be removed.
@exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). |
public void replaceFromToWithFrom(int from, int to, ObjectArrayList other, int otherFrom) {
int length=to-from+1;
if (length>0) {
checkRangeFromTo(from, to, size);
checkRangeFromTo(otherFrom,otherFrom+length-1,other.size);
System.arraycopy(other.elements, otherFrom, elements, from, length);
}
} | Replaces a number of elements in the receiver with the same number of elements of another list.
Replaces elements in the receiver, between <code>from</code> (inclusive) and <code>to</code> (inclusive),
with elements of <code>other</code>, starting from <code>otherFrom</code> (inclusive).
@param from the position of the first element to be replaced in the receiver
@param to the position of the last element to be replaced in the receiver
@param other list holding elements to be copied into the receiver.
@param otherFrom position of first element within other list to be copied. |
public void replaceFromToWithFromTo(int from, int to, ObjectArrayList other, int otherFrom, int otherTo) {
if (otherFrom>otherTo) {
throw new IndexOutOfBoundsException("otherFrom: "+otherFrom+", otherTo: "+otherTo);
}
if (this==other && to-from!=otherTo-otherFrom) { // avoid stumbling over my own feet
replaceFromToWithFromTo(from, to, partFromTo(otherFrom, otherTo), 0, otherTo-otherFrom);
return;
}
int length=otherTo-otherFrom+1;
int diff=length;
int theLast=from-1;
//System.out.println("from="+from);
//System.out.println("to="+to);
//System.out.println("diff="+diff);
if (to>=from) {
diff -= (to-from+1);
theLast=to;
}
if (diff>0) {
beforeInsertDummies(theLast+1, diff);
}
else {
if (diff<0) {
removeFromTo(theLast+diff, theLast-1);
}
}
if (length>0) {
System.arraycopy(other.elements, otherFrom, elements, from, length);
}
} | Replaces the part between <code>from</code> (inclusive) and <code>to</code> (inclusive) with the other list's
part between <code>otherFrom</code> and <code>otherTo</code>.
Powerful (and tricky) method!
Both parts need not be of the same size (part A can both be smaller or larger than part B).
Parts may overlap.
Receiver and other list may (but most not) be identical.
If <code>from > to</code>, then inserts other part before <code>from</code>.
@param from the first element of the receiver (inclusive)
@param to the last element of the receiver (inclusive)
@param other the other list (may be identical with receiver)
@param otherFrom the first element of the other list (inclusive)
@param otherTo the last element of the other list (inclusive)
<p><b>Examples:</b><pre>
a=[0, 1, 2, 3, 4, 5, 6, 7]
b=[50, 60, 70, 80, 90]
a.R(...)=a.replaceFromToWithFromTo(...)
a.R(3,5,b,0,4)-->[0, 1, 2, 50, 60, 70, 80, 90, 6, 7]
a.R(1,6,b,0,4)-->[0, 50, 60, 70, 80, 90, 7]
a.R(0,6,b,0,4)-->[50, 60, 70, 80, 90, 7]
a.R(3,5,b,1,2)-->[0, 1, 2, 60, 70, 6, 7]
a.R(1,6,b,1,2)-->[0, 60, 70, 7]
a.R(0,6,b,1,2)-->[60, 70, 7]
a.R(5,3,b,0,4)-->[0, 1, 2, 3, 4, 50, 60, 70, 80, 90, 5, 6, 7]
a.R(5,0,b,0,4)-->[0, 1, 2, 3, 4, 50, 60, 70, 80, 90, 5, 6, 7]
a.R(5,3,b,1,2)-->[0, 1, 2, 3, 4, 60, 70, 5, 6, 7]
a.R(5,0,b,1,2)-->[0, 1, 2, 3, 4, 60, 70, 5, 6, 7]
Extreme cases:
a.R(5,3,b,0,0)-->[0, 1, 2, 3, 4, 50, 5, 6, 7]
a.R(5,3,b,4,4)-->[0, 1, 2, 3, 4, 90, 5, 6, 7]
a.R(3,5,a,0,1)-->[0, 1, 2, 0, 1, 6, 7]
a.R(3,5,a,3,5)-->[0, 1, 2, 3, 4, 5, 6, 7]
a.R(3,5,a,4,4)-->[0, 1, 2, 4, 6, 7]
a.R(5,3,a,0,4)-->[0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 7]
a.R(0,-1,b,0,4)-->[50, 60, 70, 80, 90, 0, 1, 2, 3, 4, 5, 6, 7]
a.R(0,-1,a,0,4)-->[0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6, 7]
a.R(8,0,a,0,4)-->[0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4]
</pre> |
public void replaceFromWith(int from, java.util.Collection other) {
checkRange(from,size);
java.util.Iterator e = other.iterator();
int index=from;
int limit = Math.min(size-from, other.size());
for (int i=0; i<limit; i++)
elements[index++] = e.next(); //delta
} | Replaces the part of the receiver starting at <code>from</code> (inclusive) with all the elements of the specified collection.
Does not alter the size of the receiver.
Replaces exactly <tt>Math.max(0,Math.min(size()-from, other.size()))</tt> elements.
@param from the index at which to copy the first element from the specified collection.
@param other Collection to replace part of the receiver
@exception IndexOutOfBoundsException index is out of range (index < 0 || index >= size()). |
public void shuffleFromTo(int from, int to) {
if (size == 0) return;
checkRangeFromTo(from, to, size);
//cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date()));
java.util.Random gen = new java.util.Random();
Object tmpElement;
Object[] theElements = elements;
int random;
for (int i = from; i < to; i++) {
//random = gen.nextIntFromTo(i, to);
int rp = gen.nextInt(to-i);
random = rp + i;
//swap(i, random)
tmpElement = theElements[random];
theElements[random] = theElements[i];
theElements[i] = tmpElement;
}
} | Randomly permutes the part of the receiver between <code>from</code> (inclusive) and <code>to</code> (inclusive).
@param from the index of the first element (inclusive) to be permuted.
@param to the index of the last element (inclusive) to be permuted.
@exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). |
public ObjectArrayList times(int times) {
ObjectArrayList newList = new ObjectArrayList(times*size);
for (int i=times; --i >= 0; ) {
newList.addAllOfFromTo(this,0,size()-1);
}
return newList;
} | Returns a list which is a concatenation of <code>times</code> times the receiver.
@param times the number of times the receiver shall be copied. |
public Object[] toArray(Object array[]) {
if (array.length < size)
array = (Object[])java.lang.reflect.Array.newInstance(array.getClass().getComponentType(), size);
Object[] theElements = elements;
for (int i=size; --i >=0; ) array[i]=theElements[i];
if (array.length > size) array[size] = null;
return array;
} | Returns an array containing all of the elements in the receiver in the
correct order. The runtime type of the returned array is that of the
specified array. If the receiver fits in the specified array, it is
returned therein. Otherwise, a new array is allocated with the runtime
type of the specified array and the size of the receiver.
<p>
If the receiver fits in the specified array with room to spare
(i.e., the array has more elements than the receiver),
the element in the array immediately following the end of the
receiver is set to null. This is useful in determining the length
of the receiver <em>only</em> if the caller knows that the receiver
does not contain any null elements.
@param array the array into which the elements of the receiver are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
@return an array containing the elements of the receiver.
@exception ArrayStoreException the runtime type of <tt>array</tt> is not a supertype
of the runtime type of every element in the receiver. |
public java.util.ArrayList toList() {
int mySize = size();
Object[] theElements = elements;
java.util.ArrayList list = new java.util.ArrayList(mySize);
for (int i=0; i < mySize; i++) list.add(theElements[i]);
return list;
}
/**
* Returns a string representation of the receiver, containing
* the String representation of each element.
*/
public String toString() {
return cern.colt.Arrays.toString(partFromTo(0, size()-1).elements());
}
/**
* Trims the capacity of the receiver to be the receiver's current
* size. Releases any superfluos internal memory. An application can use this operation to minimize the
* storage of the receiver.
*/
public void trimToSize() {
elements = cern.colt.Arrays.trimToCapacity(elements,size());
}
} | Returns a <code>java.util.ArrayList</code> containing all the elements in the receiver. |
public static dnspolicy_dnspolicylabel_binding[] get(nitro_service service, String name) throws Exception{
dnspolicy_dnspolicylabel_binding obj = new dnspolicy_dnspolicylabel_binding();
obj.set_name(name);
dnspolicy_dnspolicylabel_binding response[] = (dnspolicy_dnspolicylabel_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch dnspolicy_dnspolicylabel_binding resources of given name . |
public static tmtrafficpolicy_tmglobal_binding[] get(nitro_service service, String name) throws Exception{
tmtrafficpolicy_tmglobal_binding obj = new tmtrafficpolicy_tmglobal_binding();
obj.set_name(name);
tmtrafficpolicy_tmglobal_binding response[] = (tmtrafficpolicy_tmglobal_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch tmtrafficpolicy_tmglobal_binding resources of given name . |
public static clusternodegroup_nslimitidentifier_binding[] get(nitro_service service, String name) throws Exception{
clusternodegroup_nslimitidentifier_binding obj = new clusternodegroup_nslimitidentifier_binding();
obj.set_name(name);
clusternodegroup_nslimitidentifier_binding response[] = (clusternodegroup_nslimitidentifier_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch clusternodegroup_nslimitidentifier_binding resources of given name . |
public static rewritepolicylabel_rewritepolicy_binding[] get(nitro_service service, String labelname) throws Exception{
rewritepolicylabel_rewritepolicy_binding obj = new rewritepolicylabel_rewritepolicy_binding();
obj.set_labelname(labelname);
rewritepolicylabel_rewritepolicy_binding response[] = (rewritepolicylabel_rewritepolicy_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch rewritepolicylabel_rewritepolicy_binding resources of given name . |
public static appfwhtmlerrorpage get(nitro_service service, options option) throws Exception{
appfwhtmlerrorpage obj = new appfwhtmlerrorpage();
appfwhtmlerrorpage[] response = (appfwhtmlerrorpage[])obj.get_resources(service,option);
return response[0];
} | Use this API to fetch all the appfwhtmlerrorpage resources that are configured on netscaler. |
public static appfwhtmlerrorpage get(nitro_service service, String name) throws Exception{
appfwhtmlerrorpage obj = new appfwhtmlerrorpage();
obj.set_name(name);
appfwhtmlerrorpage response = (appfwhtmlerrorpage) obj.get_resource(service);
return response;
} | Use this API to fetch appfwhtmlerrorpage resource of given name . |
public static authenticationvserver_stats[] get(nitro_service service) throws Exception{
authenticationvserver_stats obj = new authenticationvserver_stats();
authenticationvserver_stats[] response = (authenticationvserver_stats[])obj.stat_resources(service);
return response;
} | Use this API to fetch the statistics of all authenticationvserver_stats resources that are configured on netscaler. |
public static authenticationvserver_stats get(nitro_service service, String name) throws Exception{
authenticationvserver_stats obj = new authenticationvserver_stats();
obj.set_name(name);
authenticationvserver_stats response = (authenticationvserver_stats) obj.stat_resource(service);
return response;
} | Use this API to fetch statistics of authenticationvserver_stats resource of given name . |
public static vrid_nsip6_binding[] get(nitro_service service, Long id) throws Exception{
vrid_nsip6_binding obj = new vrid_nsip6_binding();
obj.set_id(id);
vrid_nsip6_binding response[] = (vrid_nsip6_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch vrid_nsip6_binding resources of given name . |
public static servicegroup_stats[] get(nitro_service service, options option) throws Exception{
servicegroup_stats obj = new servicegroup_stats();
servicegroup_stats[] response = (servicegroup_stats[])obj.stat_resources(service,option);
return response;
} | Use this API to fetch the statistics of all servicegroup_stats resources that are configured on netscaler. |
public static servicegroup_stats get(nitro_service service, String servicegroupname) throws Exception{
servicegroup_stats obj = new servicegroup_stats();
obj.set_servicegroupname(servicegroupname);
servicegroup_stats response = (servicegroup_stats) obj.stat_resource(service);
return response;
} | Use this API to fetch statistics of servicegroup_stats resource of given name . |
public static clusterinstance_binding get(nitro_service service, Long clid) throws Exception{
clusterinstance_binding obj = new clusterinstance_binding();
obj.set_clid(clid);
clusterinstance_binding response = (clusterinstance_binding) obj.get_resource(service);
return response;
} | Use this API to fetch clusterinstance_binding resource of given name . |
public static auditmessages[] get(nitro_service service) throws Exception{
auditmessages obj = new auditmessages();
auditmessages[] response = (auditmessages[])obj.get_resources(service);
return response;
} | Use this API to fetch all the auditmessages resources that are configured on netscaler. |
public static auditmessages[] get(nitro_service service, auditmessages_args args) throws Exception{
auditmessages obj = new auditmessages();
options option = new options();
option.set_args(nitro_util.object_to_string_withoutquotes(args));
auditmessages[] response = (auditmessages[])obj.get_resources(service, option);
return response;
} | Use this API to fetch all the auditmessages resources that are configured on netscaler.
This uses auditmessages_args which is a way to provide additional arguments while fetching the resources. |
public static auditmessages[] get_filtered(nitro_service service, String filter) throws Exception{
auditmessages obj = new auditmessages();
options option = new options();
option.set_filter(filter);
auditmessages[] response = (auditmessages[]) obj.getfiltered(service, option);
return response;
} | Use this API to fetch filtered set of auditmessages resources.
filter string should be in JSON format.eg: "port:80,servicetype:HTTP". |
public static cmppolicylabel_policybinding_binding[] get(nitro_service service, String labelname) throws Exception{
cmppolicylabel_policybinding_binding obj = new cmppolicylabel_policybinding_binding();
obj.set_labelname(labelname);
cmppolicylabel_policybinding_binding response[] = (cmppolicylabel_policybinding_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch cmppolicylabel_policybinding_binding resources of given name . |
public static vpnglobal_appcontroller_binding[] get(nitro_service service) throws Exception{
vpnglobal_appcontroller_binding obj = new vpnglobal_appcontroller_binding();
vpnglobal_appcontroller_binding response[] = (vpnglobal_appcontroller_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch a vpnglobal_appcontroller_binding resources. |
public static vpnglobal_appcontroller_binding[] get_filtered(nitro_service service, String filter) throws Exception{
vpnglobal_appcontroller_binding obj = new vpnglobal_appcontroller_binding();
options option = new options();
option.set_filter(filter);
vpnglobal_appcontroller_binding[] response = (vpnglobal_appcontroller_binding[]) obj.getfiltered(service, option);
return response;
} | Use this API to fetch filtered set of vpnglobal_appcontroller_binding resources.
filter string should be in JSON format.eg: "port:80,servicetype:HTTP". |
private static Clique valueOfHelper(int[] relativeIndices) {
// if clique already exists, return that one
Clique c = new Clique();
c.relativeIndices = relativeIndices;
return intern(c);
} | This version assumes relativeIndices array no longer needs to
be copied. Further it is assumed that it has already been
checked or assured by construction that relativeIndices
is sorted. |
private static void checkSorted(int[] sorted) {
for (int i = 0; i < sorted.length-1; i++) {
if (sorted[i] > sorted[i+1]) {
throw new RuntimeException("input must be sorted!");
}
}
} | Parameter validity check. |
public int indexOfRelativeIndex(int relativeIndex) {
for (int i = 0; i < relativeIndices.length; i++) {
if (relativeIndices[i] == relativeIndex) {
return i;
}
}
return -1;
} | For a particular relative index, returns which element in
the Clique it is. For instance, if you created a Clique
c with relativeIndices [-2, -1, 0], then c.indexOfRelativeIndex(-1)
will return 1. If the relative index is not present, it
will return -1. |
public static aaapreauthenticationpolicy_aaaglobal_binding[] get(nitro_service service, String name) throws Exception{
aaapreauthenticationpolicy_aaaglobal_binding obj = new aaapreauthenticationpolicy_aaaglobal_binding();
obj.set_name(name);
aaapreauthenticationpolicy_aaaglobal_binding response[] = (aaapreauthenticationpolicy_aaaglobal_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch aaapreauthenticationpolicy_aaaglobal_binding resources of given name . |
public static base_response restart(nitro_service client) throws Exception {
dbsmonitors restartresource = new dbsmonitors();
return restartresource.perform_operation(client,"restart");
} | Use this API to restart dbsmonitors. |
public static wisite_accessmethod_binding[] get(nitro_service service, String sitepath) throws Exception{
wisite_accessmethod_binding obj = new wisite_accessmethod_binding();
obj.set_sitepath(sitepath);
wisite_accessmethod_binding response[] = (wisite_accessmethod_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch wisite_accessmethod_binding resources of given name . |
public static Pair<String, String> readStringPair(DataInputStream in) {
Pair<String, String> p = new Pair<String, String>();
try {
p.first = in.readUTF();
p.second = in.readUTF();
} catch (Exception e) {
e.printStackTrace();
}
return p;
} | Read a string representation of a Pair from a DataStream.
This might not work correctly unless the pair of objects are of type
<code>String</code>. |
public static <X, Y> Pair<X, Y> makePair(X x, Y y) {
return new Pair<X, Y>(x, y);
} | Returns a Pair constructed from X and Y. Convenience method; the
compiler will disambiguate the classes used for you so that you
don't have to write out potentially long class names. |
public void save(DataOutputStream out) {
try {
out.writeUTF(first.toString());
out.writeUTF(second.toString());
} catch (Exception e) {
e.printStackTrace();
}
} | Write a string representation of a Pair to a DataStream.
The <code>toString()</code> method is called on each of the pair
of objects and a <code>String</code> representation is written.
This might not allow one to recover the pair of objects unless they
are of type <code>String</code>. |
@SuppressWarnings("unchecked")
public int compareTo(Pair<T1,T2> another) {
int comp = ((Comparable<T1>) first()).compareTo(another.first());
if (comp != 0) {
return comp;
} else {
return ((Comparable<T2>) second()).compareTo(another.second());
}
} | Compares this <code>Pair</code> to another object.
If the object is a <code>Pair</code>, this function will work providing
the elements of the <code>Pair</code> are themselves comparable.
It will then return a value based on the pair of objects, where
<code>p > q iff p.first() > q.first() ||
(p.first().equals(q.first()) && p.second() > q.second())</code>.
If the other object is not a <code>Pair</code>, it throws a
<code>ClassCastException</code>.
@param another the <code>Object</code> to be compared.
@return the value <code>0</code> if the argument is a
<code>Pair</code> equal to this <code>Pair</code>; a value less than
<code>0</code> if the argument is a <code>Pair</code>
greater than this <code>Pair</code>; and a value
greater than <code>0</code> if the argument is a
<code>Pair</code> less than this <code>Pair</code>.
@throws ClassCastException if the argument is not a
<code>Pair</code>.
@see java.lang.Comparable |
public static Pair<String, String> stringIntern(Pair<String, String> p) {
return new MutableInternedPair(p);
} | If first and second are Strings, then this returns an MutableInternedPair
where the Strings have been interned, and if this Pair is serialized
and then deserialized, first and second are interned upon
deserialization.
@param p A pair of Strings
@return MutableInternedPair, with same first and second as this. |
public static Pair<String, String> internedStringPair(String first, String second) {
return new MutableInternedPair(first, second);
} | Returns an MutableInternedPair where the Strings have been interned.
This is a factory method for creating an
MutableInternedPair. It requires the arguments to be Strings.
If this Pair is serialized
and then deserialized, first and second are interned upon
deserialization.
<p><i>Note:</i> I put this in thinking that its use might be
faster than calling <code>x = new Pair(a, b).stringIntern()</code>
but it's not really clear whether this is true.
@param first The first object
@param second The second object
@return An MutableInternedPair, with given first and second |
public void prettyLog(RedwoodChannels channels, String description) {
PrettyLogger.log(channels, description, this.asList());
} | {@inheritDoc} |
@Override
protected void doStart() throws Exception
{
log.info("starting...");
super.doStart();
_client = newClient(_serverString);
if (_client == null)
{
throw new IllegalStateException("newClient(" + _serverString + ") returns null.");
}
log.info("use " + _client.getClass().getSimpleName() + " as client factory.");
_client.establish();
log.info("started.");
} | /* ------------------------------------------------------------ |
@Override
protected void doStop() throws Exception
{
log.info("stopping...");
if (_client != null)
{
_client.shutdown();
_client = null;
}
super.doStop();
log.info("stopped.");
} | /* ------------------------------------------------------------ |
public void invalidateAll(final String sessionId)
{
// tell all contexts that may have a session object with this id to
// get rid of them
Handler[] contexts = _server.getChildHandlersByClass(ContextHandler.class);
for (int i = 0; contexts != null && i < contexts.length; i++)
{
SessionHandler sessionHandler = ((ContextHandler) contexts[i]).getChildHandlerByClass(SessionHandler.class);
if (sessionHandler != null)
{
SessionManager manager = sessionHandler.getSessionManager();
if (manager != null && manager instanceof KeyValueStoreSessionManager)
{
((KeyValueStoreSessionManager) manager).invalidateSession(sessionId);
}
}
}
} | /* ------------------------------------------------------------ |
public String getClusterId(final String nodeId)
{
if (nodeId == null)
{
return null;
}
int dot = nodeId.lastIndexOf('.');
return (dot > 0) ? nodeId.substring(0, dot) : nodeId;
} | /* ------------------------------------------------------------ |
public String getNodeId(final String clusterId, final HttpServletRequest request)
{
if (clusterId == null)
{
return null;
}
if (_workerName != null)
{
return clusterId + '.' + _workerName;
}
return clusterId;
} | /* ------------------------------------------------------------ |
public static base_response add(nitro_service client, authenticationradiusaction resource) throws Exception {
authenticationradiusaction addresource = new authenticationradiusaction();
addresource.name = resource.name;
addresource.serverip = resource.serverip;
addresource.serverport = resource.serverport;
addresource.authtimeout = resource.authtimeout;
addresource.radkey = resource.radkey;
addresource.radnasip = resource.radnasip;
addresource.radnasid = resource.radnasid;
addresource.radvendorid = resource.radvendorid;
addresource.radattributetype = resource.radattributetype;
addresource.radgroupsprefix = resource.radgroupsprefix;
addresource.radgroupseparator = resource.radgroupseparator;
addresource.passencoding = resource.passencoding;
addresource.ipvendorid = resource.ipvendorid;
addresource.ipattributetype = resource.ipattributetype;
addresource.accounting = resource.accounting;
addresource.pwdvendorid = resource.pwdvendorid;
addresource.pwdattributetype = resource.pwdattributetype;
addresource.defaultauthenticationgroup = resource.defaultauthenticationgroup;
addresource.callingstationid = resource.callingstationid;
return addresource.add_resource(client);
} | Use this API to add authenticationradiusaction. |
public static base_responses add(nitro_service client, authenticationradiusaction resources[]) throws Exception {
base_responses result = null;
if (resources != null && resources.length > 0) {
authenticationradiusaction addresources[] = new authenticationradiusaction[resources.length];
for (int i=0;i<resources.length;i++){
addresources[i] = new authenticationradiusaction();
addresources[i].name = resources[i].name;
addresources[i].serverip = resources[i].serverip;
addresources[i].serverport = resources[i].serverport;
addresources[i].authtimeout = resources[i].authtimeout;
addresources[i].radkey = resources[i].radkey;
addresources[i].radnasip = resources[i].radnasip;
addresources[i].radnasid = resources[i].radnasid;
addresources[i].radvendorid = resources[i].radvendorid;
addresources[i].radattributetype = resources[i].radattributetype;
addresources[i].radgroupsprefix = resources[i].radgroupsprefix;
addresources[i].radgroupseparator = resources[i].radgroupseparator;
addresources[i].passencoding = resources[i].passencoding;
addresources[i].ipvendorid = resources[i].ipvendorid;
addresources[i].ipattributetype = resources[i].ipattributetype;
addresources[i].accounting = resources[i].accounting;
addresources[i].pwdvendorid = resources[i].pwdvendorid;
addresources[i].pwdattributetype = resources[i].pwdattributetype;
addresources[i].defaultauthenticationgroup = resources[i].defaultauthenticationgroup;
addresources[i].callingstationid = resources[i].callingstationid;
}
result = add_bulk_request(client, addresources);
}
return result;
} | Use this API to add authenticationradiusaction resources. |
public static authenticationradiusaction[] get(nitro_service service) throws Exception{
authenticationradiusaction obj = new authenticationradiusaction();
authenticationradiusaction[] response = (authenticationradiusaction[])obj.get_resources(service);
return response;
} | Use this API to fetch all the authenticationradiusaction resources that are configured on netscaler. |
public static authenticationradiusaction get(nitro_service service, String name) throws Exception{
authenticationradiusaction obj = new authenticationradiusaction();
obj.set_name(name);
authenticationradiusaction response = (authenticationradiusaction) obj.get_resource(service);
return response;
} | Use this API to fetch authenticationradiusaction resource of given name . |
public static authenticationradiusaction[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception{
authenticationradiusaction obj = new authenticationradiusaction();
options option = new options();
option.set_filter(filter);
authenticationradiusaction[] response = (authenticationradiusaction[]) obj.getfiltered(service, option);
return response;
} | Use this API to fetch filtered set of authenticationradiusaction resources.
set the filter parameter values in filtervalue object. |
public void prepare(ResponseBuilder rb, ComponentFields mtasFields)
throws IOException {
Set<String> ids = MtasSolrResultUtil
.getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_GROUP);
if (!ids.isEmpty()) {
int tmpCounter = 0;
String[] fields = new String[ids.size()];
String[] queryTypes = new String[ids.size()];
String[] queryValues = new String[ids.size()];
String[] queryPrefixes = new String[ids.size()];
String[] queryIgnores = new String[ids.size()];
String[] queryMaximumIgnoreLengths = new String[ids.size()];
HashMap<String, String[]>[] queryVariables = new HashMap[ids.size()];
String[] keys = new String[ids.size()];
String[] numbers = new String[ids.size()];
String[] starts = new String[ids.size()];
String[][] groupingLeftPosition = new String[ids.size()][];
String[][] groupingLeftPrefixes = new String[ids.size()][];
String[][] groupingRightPosition = new String[ids.size()][];
String[][] groupingRightPrefixes = new String[ids.size()][];
String[] groupingHitInsidePrefixes = new String[ids.size()];
String[][] groupingHitLeftPosition = new String[ids.size()][];
String[][] groupingHitLeftPrefixes = new String[ids.size()][];
String[][] groupingHitRightPosition = new String[ids.size()][];
String[][] groupingHitRightPrefixes = new String[ids.size()][];
String[][] groupingHitInsideLeftPosition = new String[ids.size()][];
String[][] groupingHitInsideLeftPrefixes = new String[ids.size()][];
String[][] groupingHitInsideRightPosition = new String[ids.size()][];
String[][] groupingHitInsideRightPrefixes = new String[ids.size()][];
for (String id : ids) {
fields[tmpCounter] = rb.req.getParams().get(
PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_FIELD, null);
keys[tmpCounter] = rb.req.getParams()
.get(PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_KEY,
String.valueOf(tmpCounter))
.trim();
numbers[tmpCounter] = rb.req.getParams().get(
PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_NUMBER, null);
starts[tmpCounter] = rb.req.getParams().get(
PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_START, null);
queryTypes[tmpCounter] = rb.req.getParams().get(
PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_QUERY_TYPE,
null);
queryValues[tmpCounter] = rb.req.getParams().get(
PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_QUERY_VALUE,
null);
queryPrefixes[tmpCounter] = rb.req.getParams().get(
PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_QUERY_PREFIX,
null);
queryIgnores[tmpCounter] = rb.req.getParams().get(
PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_QUERY_IGNORE,
null);
queryMaximumIgnoreLengths[tmpCounter] = rb.req.getParams()
.get(PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_QUERY_MAXIMUM_IGNORE_LENGTH, null);
Set<String> vIds = MtasSolrResultUtil.getIdsFromParameters(
rb.req.getParams(),
PARAM_MTAS_GROUP + "." + id + "." + NAME_MTAS_GROUP_QUERY_VARIABLE);
queryVariables[tmpCounter] = new HashMap<>();
if (!vIds.isEmpty()) {
HashMap<String, ArrayList<String>> tmpVariables = new HashMap<>();
for (String vId : vIds) {
String name = rb.req.getParams()
.get(PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_QUERY_VARIABLE + "." + vId + "."
+ SUBNAME_MTAS_GROUP_QUERY_VARIABLE_NAME, null);
if (name != null) {
if (!tmpVariables.containsKey(name)) {
tmpVariables.put(name, new ArrayList<String>());
}
String value = rb.req.getParams()
.get(PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_QUERY_VARIABLE + "." + vId + "."
+ SUBNAME_MTAS_GROUP_QUERY_VARIABLE_VALUE, null);
if (value != null) {
ArrayList<String> list = new ArrayList<>();
String[] subList = value.split("(?<!\\\\),");
for (int i = 0; i < subList.length; i++) {
list.add(
subList[i].replace("\\,", ",").replace("\\\\", "\\"));
}
tmpVariables.get(name).addAll(list);
}
}
}
for (Entry<String, ArrayList<String>> entry : tmpVariables
.entrySet()) {
queryVariables[tmpCounter].put(entry.getKey(),
entry.getValue().toArray(new String[entry.getValue().size()]));
}
}
groupingHitInsidePrefixes[tmpCounter] = null;
// collect
SortedSet<String> gids;
String tmpName;
// collect grouping inside
tmpName = PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE;
groupingHitInsidePrefixes[tmpCounter] = rb.req.getParams()
.get(tmpName + "." + NAME_MTAS_GROUP_GROUPING_PREFIXES);
// collect grouping left
tmpName = PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_GROUPING_LEFT;
gids = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
tmpName);
groupingLeftPosition[tmpCounter] = new String[gids.size()];
groupingLeftPrefixes[tmpCounter] = new String[gids.size()];
prepare(rb.req.getParams(), gids, tmpName,
groupingLeftPosition[tmpCounter], groupingLeftPrefixes[tmpCounter]);
// collect grouping right
tmpName = PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_GROUPING_RIGHT;
gids = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
tmpName);
groupingRightPosition[tmpCounter] = new String[gids.size()];
groupingRightPrefixes[tmpCounter] = new String[gids.size()];
prepare(rb.req.getParams(), gids, tmpName,
groupingRightPosition[tmpCounter],
groupingRightPrefixes[tmpCounter]);
// collect grouping hit left
tmpName = PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_LEFT;
gids = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
tmpName);
groupingHitLeftPosition[tmpCounter] = new String[gids.size()];
groupingHitLeftPrefixes[tmpCounter] = new String[gids.size()];
prepare(rb.req.getParams(), gids, tmpName,
groupingHitLeftPosition[tmpCounter],
groupingHitLeftPrefixes[tmpCounter]);
// collect grouping hit right
tmpName = PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_RIGHT;
gids = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
tmpName);
groupingHitRightPosition[tmpCounter] = new String[gids.size()];
groupingHitRightPrefixes[tmpCounter] = new String[gids.size()];
prepare(rb.req.getParams(), gids, tmpName,
groupingHitRightPosition[tmpCounter],
groupingHitRightPrefixes[tmpCounter]);
// collect grouping hit inside left
tmpName = PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE_LEFT;
gids = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
tmpName);
groupingHitInsideLeftPosition[tmpCounter] = new String[gids.size()];
groupingHitInsideLeftPrefixes[tmpCounter] = new String[gids.size()];
prepare(rb.req.getParams(), gids, tmpName,
groupingHitInsideLeftPosition[tmpCounter],
groupingHitInsideLeftPrefixes[tmpCounter]);
// collect grouping hit inside right
tmpName = PARAM_MTAS_GROUP + "." + id + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE_RIGHT;
gids = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
tmpName);
groupingHitInsideRightPosition[tmpCounter] = new String[gids.size()];
groupingHitInsideRightPrefixes[tmpCounter] = new String[gids.size()];
prepare(rb.req.getParams(), gids, tmpName,
groupingHitInsideRightPosition[tmpCounter],
groupingHitInsideRightPrefixes[tmpCounter]);
tmpCounter++;
}
String uniqueKeyField = rb.req.getSchema().getUniqueKeyField().getName();
mtasFields.doGroup = true;
rb.setNeedDocSet(true);
for (String field : fields) {
if (field == null || field.isEmpty()) {
throw new IOException("no (valid) field in mtas group");
} else if (!mtasFields.list.containsKey(field)) {
mtasFields.list.put(field, new ComponentField(uniqueKeyField));
}
}
MtasSolrResultUtil.compareAndCheck(keys, fields, NAME_MTAS_GROUP_KEY,
NAME_MTAS_GROUP_FIELD, true);
MtasSolrResultUtil.compareAndCheck(queryValues, fields,
NAME_MTAS_GROUP_QUERY_VALUE, NAME_MTAS_GROUP_FIELD, false);
MtasSolrResultUtil.compareAndCheck(queryTypes, fields,
NAME_MTAS_GROUP_QUERY_TYPE, NAME_MTAS_GROUP_FIELD, false);
for (int i = 0; i < fields.length; i++) {
ComponentField cf = mtasFields.list.get(fields[i]);
Integer maximumIgnoreLength = (queryMaximumIgnoreLengths[i] == null)
? null : Integer.parseInt(queryMaximumIgnoreLengths[i]);
MtasSpanQuery q = MtasSolrResultUtil.constructQuery(queryValues[i],
queryTypes[i], queryPrefixes[i], queryVariables[i], fields[i],
queryIgnores[i], maximumIgnoreLength);
// minimize number of queries
if (cf.spanQueryList.contains(q)) {
q = cf.spanQueryList.get(cf.spanQueryList.indexOf(q));
} else {
cf.spanQueryList.add(q);
}
String key = (keys[i] == null) || (keys[i].isEmpty())
? String.valueOf(i) + ":" + fields[i] + ":" + queryValues[i]
: keys[i].trim();
int number = (numbers[i] == null) || (numbers[i].isEmpty())
? DEFAULT_NUMBER : Integer.parseInt(numbers[i]);
int start = (starts[i] == null) || (starts[i].isEmpty()) ? 0
: Integer.parseInt(starts[i]);
mtasFields.list.get(fields[i]).groupList.add(new ComponentGroup(q, key,
number, start, groupingHitInsidePrefixes[i],
groupingHitInsideLeftPosition[i], groupingHitInsideLeftPrefixes[i],
groupingHitInsideRightPosition[i],
groupingHitInsideRightPrefixes[i], groupingHitLeftPosition[i],
groupingHitLeftPrefixes[i], groupingHitRightPosition[i],
groupingHitRightPrefixes[i], groupingLeftPosition[i],
groupingLeftPrefixes[i], groupingRightPosition[i],
groupingRightPrefixes[i]));
}
}
} | /*
(non-Javadoc)
@see
mtas.solr.handler.component.util.MtasSolrComponent#prepare(org.apache.solr.
handler.component.ResponseBuilder,
mtas.codec.util.CodecComponent.ComponentFields) |
@SuppressWarnings("unchecked")
public SimpleOrderedMap<Object> create(ComponentGroup group, Boolean encode)
throws IOException {
SimpleOrderedMap<Object> mtasGroupResponse = new SimpleOrderedMap<>();
mtasGroupResponse.add("key", group.key);
MtasSolrMtasResult data = new MtasSolrMtasResult(group.dataCollector,
new String[] { group.dataType }, new String[] { group.statsType },
new SortedSet[] { group.statsItems }, new List[] { null },
new String[] { group.sortType }, new String[] { group.sortDirection },
new Integer[] { group.start }, new Integer[] { group.number }, null);
if (encode) {
mtasGroupResponse.add("_encoded_list", MtasSolrResultUtil.encode(data));
} else {
mtasGroupResponse.add("list", data);
MtasSolrResultUtil.rewrite(mtasGroupResponse, searchComponent);
}
return mtasGroupResponse;
} | /*
(non-Javadoc)
@see
mtas.solr.handler.component.util.MtasSolrComponent#create(mtas.codec.util.
CodecComponent.BasicComponent, java.lang.Boolean) |
private void prepare(SolrParams solrParams, SortedSet<String> gids,
String name, String[] positions, String[] prefixes) throws IOException {
if (!gids.isEmpty()) {
int tmpSubCounter = 0;
for (String gid : gids) {
positions[tmpSubCounter] = solrParams.get(
name + "." + gid + "." + NAME_MTAS_GROUP_GROUPING_POSITION, null);
prefixes[tmpSubCounter] = solrParams.get(
name + "." + gid + "." + NAME_MTAS_GROUP_GROUPING_PREFIXES, null);
if (positions[tmpSubCounter] == null) {
throw new IOException("no position for " + gid);
} else if (prefixes[tmpSubCounter] == null) {
throw new IOException("no prefix for " + gid);
}
tmpSubCounter++;
}
}
} | Prepare.
@param solrParams the solr params
@param gids the gids
@param name the name
@param positions the positions
@param prefixes the prefixes
@throws IOException Signals that an I/O exception has occurred. |
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
ShardRequest sreq) {
if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
&& sreq.params.getBool(PARAM_MTAS_GROUP, false)) {
if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {
// do nothing
// Set<String> keys = MtasSolrResultUtil
// .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_GROUP);
// for (String key : keys) {
// sreq.params.remove(
// PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_NUMBER);
// sreq.params.remove(
// PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_START);
// }
} else {
// remove prefix for other requests
Set<String> keys = MtasSolrResultUtil
.getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_GROUP);
sreq.params.remove(PARAM_MTAS_GROUP);
Set<String> subKeys;
for (String key : keys) {
sreq.params.remove(
PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_FIELD);
sreq.params
.remove(PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_KEY);
sreq.params.remove(
PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_NUMBER);
sreq.params.remove(
PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_START);
sreq.params.remove(
PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_QUERY_TYPE);
sreq.params.remove(
PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_QUERY_VALUE);
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_QUERY_PREFIX);
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_QUERY_IGNORE);
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_QUERY_MAXIMUM_IGNORE_LENGTH);
subKeys = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_LEFT);
for (String subKey : subKeys) {
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_LEFT + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_POSITION);
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_LEFT + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_PREFIXES);
}
subKeys = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_RIGHT);
for (String subKey : subKeys) {
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_RIGHT + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_POSITION);
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_RIGHT + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_PREFIXES);
}
subKeys = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE);
for (String subKey : subKeys) {
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_POSITION);
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_PREFIXES);
}
subKeys = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE_LEFT);
for (String subKey : subKeys) {
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE_LEFT + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_POSITION);
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE_LEFT + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_PREFIXES);
}
subKeys = MtasSolrResultUtil.getIdsFromParameters(rb.req.getParams(),
PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE_RIGHT);
for (String subKey : subKeys) {
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE_RIGHT + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_POSITION);
sreq.params.remove(PARAM_MTAS_GROUP + "." + key + "."
+ NAME_MTAS_GROUP_GROUPING_HIT_INSIDE_RIGHT + "." + subKey + "."
+ NAME_MTAS_GROUP_GROUPING_PREFIXES);
}
}
}
}
} | /*
(non-Javadoc)
@see
mtas.solr.handler.component.util.MtasSolrComponent#modifyRequest(org.apache
.solr.handler.component.ResponseBuilder,
org.apache.solr.handler.component.SearchComponent,
org.apache.solr.handler.component.ShardRequest) |
@SuppressWarnings("unchecked")
public void distributedProcess(ResponseBuilder rb, ComponentFields mtasFields)
throws IOException {
// rewrite
NamedList<Object> mtasResponse = null;
try {
mtasResponse = (NamedList<Object>) rb.rsp.getValues().get("mtas");
} catch (ClassCastException e) {
log.debug(e);
mtasResponse = null;
}
if (mtasResponse != null) {
ArrayList<Object> mtasResponseGroup;
try {
mtasResponseGroup = (ArrayList<Object>) mtasResponse.get(NAME);
if (mtasResponseGroup != null) {
MtasSolrResultUtil.rewrite(mtasResponseGroup, searchComponent);
}
} catch (ClassCastException e) {
log.debug(e);
mtasResponse.remove(NAME);
}
}
} | /*
(non-Javadoc)
@see
mtas.solr.handler.component.util.MtasSolrComponent#distributedProcess(org.
apache.solr.handler.component.ResponseBuilder,
mtas.codec.util.CodecComponent.ComponentFields) |
public static sslcertkey_sslvserver_binding[] get(nitro_service service, String certkey) throws Exception{
sslcertkey_sslvserver_binding obj = new sslcertkey_sslvserver_binding();
obj.set_certkey(certkey);
sslcertkey_sslvserver_binding response[] = (sslcertkey_sslvserver_binding[]) obj.get_resources(service);
return response;
} | Use this API to fetch sslcertkey_sslvserver_binding resources of given name . |
private double getConstraint(double x1, double x2)
{
double c1,c2,h;
c1 = -x1*x1-x2*x2+1+0.1*Math.cos(16*Math.atan(x1/x2));
c2 = (x1-0.5)*(x1-0.5)+(x2-0.5)*(x2-0.5)-0.5;
if(c1>c2)
h = (c1>0)?c1:0;
else
h = (c2>0)?c2:0;
return h;
} | use the design parameters to compute the constraint equation to get the value |
public static lbvserver_stats[] get(nitro_service service) throws Exception{
lbvserver_stats obj = new lbvserver_stats();
lbvserver_stats[] response = (lbvserver_stats[])obj.stat_resources(service);
return response;
} | Use this API to fetch the statistics of all lbvserver_stats resources that are configured on netscaler. |
public static lbvserver_stats get(nitro_service service, String name) throws Exception{
lbvserver_stats obj = new lbvserver_stats();
obj.set_name(name);
lbvserver_stats response = (lbvserver_stats) obj.stat_resource(service);
return response;
} | Use this API to fetch statistics of lbvserver_stats resource of given name . |
@Override
final protected void addRangeEmpty(int left, int right, int additionalId,
long additionalRef) {
String key = left + "_" + right;
if (index.containsKey(key)) {
// do nothing (empty...)
} else {
root = addRange(root, left, right, additionalId, additionalRef, null,
null);
root.color = MtasRBTreeNode.BLACK;
}
} | /*
(non-Javadoc)
@see mtas.codec.tree.MtasTree#addRangeEmpty(int, int) |
Subsets and Splits