code
stringlengths 11
173k
| docstring
stringlengths 2
593k
| func_name
stringlengths 2
189
| language
stringclasses 1
value | repo
stringclasses 833
values | path
stringlengths 11
294
| url
stringlengths 60
339
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public static String valueOf(char c) {
return null;
} |
Returns the string representation of the {@code char}
argument.
@param c a {@code char}.
@return a string of length {@code 1} containing
as its single character the argument {@code c}.
| CaseInsensitiveComparator::valueOf | java | google/j2objc | jre_emul/stub_classes/java/java/lang/String.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/String.java | Apache-2.0 |
public static String valueOf(int i) {
return null;
} |
Returns the string representation of the {@code int} argument.
<p>
The representation is exactly the one returned by the
{@code Integer.toString} method of one argument.
@param i an {@code int}.
@return a string representation of the {@code int} argument.
@see java.lang.Integer#toString(int, int)
| CaseInsensitiveComparator::valueOf | java | google/j2objc | jre_emul/stub_classes/java/java/lang/String.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/String.java | Apache-2.0 |
public static String valueOf(long l) {
return null;
} |
Returns the string representation of the {@code long} argument.
<p>
The representation is exactly the one returned by the
{@code Long.toString} method of one argument.
@param l a {@code long}.
@return a string representation of the {@code long} argument.
@see java.lang.Long#toString(long)
| CaseInsensitiveComparator::valueOf | java | google/j2objc | jre_emul/stub_classes/java/java/lang/String.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/String.java | Apache-2.0 |
public static String valueOf(float f) {
return null;
} |
Returns the string representation of the {@code float} argument.
<p>
The representation is exactly the one returned by the
{@code Float.toString} method of one argument.
@param f a {@code float}.
@return a string representation of the {@code float} argument.
@see java.lang.Float#toString(float)
| CaseInsensitiveComparator::valueOf | java | google/j2objc | jre_emul/stub_classes/java/java/lang/String.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/String.java | Apache-2.0 |
public static String valueOf(double d) {
return null;
} |
Returns the string representation of the {@code double} argument.
<p>
The representation is exactly the one returned by the
{@code Double.toString} method of one argument.
@param d a {@code double}.
@return a string representation of the {@code double} argument.
@see java.lang.Double#toString(double)
| CaseInsensitiveComparator::valueOf | java | google/j2objc | jre_emul/stub_classes/java/java/lang/String.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/String.java | Apache-2.0 |
public String intern() {
return null;
} |
Returns a canonical representation for the string object.
<p>
A pool of strings, initially empty, is maintained privately by the
class {@code String}.
<p>
When the intern method is invoked, if the pool already contains a
string equal to this {@code String} object as determined by
the {@link #equals(Object)} method, then the string from the pool is
returned. Otherwise, this {@code String} object is added to the
pool and a reference to this {@code String} object is returned.
<p>
It follows that for any two strings {@code s} and {@code t},
{@code s.intern() == t.intern()} is {@code true}
if and only if {@code s.equals(t)} is {@code true}.
<p>
All literal strings and string-valued constant expressions are
interned. String literals are defined in section 3.10.5 of the
<cite>The Java™ Language Specification</cite>.
@return a string that has the same contents as this string, but is
guaranteed to be from a pool of unique strings.
@jls 3.10.5 String Literals
| CaseInsensitiveComparator::intern | java | google/j2objc | jre_emul/stub_classes/java/java/lang/String.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/String.java | Apache-2.0 |
public String repeat(int count) {
return null;
} |
Returns a string whose value is the concatenation of this
string repeated {@code count} times.
<p>
If this string is empty or count is zero then the empty
string is returned.
@param count number of times to repeat
@return A string composed of this string repeated
{@code count} times or the empty string if this
string is empty or count is zero
@throws IllegalArgumentException if the {@code count} is
negative.
@since 11
| CaseInsensitiveComparator::repeat | java | google/j2objc | jre_emul/stub_classes/java/java/lang/String.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/String.java | Apache-2.0 |
public Object() {} |
Constructs a new instance of {@code Object}.
| Object::Object | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public final Class<?> getClass() {
return null;
} |
Returns the unique instance of {@link Class} that represents this
object's class. Note that {@code getClass()} is a special case in that it
actually returns {@code Class<? extends Foo>} where {@code Foo} is the
erasure of the type of the expression {@code getClass()} was called upon.
<p>
As an example, the following code actually compiles, although one might
think it shouldn't:
<p>
<pre>{@code
List<Integer> l = new ArrayList<Integer>();
Class<? extends List> c = l.getClass();}</pre>
@return this object's {@code Class} instance.
| Object::getClass | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public int hashCode() {
return 0;
} |
Returns an integer hash code for this object. By contract, any two
objects for which {@link #equals} returns {@code true} must return
the same hash code value. This means that subclasses of {@code Object}
usually override both methods or neither method.
<p>Note that hash values must not change over time unless information used in equals
comparisons also changes.
<p>See <a href="{@docRoot}reference/java/lang/Object.html#writing_hashCode">Writing a correct
{@code hashCode} method</a>
if you intend implementing your own {@code hashCode} method.
@return this object's hash code.
@see #equals
| Object::hashCode | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public boolean equals(Object obj) {
return false;
} |
Compares this instance with the specified object and indicates if they
are equal. In order to be equal, {@code o} must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
<p>The default implementation returns {@code true} only if {@code this ==
o}. See <a href="{@docRoot}reference/java/lang/Object.html#writing_equals">Writing a correct
{@code equals} method</a>
if you intend implementing your own {@code equals} method.
<p>The general contract for the {@code equals} and {@link
#hashCode()} methods is that if {@code equals} returns {@code true} for
any two objects, then {@code hashCode()} must return the same value for
these objects. This means that subclasses of {@code Object} usually
override either both methods or neither of them.
@param obj
the object to compare this instance with.
@return {@code true} if the specified object is equal to this {@code
Object}; {@code false} otherwise.
@see #hashCode
| Object::equals | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
protected Object clone() throws CloneNotSupportedException {
return null;
} |
Creates and returns a copy of this {@code Object}. The default
implementation returns a so-called "shallow" copy: It creates a new
instance of the same class and then copies the field values (including
object references) from this instance to the new instance. A "deep" copy,
in contrast, would also recursively clone nested objects. A subclass that
needs to implement this kind of cloning should call {@code super.clone()}
to create the new instance and then create deep copies of the nested,
mutable objects.
@return a copy of this object.
@throws CloneNotSupportedException
if this object's class does not implement the {@code
Cloneable} interface.
| Object::clone | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
protected void finalize() throws Throwable {} |
Invoked when the garbage collector has detected that this instance is no longer reachable.
The default implementation does nothing, but this method can be overridden to free resources.
<p>Note that objects that override {@code finalize} are significantly more expensive than
objects that don't. Finalizers may be run a long time after the object is no longer
reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup.
Note also that finalizers are run on a single VM-wide finalizer thread,
so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary
for a class that has a native peer and needs to call a native method to destroy that peer.
Even then, it's better to provide an explicit {@code close} method (and implement
{@link java.io.Closeable}), and insist that callers manually dispose of instances. This
works well for something like files, but less well for something like a {@code BigInteger}
where typical calling code would have to deal with lots of temporaries. Unfortunately,
code that creates lots of temporaries is the worst kind of code from the point of view of
the single finalizer thread.
<p>If you <i>must</i> use finalizers, consider at least providing your own
{@link java.lang.ref.ReferenceQueue} and having your own thread process that queue.
<p>Unlike constructors, finalizers are not automatically chained. You are responsible for
calling {@code super.finalize()} yourself.
<p>Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer
thread.
See <i>Effective Java</i> Item 7, "Avoid finalizers" for more.
| Object::finalize | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public final void notify() {} |
Causes a thread which is waiting on this object's monitor (by means of
calling one of the {@code wait()} methods) to be woken up. If more than
one thread is waiting, one of them is chosen at the discretion of the
VM. The chosen thread will not run immediately. The thread
that called {@code notify()} has to release the object's monitor first.
Also, the chosen thread still has to compete against other threads that
try to synchronize on the same object.
<p>This method can only be invoked by a thread which owns this object's
monitor. A thread becomes owner of an object's monitor
<ul>
<li>by executing a synchronized method of that object;</li>
<li>by executing the body of a {@code synchronized} statement that
synchronizes on the object;</li>
<li>by executing a synchronized static method if the object is of type
{@code Class}.</li>
</ul>
@see #notifyAll
@see #wait()
@see #wait(long)
@see #wait(long,int)
@see java.lang.Thread
| Object::notify | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public final void notifyAll() {} |
Causes all threads which are waiting on this object's monitor (by means
of calling one of the {@code wait()} methods) to be woken up. The threads
will not run immediately. The thread that called {@code notify()} has to
release the object's monitor first. Also, the threads still have to
compete against other threads that try to synchronize on the same object.
<p>This method can only be invoked by a thread which owns this object's
monitor. A thread becomes owner of an object's monitor
<ul>
<li>by executing a synchronized method of that object;</li>
<li>by executing the body of a {@code synchronized} statement that
synchronizes on the object;</li>
<li>by executing a synchronized static method if the object is of type
{@code Class}.</li>
</ul>
@throws IllegalMonitorStateException
if the thread calling this method is not the owner of this
object's monitor.
@see #notify
@see #wait()
@see #wait(long)
@see #wait(long,int)
@see java.lang.Thread
| Object::notifyAll | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public final void wait(long timeout) throws InterruptedException {} |
Causes the calling thread to wait until another thread calls the {@code
notify()} or {@code notifyAll()} method of this object or until the
specified timeout expires. This method can only be invoked by a thread
which owns this object's monitor; see {@link #notify()} on how a thread
can become the owner of a monitor.
<p>A waiting thread can be sent {@code interrupt()} to cause it to
prematurely stop waiting, so {@code wait} should be called in a loop to
check that the condition that has been waited for has been met before
continuing.
<p>While the thread waits, it gives up ownership of this object's
monitor. When it is notified (or interrupted), it re-acquires the monitor
before it starts running.
<p>A timeout of zero means the calling thread should wait forever unless interrupted or
notified.
@param timeout
the maximum time to wait in milliseconds.
@throws IllegalArgumentException
if {@code millis < 0}.
@throws IllegalMonitorStateException
if the thread calling this method is not the owner of this
object's monitor.
@throws InterruptedException if the current thread has been interrupted.
The interrupted status of the current thread will be cleared before the exception
is thrown.
@see #notify
@see #notifyAll
@see #wait()
@see #wait(long,int)
@see java.lang.Thread
| Object::wait | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public final void wait(long timeout, int nanos) throws InterruptedException {} |
Causes the calling thread to wait until another thread calls the {@code
notify()} or {@code notifyAll()} method of this object or until the
specified timeout expires. This method can only be invoked by a thread
that owns this object's monitor; see {@link #notify()} on how a thread
can become the owner of a monitor.
<p>A waiting thread can be sent {@code interrupt()} to cause it to
prematurely stop waiting, so {@code wait} should be called in a loop to
check that the condition that has been waited for has been met before
continuing.
<p>While the thread waits, it gives up ownership of this object's
monitor. When it is notified (or interrupted), it re-acquires the monitor
before it starts running.
<p>A timeout of zero means the calling thread should wait forever unless interrupted or
notified.
@param timeout
the maximum time to wait in milliseconds.
@param nanos
the fraction of a millisecond to wait, specified in
nanoseconds.
@throws IllegalArgumentException
if {@code millis < 0}, {@code nanos < 0} or {@code nanos >
999999}.
@throws IllegalMonitorStateException
if the thread calling this method is not the owner of this
object's monitor.
@throws InterruptedException if the current thread has been interrupted.
The interrupted status of the current thread will be cleared before the exception
is thrown.
@see #notify
@see #notifyAll
@see #wait()
@see #wait(long,int)
@see java.lang.Thread
| Object::wait | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public final void wait() throws InterruptedException {} |
Causes the calling thread to wait until another thread calls the {@code
notify()} or {@code notifyAll()} method of this object. This method can
only be invoked by a thread which owns this object's monitor; see
{@link #notify()} on how a thread can become the owner of a monitor.
<p>A waiting thread can be sent {@code interrupt()} to cause it to
prematurely stop waiting, so {@code wait} should be called in a loop to
check that the condition that has been waited for has been met before
continuing.
<p>While the thread waits, it gives up ownership of this object's
monitor. When it is notified (or interrupted), it re-acquires the monitor
before it starts running.
@throws IllegalMonitorStateException
if the thread calling this method is not the owner of this
object's monitor.
@throws InterruptedException if the current thread has been interrupted.
The interrupted status of the current thread will be cleared before the exception
is thrown.
@see #notify
@see #notifyAll
@see #wait(long)
@see #wait(long,int)
@see java.lang.Thread
| Object::wait | java | google/j2objc | jre_emul/stub_classes/java/java/lang/Object.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/Object.java | Apache-2.0 |
public String getName() {
return null;
} |
Returns the name of the field represented by this {@code Field} object.
| Field::getName | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public Class<?> getType() {
return null;
} |
Returns a {@code Class} object that identifies the
declared type for the field represented by this
{@code Field} object.
@return a {@code Class} object identifying the declared
type of the field represented by this object
| Field::getType | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public Type getGenericType() {
return null;
} |
Returns a {@code Type} object that represents the declared type for
the field represented by this {@code Field} object.
<p>If the {@code Type} is a parameterized type, the
{@code Type} object returned must accurately reflect the
actual type parameters used in the source code.
<p>If the type of the underlying field is a type variable or a
parameterized type, it is created. Otherwise, it is resolved.
@return a {@code Type} object that represents the declared type for
the field represented by this {@code Field} object
@throws GenericSignatureFormatError if the generic field
signature does not conform to the format specified in
<cite>The Java™ Virtual Machine Specification</cite>
@throws TypeNotPresentException if the generic type
signature of the underlying field refers to a non-existent
type declaration
@throws MalformedParameterizedTypeException if the generic
signature of the underlying field refers to a parameterized type
that cannot be instantiated for any reason
@since 1.5
| Field::getGenericType | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public Object get(Object obj) throws IllegalArgumentException, IllegalAccessException {
return null;
} |
Returns the value of the field represented by this {@code Field}, on
the specified object. The value is automatically wrapped in an
object if it has a primitive type.
<p>The underlying field's value is obtained as follows:
<p>If the underlying field is a static field, the {@code obj} argument
is ignored; it may be null.
<p>Otherwise, the underlying field is an instance field. If the
specified {@code obj} argument is null, the method throws a
{@code NullPointerException}. If the specified object is not an
instance of the class or interface declaring the underlying
field, the method throws an {@code IllegalArgumentException}.
<p>If this {@code Field} object is enforcing Java language access control, and
the underlying field is inaccessible, the method throws an
{@code IllegalAccessException}.
If the underlying field is static, the class that declared the
field is initialized if it has not already been initialized.
<p>Otherwise, the value is retrieved from the underlying instance
or static field. If the field has a primitive type, the value
is wrapped in an object before being returned, otherwise it is
returned as is.
<p>If the field is hidden in the type of {@code obj},
the field's value is obtained according to the preceding rules.
@param obj object from which the represented field's value is
to be extracted
@return the value of the represented field in object
{@code obj}; primitive values are wrapped in an appropriate
object before being returned
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof).
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
| Field::get | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public boolean getBoolean(Object obj) throws IllegalArgumentException, IllegalAccessException {
return false;
} |
Gets the value of a static or instance {@code boolean} field.
@param obj the object to extract the {@code boolean} value
from
@return the value of the {@code boolean} field
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not
an instance of the class or interface declaring the
underlying field (or a subclass or implementor
thereof), or if the field value cannot be
converted to the type {@code boolean} by a
widening conversion.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#get
| Field::getBoolean | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public byte getByte(Object obj) throws IllegalArgumentException, IllegalAccessException {
return 0;
} |
Gets the value of a static or instance {@code byte} field.
@param obj the object to extract the {@code byte} value
from
@return the value of the {@code byte} field
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not
an instance of the class or interface declaring the
underlying field (or a subclass or implementor
thereof), or if the field value cannot be
converted to the type {@code byte} by a
widening conversion.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#get
| Field::getByte | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public char getChar(Object obj) throws IllegalArgumentException, IllegalAccessException {
return 0;
} |
Gets the value of a static or instance field of type
{@code char} or of another primitive type convertible to
type {@code char} via a widening conversion.
@param obj the object to extract the {@code char} value
from
@return the value of the field converted to type {@code char}
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not
an instance of the class or interface declaring the
underlying field (or a subclass or implementor
thereof), or if the field value cannot be
converted to the type {@code char} by a
widening conversion.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#get
| Field::getChar | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public double getDouble(Object obj) throws IllegalArgumentException, IllegalAccessException {
return 0.0;
} |
Gets the value of a static or instance field of type
{@code double} or of another primitive type convertible to
type {@code double} via a widening conversion.
@param obj the object to extract the {@code double} value
from
@return the value of the field converted to type {@code double}
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not
an instance of the class or interface declaring the
underlying field (or a subclass or implementor
thereof), or if the field value cannot be
converted to the type {@code double} by a
widening conversion.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#get
| Field::getDouble | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public float getFloat(Object obj) throws IllegalArgumentException, IllegalAccessException {
return 0.0f;
} |
Gets the value of a static or instance field of type
{@code float} or of another primitive type convertible to
type {@code float} via a widening conversion.
@param obj the object to extract the {@code float} value
from
@return the value of the field converted to type {@code float}
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not
an instance of the class or interface declaring the
underlying field (or a subclass or implementor
thereof), or if the field value cannot be
converted to the type {@code float} by a
widening conversion.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#get
| Field::getFloat | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public int getInt(Object obj) throws IllegalArgumentException, IllegalAccessException {
return 0;
} |
Gets the value of a static or instance field of type
{@code int} or of another primitive type convertible to
type {@code int} via a widening conversion.
@param obj the object to extract the {@code int} value
from
@return the value of the field converted to type {@code int}
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not
an instance of the class or interface declaring the
underlying field (or a subclass or implementor
thereof), or if the field value cannot be
converted to the type {@code int} by a
widening conversion.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#get
| Field::getInt | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public long getLong(Object obj) throws IllegalArgumentException, IllegalAccessException {
return 0L;
} |
Gets the value of a static or instance field of type
{@code long} or of another primitive type convertible to
type {@code long} via a widening conversion.
@param obj the object to extract the {@code long} value
from
@return the value of the field converted to type {@code long}
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not
an instance of the class or interface declaring the
underlying field (or a subclass or implementor
thereof), or if the field value cannot be
converted to the type {@code long} by a
widening conversion.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#get
| Field::getLong | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public short getShort(Object obj) throws IllegalArgumentException, IllegalAccessException {
return 0;
} |
Gets the value of a static or instance field of type
{@code short} or of another primitive type convertible to
type {@code short} via a widening conversion.
@param obj the object to extract the {@code short} value
from
@return the value of the field converted to type {@code short}
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is inaccessible.
@exception IllegalArgumentException if the specified object is not
an instance of the class or interface declaring the
underlying field (or a subclass or implementor
thereof), or if the field value cannot be
converted to the type {@code short} by a
widening conversion.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#get
| Field::getShort | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void set(Object obj, Object value) throws IllegalArgumentException,
IllegalAccessException {} |
Sets the field represented by this {@code Field} object on the
specified object argument to the specified new value. The new
value is automatically unwrapped if the underlying field has a
primitive type.
<p>The operation proceeds as follows:
<p>If the underlying field is static, the {@code obj} argument is
ignored; it may be null.
<p>Otherwise the underlying field is an instance field. If the
specified object argument is null, the method throws a
{@code NullPointerException}. If the specified object argument is not
an instance of the class or interface declaring the underlying
field, the method throws an {@code IllegalArgumentException}.
<p>If this {@code Field} object is enforcing Java language access control, and
the underlying field is inaccessible, the method throws an
{@code IllegalAccessException}.
<p>If the underlying field is final, the method throws an
{@code IllegalAccessException} unless {@code setAccessible(true)}
has succeeded for this {@code Field} object
and the field is non-static. Setting a final field in this way
is meaningful only during deserialization or reconstruction of
instances of classes with blank final fields, before they are
made available for access by other parts of a program. Use in
any other context may have unpredictable effects, including cases
in which other parts of a program continue to use the original
value of this field.
<p>If the underlying field is of a primitive type, an unwrapping
conversion is attempted to convert the new value to a value of
a primitive type. If this attempt fails, the method throws an
{@code IllegalArgumentException}.
<p>If, after possible unwrapping, the new value cannot be
converted to the type of the underlying field by an identity or
widening conversion, the method throws an
{@code IllegalArgumentException}.
<p>If the underlying field is static, the class that declared the
field is initialized if it has not already been initialized.
<p>The field is set to the possibly unwrapped and widened new value.
<p>If the field is hidden in the type of {@code obj},
the field's value is set according to the preceding rules.
@param obj the object whose field should be modified
@param value the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
| Field::set | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void setBoolean(Object obj, boolean b) throws IllegalArgumentException, IllegalAccessException {} |
Sets the value of a field as a {@code boolean} on the specified object.
This method is equivalent to
{@code set(obj, zObj)},
where {@code zObj} is a {@code Boolean} object and
{@code zObj.booleanValue() == z}.
@param obj the object whose field should be modified
@param z the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#set
| Field::setBoolean | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void setByte(Object obj, byte b) throws IllegalArgumentException, IllegalAccessException {} |
Sets the value of a field as a {@code byte} on the specified object.
This method is equivalent to
{@code set(obj, bObj)},
where {@code bObj} is a {@code Byte} object and
{@code bObj.byteValue() == b}.
@param obj the object whose field should be modified
@param b the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#set
| Field::setByte | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void setChar(Object obj, char c) throws IllegalArgumentException, IllegalAccessException {} |
Sets the value of a field as a {@code char} on the specified object.
This method is equivalent to
{@code set(obj, cObj)},
where {@code cObj} is a {@code Character} object and
{@code cObj.charValue() == c}.
@param obj the object whose field should be modified
@param c the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#set
| Field::setChar | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void setDouble(Object obj, double d) throws IllegalArgumentException, IllegalAccessException {} |
Sets the value of a field as a {@code double} on the specified object.
This method is equivalent to
{@code set(obj, dObj)},
where {@code dObj} is a {@code Double} object and
{@code dObj.doubleValue() == d}.
@param obj the object whose field should be modified
@param d the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#set
| Field::setDouble | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void setFloat(Object obj, float f) throws IllegalArgumentException, IllegalAccessException {} |
Sets the value of a field as a {@code float} on the specified object.
This method is equivalent to
{@code set(obj, fObj)},
where {@code fObj} is a {@code Float} object and
{@code fObj.floatValue() == f}.
@param obj the object whose field should be modified
@param f the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#set
| Field::setFloat | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void setInt(Object obj, int i) throws IllegalArgumentException, IllegalAccessException {} |
Sets the value of a field as an {@code int} on the specified object.
This method is equivalent to
{@code set(obj, iObj)},
where {@code iObj} is a {@code Integer} object and
{@code iObj.intValue() == i}.
@param obj the object whose field should be modified
@param i the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#set
| Field::setInt | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void setLong(Object obj, long l) throws IllegalArgumentException, IllegalAccessException {} |
Sets the value of a field as a {@code long} on the specified object.
This method is equivalent to
{@code set(obj, lObj)},
where {@code lObj} is a {@code Long} object and
{@code lObj.longValue() == l}.
@param obj the object whose field should be modified
@param l the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#set
| Field::setLong | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public void setShort(Object obj, short s) throws IllegalArgumentException, IllegalAccessException {} |
Sets the value of a field as a {@code short} on the specified object.
This method is equivalent to
{@code set(obj, sObj)},
where {@code sObj} is a {@code Short} object and
{@code sObj.shortValue() == s}.
@param obj the object whose field should be modified
@param s the new value for the field of {@code obj}
being modified
@exception IllegalAccessException if this {@code Field} object
is enforcing Java language access control and the underlying
field is either inaccessible or final.
@exception IllegalArgumentException if the specified object is not an
instance of the class or interface declaring the underlying
field (or a subclass or implementor thereof),
or if an unwrapping conversion fails.
@exception NullPointerException if the specified object is null
and the field is an instance field.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
@see Field#set
| Field::setShort | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public boolean isSynthetic() {
return false;
} |
Returns {@code true} if this field is a synthetic
field; returns {@code false} otherwise.
@return true if and only if this field is a synthetic
field as defined by the Java Language Specification.
@since 1.5
| Field::isSynthetic | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public boolean isEnumConstant() {
return false;
} |
Returns {@code true} if this field represents an element of
an enumerated type; returns {@code false} otherwise.
@return {@code true} if and only if this field represents an element of
an enumerated type.
@since 1.5
| Field::isEnumConstant | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public int hashCode() {
return -1;
} |
Returns a hashcode for this {@code Field}. This is computed as the
exclusive-or of the hashcodes for the underlying field's
declaring class name and its name.
| Field::hashCode | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public java.lang.String toString() {
return null;
} |
Returns a string describing this {@code Field}. The format is
the access modifiers for the field, if any, followed
by the field type, followed by a space, followed by
the fully-qualified name of the class declaring the field,
followed by a period, followed by the name of the field.
For example:
<pre>
public static final int java.lang.Thread.MIN_PRIORITY
private int java.io.FileDescriptor.fd
</pre>
<p>The modifiers are placed in canonical order as specified by
"The Java Language Specification". This is {@code public},
{@code protected} or {@code private} first, and then other
modifiers in the following order: {@code static}, {@code final},
{@code transient}, {@code volatile}.
@return a string describing this {@code Field}
@jls 8.3.1 Field Modifiers
| Field::toString | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Field.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Field.java | Apache-2.0 |
public int getParameterCount() {
return 0;
} |
Returns the number of formal parameters (whether explicitly
declared or implicitly declared or neither) for the executable
represented by this object.
@return The number of formal parameters for the executable this
object represents
| Executable::getParameterCount | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public Type[] getGenericParameterTypes() {
return null;
} |
Returns an array of {@code Type} objects that represent the formal
parameter types, in declaration order, of the executable represented by
this object. Returns an array of length 0 if the
underlying executable takes no parameters.
<p>If a formal parameter type is a parameterized type,
the {@code Type} object returned for it must accurately reflect
the actual type parameters used in the source code.
<p>If a formal parameter type is a type variable or a parameterized
type, it is created. Otherwise, it is resolved.
@return an array of {@code Type}s that represent the formal
parameter types of the underlying executable, in declaration order
@throws GenericSignatureFormatError
if the generic method signature does not conform to the format
specified in
<cite>The Java™ Virtual Machine Specification</cite>
@throws TypeNotPresentException if any of the parameter
types of the underlying executable refers to a non-existent type
declaration
@throws MalformedParameterizedTypeException if any of
the underlying executable's parameter types refer to a parameterized
type that cannot be instantiated for any reason
| Executable::getGenericParameterTypes | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public Parameter[] getParameters() {
return null;
} |
Returns an array of {@code Parameter} objects that represent
all the parameters to the underlying executable represented by
this object. Returns an array of length 0 if the executable
has no parameters.
<p>The parameters of the underlying executable do not necessarily
have unique names, or names that are legal identifiers in the
Java programming language (JLS 3.8).
@throws MalformedParametersException if the class file contains
a MethodParameters attribute that is improperly formatted.
@return an array of {@code Parameter} objects representing all
the parameters to the executable this object represents.
| Executable::getParameters | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public Type[] getGenericExceptionTypes() {
return null;
} |
Returns an array of {@code Type} objects that represent the
exceptions declared to be thrown by this executable object.
Returns an array of length 0 if the underlying executable declares
no exceptions in its {@code throws} clause.
<p>If an exception type is a type variable or a parameterized
type, it is created. Otherwise, it is resolved.
@return an array of Types that represent the exception types
thrown by the underlying executable
@throws GenericSignatureFormatError
if the generic method signature does not conform to the format
specified in
<cite>The Java™ Virtual Machine Specification</cite>
@throws TypeNotPresentException if the underlying executable's
{@code throws} clause refers to a non-existent type declaration
@throws MalformedParameterizedTypeException if
the underlying executable's {@code throws} clause refers to a
parameterized type that cannot be instantiated for any reason
| Executable::getGenericExceptionTypes | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public boolean isVarArgs() {
return false;
} |
Returns {@code true} if this executable was declared to take a
variable number of arguments; returns {@code false} otherwise.
@return {@code true} if an only if this executable was declared
to take a variable number of arguments.
| Executable::isVarArgs | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public <T extends Annotation> T getAnnotation(Class<T> cls) {
return null;
} |
{@inheritDoc}
@throws NullPointerException {@inheritDoc}
| Executable::getAnnotation | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public AnnotatedType getAnnotatedReceiverType() {
return null;
} |
Returns an {@code AnnotatedType} object that represents the use of a
type to specify the receiver type of the method/constructor represented
by this Executable object. The receiver type of a method/constructor is
available only if the method/constructor has a <em>receiver
parameter</em> (JLS 8.4.1).
If this {@code Executable} object represents a constructor or instance
method that does not have a receiver parameter, or has a receiver
parameter with no annotations on its type, then the return value is an
{@code AnnotatedType} object representing an element with no
annotations.
If this {@code Executable} object represents a static method, then the
return value is null.
@return an object representing the receiver type of the method or
constructor represented by this {@code Executable}
@since 1.8
| Executable::getAnnotatedReceiverType | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public AnnotatedType[] getAnnotatedParameterTypes() {
return null;
} |
Returns an array of {@code AnnotatedType} objects that represent the use
of types to specify formal parameter types of the method/constructor
represented by this Executable. The order of the objects in the array
corresponds to the order of the formal parameter types in the
declaration of the method/constructor.
Returns an array of length 0 if the method/constructor declares no
parameters.
@return an array of objects representing the types of the
formal parameters of the method or constructor represented by this
{@code Executable}
@since 1.8
| Executable::getAnnotatedParameterTypes | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public AnnotatedType[] getAnnotatedExceptionTypes() {
return null;
} |
Returns an array of {@code AnnotatedType} objects that represent the use
of types to specify the declared exceptions of the method/constructor
represented by this Executable. The order of the objects in the array
corresponds to the order of the exception types in the declaration of
the method/constructor.
Returns an array of length 0 if the method/constructor declares no
exceptions.
@return an array of objects representing the declared
exceptions of the method or constructor represented by this {@code
Executable}
@since 1.8
| Executable::getAnnotatedExceptionTypes | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Executable.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Executable.java | Apache-2.0 |
public Class<?> getReturnType() {
return null;
} |
Returns a {@code Class} object that represents the formal return type
of the method represented by this {@code Method} object.
@return the return type for the method this object represents
| Method::getReturnType | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Method.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Method.java | Apache-2.0 |
public Type getGenericReturnType() {
return null;
} |
Returns a {@code Type} object that represents the formal return
type of the method represented by this {@code Method} object.
<p>If the return type is a parameterized type,
the {@code Type} object returned must accurately reflect
the actual type parameters used in the source code.
<p>If the return type is a type variable or a parameterized type, it
is created. Otherwise, it is resolved.
@return a {@code Type} object that represents the formal return
type of the underlying method
@throws GenericSignatureFormatError
if the generic method signature does not conform to the format
specified in
<cite>The Java™ Virtual Machine Specification</cite>
@throws TypeNotPresentException if the underlying method's
return type refers to a non-existent type declaration
@throws MalformedParameterizedTypeException if the
underlying method's return typed refers to a parameterized
type that cannot be instantiated for any reason
@since 1.5
| Method::getGenericReturnType | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Method.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Method.java | Apache-2.0 |
public Object invoke(Object obj, Object... args)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
return null;
} |
Invokes the underlying method represented by this {@code Method}
object, on the specified object with the specified parameters.
Individual parameters are automatically unwrapped to match
primitive formal parameters, and both primitive and reference
parameters are subject to method invocation conversions as
necessary.
<p>If the underlying method is static, then the specified {@code obj}
argument is ignored. It may be null.
<p>If the number of formal parameters required by the underlying method is
0, the supplied {@code args} array may be of length 0 or null.
<p>If the underlying method is an instance method, it is invoked
using dynamic method lookup as documented in The Java Language
Specification, Second Edition, section 15.12.4.4; in particular,
overriding based on the runtime type of the target object will occur.
<p>If the underlying method is static, the class that declared
the method is initialized if it has not already been initialized.
<p>If the method completes normally, the value it returns is
returned to the caller of invoke; if the value has a primitive
type, it is first appropriately wrapped in an object. However,
if the value has the type of an array of a primitive type, the
elements of the array are <i>not</i> wrapped in objects; in
other words, an array of primitive type is returned. If the
underlying method return type is void, the invocation returns
null.
@param obj the object the underlying method is invoked from
@param args the arguments used for the method call
@return the result of dispatching the method represented by
this object on {@code obj} with parameters
{@code args}
@exception IllegalAccessException if this {@code Method} object
is enforcing Java language access control and the underlying
method is inaccessible.
@exception IllegalArgumentException if the method is an
instance method and the specified object argument
is not an instance of the class or interface
declaring the underlying method (or of a subclass
or implementor thereof); if the number of actual
and formal parameters differ; if an unwrapping
conversion for primitive arguments fails; or if,
after possible unwrapping, a parameter value
cannot be converted to the corresponding formal
parameter type by a method invocation conversion.
@exception InvocationTargetException if the underlying method
throws an exception.
@exception NullPointerException if the specified object is null
and the method is an instance method.
@exception ExceptionInInitializerError if the initialization
provoked by this method fails.
| Method::invoke | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Method.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Method.java | Apache-2.0 |
public Object getDefaultValue() {
return null;
} |
Returns the default value for the annotation member represented by
this {@code Method} instance. If the member is of a primitive type,
an instance of the corresponding wrapper type is returned. Returns
null if no default is associated with the member, or if the method
instance does not represent a declared member of an annotation type.
@return the default value for the annotation member represented
by this {@code Method} instance.
@throws TypeNotPresentException if the annotation is of type
{@link Class} and no definition can be found for the
default class value.
@since 1.5
| Method::getDefaultValue | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Method.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Method.java | Apache-2.0 |
public boolean isBridge() {
return false;
} |
Returns {@code true} if this method is a bridge
method; returns {@code false} otherwise.
@return true if and only if this method is a bridge
method as defined by the Java Language Specification.
@since 1.5
| Method::isBridge | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Method.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Method.java | Apache-2.0 |
public boolean isDefault() {
return false;
} |
Returns {@code true} if this method is a default
method; returns {@code false} otherwise.
A default method is a public non-abstract instance method, that
is, a non-static method with a body, declared in an interface
type.
@return true if and only if this method is a default
method as defined by the Java Language Specification.
@since 1.8
| Method::isDefault | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Method.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Method.java | Apache-2.0 |
public T newInstance(Object ... initargs) throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
return null;
} |
Uses the constructor represented by this {@code Constructor} object to
create and initialize a new instance of the constructor's
declaring class, with the specified initialization parameters.
Individual parameters are automatically unwrapped to match
primitive formal parameters, and both primitive and reference
parameters are subject to method invocation conversions as necessary.
<p>If the number of formal parameters required by the underlying constructor
is 0, the supplied {@code initargs} array may be of length 0 or null.
<p>If the constructor's declaring class is an inner class in a
non-static context, the first argument to the constructor needs
to be the enclosing instance; see section 15.9.3 of
<cite>The Java™ Language Specification</cite>.
<p>If the required access and argument checks succeed and the
instantiation will proceed, the constructor's declaring class
is initialized if it has not already been initialized.
<p>If the constructor completes normally, returns the newly
created and initialized instance.
@param initargs array of objects to be passed as arguments to
the constructor call; values of primitive types are wrapped in
a wrapper object of the appropriate type (e.g. a {@code float}
in a {@link java.lang.Float Float})
@return a new object created by calling the constructor
this object represents
@exception IllegalAccessException if this {@code Constructor} object
is enforcing Java language access control and the underlying
constructor is inaccessible.
@exception IllegalArgumentException if the number of actual
and formal parameters differ; if an unwrapping
conversion for primitive arguments fails; or if,
after possible unwrapping, a parameter value
cannot be converted to the corresponding formal
parameter type by a method invocation conversion; if
this constructor pertains to an enum type.
@exception InstantiationException if the class that declares the
underlying constructor represents an abstract class.
@exception InvocationTargetException if the underlying constructor
throws an exception.
@exception ExceptionInInitializerError if the initialization provoked
by this method fails.
| Constructor::newInstance | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/Constructor.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/Constructor.java | Apache-2.0 |
public boolean isAccessible() {
return false;
} |
Get the value of the {@code accessible} flag for this object.
@return the value of the object's {@code accessible} flag
| AccessibleObject::isAccessible | java | google/j2objc | jre_emul/stub_classes/java/java/lang/reflect/AccessibleObject.java | https://github.com/google/j2objc/blob/master/jre_emul/stub_classes/java/java/lang/reflect/AccessibleObject.java | Apache-2.0 |
private static NetworkInterface chooseDefaultInterface() {
Enumeration<NetworkInterface> nifs;
try {
nifs = NetworkInterface.getNetworkInterfaces();
} catch (IOException ignore) {
// unable to enumate network interfaces
return null;
}
NetworkInterface ppp = null;
NetworkInterface loopback = null;
while (nifs.hasMoreElements()) {
NetworkInterface ni = nifs.nextElement();
try {
if (ni.isUp() && ni.supportsMulticast()) {
boolean isLoopback = ni.isLoopback();
boolean isPPP = ni.isPointToPoint();
if (!isLoopback && !isPPP) {
// found an interface that is not the loopback or a
// point-to-point interface
return ni;
}
if (ppp == null && isPPP)
ppp = ni;
if (loopback == null && isLoopback)
loopback = ni;
}
} catch (IOException skip) { }
}
return (ppp != null) ? ppp : loopback;
} |
Choose a default interface. This method returns an interface that is
both "up" and supports multicast. This method choses an interface in
order of preference:
1. neither loopback nor point to point
2. point to point
3. loopback
@return the chosen interface or {@code null} if there isn't a suitable
default
| DefaultInterface::chooseDefaultInterface | java | google/j2objc | jre_emul/openjdk/src/macosx/classes/java/net/DefaultInterface.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/macosx/classes/java/net/DefaultInterface.java | Apache-2.0 |
final void register(int fd, PollableChannel ch) {
fdToChannelLock.writeLock().lock();
try {
if (isShutdown())
throw new ShutdownChannelGroupException();
fdToChannel.put(Integer.valueOf(fd), ch);
} finally {
fdToChannelLock.writeLock().unlock();
}
} |
Register channel identified by its file descriptor
| Port::register | java | google/j2objc | jre_emul/openjdk/src/macosx/classes/sun/nio/ch/Port.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/macosx/classes/sun/nio/ch/Port.java | Apache-2.0 |
final void unregister(int fd) {
boolean checkForShutdown = false;
fdToChannelLock.writeLock().lock();
try {
fdToChannel.remove(Integer.valueOf(fd));
// last key to be removed so check if group is shutdown
if (fdToChannel.isEmpty())
checkForShutdown = true;
} finally {
fdToChannelLock.writeLock().unlock();
}
// continue shutdown
if (checkForShutdown && isShutdown()) {
try {
shutdownNow();
} catch (IOException ignore) { }
}
} |
Unregister channel identified by its file descriptor
| Port::unregister | java | google/j2objc | jre_emul/openjdk/src/macosx/classes/sun/nio/ch/Port.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/macosx/classes/sun/nio/ch/Port.java | Apache-2.0 |
private int updateSelectedKeys(int entries)
throws IOException
{
int numKeysUpdated = 0;
boolean interrupted = false;
// A file descriptor may be registered with kqueue with more than one
// filter and so there may be more than one event for a fd. The update
// count in the MapEntry tracks when the fd was last updated and this
// ensures that the ready ops are updated rather than replaced by a
// second or subsequent event.
updateCount++;
for (int i = 0; i < entries; i++) {
int nextFD = kqueueWrapper.getDescriptor(i);
if (nextFD == fd0) {
interrupted = true;
} else {
MapEntry me = fdMap.get(Integer.valueOf(nextFD));
// entry is null in the case of an interrupt
if (me != null) {
int rOps = kqueueWrapper.getReventOps(i);
SelectionKeyImpl ski = me.ski;
if (selectedKeys.contains(ski)) {
// first time this file descriptor has been encountered on this
// update?
if (me.updateCount != updateCount) {
if (ski.channel.translateAndSetReadyOps(rOps, ski)) {
numKeysUpdated++;
me.updateCount = updateCount;
}
} else {
// ready ops have already been set on this update
ski.channel.translateAndUpdateReadyOps(rOps, ski);
}
} else {
ski.channel.translateAndSetReadyOps(rOps, ski);
if ((ski.nioReadyOps() & ski.nioInterestOps()) != 0) {
selectedKeys.add(ski);
numKeysUpdated++;
me.updateCount = updateCount;
}
}
}
}
}
if (interrupted) {
// Clear the wakeup pipe
synchronized (interruptLock) {
IOUtil.drain(fd0);
interruptTriggered = false;
}
}
return numKeysUpdated;
} |
Update the keys whose fd's have been selected by kqueue.
Add the ready keys to the selected key set.
If the interrupt fd has been selected, drain it and clear the interrupt.
| MapEntry::updateSelectedKeys | java | google/j2objc | jre_emul/openjdk/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java | Apache-2.0 |
private void implClose() {
synchronized (this) {
if (closed)
return;
closed = true;
}
freePollArray(address);
close0(sp[0]);
close0(sp[1]);
close0(kqfd);
} |
Release all resources
| Event::implClose | java | google/j2objc | jre_emul/openjdk/src/macosx/classes/sun/nio/ch/KQueuePort.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/macosx/classes/sun/nio/ch/KQueuePort.java | Apache-2.0 |
static long getEvent(long address, int i) {
return address + (SIZEOF_KQUEUEEVENT*i);
} |
Returns kevent[i].
| KQueue::getEvent | java | google/j2objc | jre_emul/openjdk/src/macosx/classes/sun/nio/ch/KQueue.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/macosx/classes/sun/nio/ch/KQueue.java | Apache-2.0 |
static int getDescriptor(long address) {
return unsafe.getInt(address + OFFSET_IDENT);
} |
Returns the file descriptor from a kevent (assuming to be in ident field)
| KQueue::getDescriptor | java | google/j2objc | jre_emul/openjdk/src/macosx/classes/sun/nio/ch/KQueue.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/macosx/classes/sun/nio/ch/KQueue.java | Apache-2.0 |
public static SelectorProvider create() {
return new sun.nio.ch.KQueueSelectorProvider();
} |
Returns the default SelectorProvider.
| DefaultSelectorProvider::create | java | google/j2objc | jre_emul/openjdk/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java | Apache-2.0 |
private RoundingMode(int oldMode) {
this.oldMode = oldMode;
} |
Constructor
@param oldMode The {@code BigDecimal} constant corresponding to
this mode
| RoundingMode::RoundingMode | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/RoundingMode.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/RoundingMode.java | Apache-2.0 |
public static RoundingMode valueOf(int rm) {
switch(rm) {
case BigDecimal.ROUND_UP:
return UP;
case BigDecimal.ROUND_DOWN:
return DOWN;
case BigDecimal.ROUND_CEILING:
return CEILING;
case BigDecimal.ROUND_FLOOR:
return FLOOR;
case BigDecimal.ROUND_HALF_UP:
return HALF_UP;
case BigDecimal.ROUND_HALF_DOWN:
return HALF_DOWN;
case BigDecimal.ROUND_HALF_EVEN:
return HALF_EVEN;
case BigDecimal.ROUND_UNNECESSARY:
return UNNECESSARY;
default:
throw new IllegalArgumentException("argument out of range");
}
} |
Returns the {@code RoundingMode} object corresponding to a
legacy integer rounding mode constant in {@link BigDecimal}.
@param rm legacy integer rounding mode to convert
@return {@code RoundingMode} corresponding to the given integer.
@throws IllegalArgumentException integer is out of range
| RoundingMode::valueOf | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/RoundingMode.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/RoundingMode.java | Apache-2.0 |
public BigDecimal(char[] in, int offset, int len, MathContext mc) {
// protect against huge length.
if (offset + len > in.length || offset < 0)
throw new NumberFormatException("Bad offset or len arguments for char[] input.");
// This is the primary string to BigDecimal constructor; all
// incoming strings end up here; it uses explicit (inline)
// parsing for speed and generates at most one intermediate
// (temporary) object (a char[] array) for non-compact case.
// Use locals for all fields values until completion
int prec = 0; // record precision value
int scl = 0; // record scale value
long rs = 0; // the compact value in long
BigInteger rb = null; // the inflated value in BigInteger
// use array bounds checking to handle too-long, len == 0,
// bad offset, etc.
try {
// handle the sign
boolean isneg = false; // assume positive
if (in[offset] == '-') {
isneg = true; // leading minus means negative
offset++;
len--;
} else if (in[offset] == '+') { // leading + allowed
offset++;
len--;
}
// should now be at numeric part of the significand
boolean dot = false; // true when there is a '.'
long exp = 0; // exponent
char c; // current character
boolean isCompact = (len <= MAX_COMPACT_DIGITS);
// integer significand array & idx is the index to it. The array
// is ONLY used when we can't use a compact representation.
int idx = 0;
if (isCompact) {
// First compact case, we need not to preserve the character
// and we can just compute the value in place.
for (; len > 0; offset++, len--) {
c = in[offset];
if ((c == '0')) { // have zero
if (prec == 0)
prec = 1;
else if (rs != 0) {
rs *= 10;
++prec;
} // else digit is a redundant leading zero
if (dot)
++scl;
} else if ((c >= '1' && c <= '9')) { // have digit
int digit = c - '0';
if (prec != 1 || rs != 0)
++prec; // prec unchanged if preceded by 0s
rs = rs * 10 + digit;
if (dot)
++scl;
} else if (c == '.') { // have dot
// have dot
if (dot) // two dots
throw new NumberFormatException();
dot = true;
} else if (Character.isDigit(c)) { // slow path
int digit = Character.digit(c, 10);
if (digit == 0) {
if (prec == 0)
prec = 1;
else if (rs != 0) {
rs *= 10;
++prec;
} // else digit is a redundant leading zero
} else {
if (prec != 1 || rs != 0)
++prec; // prec unchanged if preceded by 0s
rs = rs * 10 + digit;
}
if (dot)
++scl;
} else if ((c == 'e') || (c == 'E')) {
exp = parseExp(in, offset, len);
// Next test is required for backwards compatibility
if ((int) exp != exp) // overflow
throw new NumberFormatException();
break; // [saves a test]
} else {
throw new NumberFormatException();
}
}
if (prec == 0) // no digits found
throw new NumberFormatException();
// Adjust scale if exp is not zero.
if (exp != 0) { // had significant exponent
scl = adjustScale(scl, exp);
}
rs = isneg ? -rs : rs;
int mcp = mc.precision;
int drop = prec - mcp; // prec has range [1, MAX_INT], mcp has range [0, MAX_INT];
// therefore, this subtract cannot overflow
if (mcp > 0 && drop > 0) { // do rounding
while (drop > 0) {
scl = checkScaleNonZero((long) scl - drop);
rs = divideAndRound(rs, LONG_TEN_POWERS_TABLE[drop], mc.roundingMode.oldMode);
prec = longDigitLength(rs);
drop = prec - mcp;
}
}
} else {
char coeff[] = new char[len];
for (; len > 0; offset++, len--) {
c = in[offset];
// have digit
if ((c >= '0' && c <= '9') || Character.isDigit(c)) {
// First compact case, we need not to preserve the character
// and we can just compute the value in place.
if (c == '0' || Character.digit(c, 10) == 0) {
if (prec == 0) {
coeff[idx] = c;
prec = 1;
} else if (idx != 0) {
coeff[idx++] = c;
++prec;
} // else c must be a redundant leading zero
} else {
if (prec != 1 || idx != 0)
++prec; // prec unchanged if preceded by 0s
coeff[idx++] = c;
}
if (dot)
++scl;
continue;
}
// have dot
if (c == '.') {
// have dot
if (dot) // two dots
throw new NumberFormatException();
dot = true;
continue;
}
// exponent expected
if ((c != 'e') && (c != 'E'))
throw new NumberFormatException();
exp = parseExp(in, offset, len);
// Next test is required for backwards compatibility
if ((int) exp != exp) // overflow
throw new NumberFormatException();
break; // [saves a test]
}
// here when no characters left
if (prec == 0) // no digits found
throw new NumberFormatException();
// Adjust scale if exp is not zero.
if (exp != 0) { // had significant exponent
scl = adjustScale(scl, exp);
}
// Remove leading zeros from precision (digits count)
rb = new BigInteger(coeff, isneg ? -1 : 1, prec);
rs = compactValFor(rb);
int mcp = mc.precision;
if (mcp > 0 && (prec > mcp)) {
if (rs == INFLATED) {
int drop = prec - mcp;
while (drop > 0) {
scl = checkScaleNonZero((long) scl - drop);
rb = divideAndRoundByTenPow(rb, drop, mc.roundingMode.oldMode);
rs = compactValFor(rb);
if (rs != INFLATED) {
prec = longDigitLength(rs);
break;
}
prec = bigDigitLength(rb);
drop = prec - mcp;
}
}
if (rs != INFLATED) {
int drop = prec - mcp;
while (drop > 0) {
scl = checkScaleNonZero((long) scl - drop);
rs = divideAndRound(rs, LONG_TEN_POWERS_TABLE[drop], mc.roundingMode.oldMode);
prec = longDigitLength(rs);
drop = prec - mcp;
}
rb = null;
}
}
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new NumberFormatException();
} catch (NegativeArraySizeException e) {
throw new NumberFormatException();
}
this.scale = scl;
this.precision = prec;
this.intCompact = rs;
this.intVal = rb;
} |
Translates a character array representation of a
{@code BigDecimal} into a {@code BigDecimal}, accepting the
same sequence of characters as the {@link #BigDecimal(String)}
constructor, while allowing a sub-array to be specified and
with rounding according to the context settings.
<p>Note that if the sequence of characters is already available
within a character array, using this constructor is faster than
converting the {@code char} array to string and using the
{@code BigDecimal(String)} constructor .
@param in {@code char} array that is the source of characters.
@param offset first character in the array to inspect.
@param len number of characters to consider..
@param mc the context to use.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@throws NumberFormatException if {@code in} is not a valid
representation of a {@code BigDecimal} or the defined subarray
is not wholly within {@code in}.
@since 1.5
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
private static long parseExp(char[] in, int offset, int len){
long exp = 0;
offset++;
char c = in[offset];
len--;
boolean negexp = (c == '-');
// optional sign
if (negexp || c == '+') {
offset++;
c = in[offset];
len--;
}
if (len <= 0) // no exponent digits
throw new NumberFormatException();
// skip leading zeros in the exponent
while (len > 10 && (c=='0' || (Character.digit(c, 10) == 0))) {
offset++;
c = in[offset];
len--;
}
if (len > 10) // too many nonzero exponent digits
throw new NumberFormatException();
// c now holds first digit of exponent
for (;; len--) {
int v;
if (c >= '0' && c <= '9') {
v = c - '0';
} else {
v = Character.digit(c, 10);
if (v < 0) // not a digit
throw new NumberFormatException();
}
exp = exp * 10 + v;
if (len == 1)
break; // that was final character
offset++;
c = in[offset];
}
if (negexp) // apply sign
exp = -exp;
return exp;
} |
Translates a character array representation of a
{@code BigDecimal} into a {@code BigDecimal}, accepting the
same sequence of characters as the {@link #BigDecimal(String)}
constructor, while allowing a sub-array to be specified and
with rounding according to the context settings.
<p>Note that if the sequence of characters is already available
within a character array, using this constructor is faster than
converting the {@code char} array to string and using the
{@code BigDecimal(String)} constructor .
@param in {@code char} array that is the source of characters.
@param offset first character in the array to inspect.
@param len number of characters to consider..
@param mc the context to use.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@throws NumberFormatException if {@code in} is not a valid
representation of a {@code BigDecimal} or the defined subarray
is not wholly within {@code in}.
@since 1.5
public BigDecimal(char[] in, int offset, int len, MathContext mc) {
// protect against huge length.
if (offset + len > in.length || offset < 0)
throw new NumberFormatException("Bad offset or len arguments for char[] input.");
// This is the primary string to BigDecimal constructor; all
// incoming strings end up here; it uses explicit (inline)
// parsing for speed and generates at most one intermediate
// (temporary) object (a char[] array) for non-compact case.
// Use locals for all fields values until completion
int prec = 0; // record precision value
int scl = 0; // record scale value
long rs = 0; // the compact value in long
BigInteger rb = null; // the inflated value in BigInteger
// use array bounds checking to handle too-long, len == 0,
// bad offset, etc.
try {
// handle the sign
boolean isneg = false; // assume positive
if (in[offset] == '-') {
isneg = true; // leading minus means negative
offset++;
len--;
} else if (in[offset] == '+') { // leading + allowed
offset++;
len--;
}
// should now be at numeric part of the significand
boolean dot = false; // true when there is a '.'
long exp = 0; // exponent
char c; // current character
boolean isCompact = (len <= MAX_COMPACT_DIGITS);
// integer significand array & idx is the index to it. The array
// is ONLY used when we can't use a compact representation.
int idx = 0;
if (isCompact) {
// First compact case, we need not to preserve the character
// and we can just compute the value in place.
for (; len > 0; offset++, len--) {
c = in[offset];
if ((c == '0')) { // have zero
if (prec == 0)
prec = 1;
else if (rs != 0) {
rs *= 10;
++prec;
} // else digit is a redundant leading zero
if (dot)
++scl;
} else if ((c >= '1' && c <= '9')) { // have digit
int digit = c - '0';
if (prec != 1 || rs != 0)
++prec; // prec unchanged if preceded by 0s
rs = rs * 10 + digit;
if (dot)
++scl;
} else if (c == '.') { // have dot
// have dot
if (dot) // two dots
throw new NumberFormatException();
dot = true;
} else if (Character.isDigit(c)) { // slow path
int digit = Character.digit(c, 10);
if (digit == 0) {
if (prec == 0)
prec = 1;
else if (rs != 0) {
rs *= 10;
++prec;
} // else digit is a redundant leading zero
} else {
if (prec != 1 || rs != 0)
++prec; // prec unchanged if preceded by 0s
rs = rs * 10 + digit;
}
if (dot)
++scl;
} else if ((c == 'e') || (c == 'E')) {
exp = parseExp(in, offset, len);
// Next test is required for backwards compatibility
if ((int) exp != exp) // overflow
throw new NumberFormatException();
break; // [saves a test]
} else {
throw new NumberFormatException();
}
}
if (prec == 0) // no digits found
throw new NumberFormatException();
// Adjust scale if exp is not zero.
if (exp != 0) { // had significant exponent
scl = adjustScale(scl, exp);
}
rs = isneg ? -rs : rs;
int mcp = mc.precision;
int drop = prec - mcp; // prec has range [1, MAX_INT], mcp has range [0, MAX_INT];
// therefore, this subtract cannot overflow
if (mcp > 0 && drop > 0) { // do rounding
while (drop > 0) {
scl = checkScaleNonZero((long) scl - drop);
rs = divideAndRound(rs, LONG_TEN_POWERS_TABLE[drop], mc.roundingMode.oldMode);
prec = longDigitLength(rs);
drop = prec - mcp;
}
}
} else {
char coeff[] = new char[len];
for (; len > 0; offset++, len--) {
c = in[offset];
// have digit
if ((c >= '0' && c <= '9') || Character.isDigit(c)) {
// First compact case, we need not to preserve the character
// and we can just compute the value in place.
if (c == '0' || Character.digit(c, 10) == 0) {
if (prec == 0) {
coeff[idx] = c;
prec = 1;
} else if (idx != 0) {
coeff[idx++] = c;
++prec;
} // else c must be a redundant leading zero
} else {
if (prec != 1 || idx != 0)
++prec; // prec unchanged if preceded by 0s
coeff[idx++] = c;
}
if (dot)
++scl;
continue;
}
// have dot
if (c == '.') {
// have dot
if (dot) // two dots
throw new NumberFormatException();
dot = true;
continue;
}
// exponent expected
if ((c != 'e') && (c != 'E'))
throw new NumberFormatException();
exp = parseExp(in, offset, len);
// Next test is required for backwards compatibility
if ((int) exp != exp) // overflow
throw new NumberFormatException();
break; // [saves a test]
}
// here when no characters left
if (prec == 0) // no digits found
throw new NumberFormatException();
// Adjust scale if exp is not zero.
if (exp != 0) { // had significant exponent
scl = adjustScale(scl, exp);
}
// Remove leading zeros from precision (digits count)
rb = new BigInteger(coeff, isneg ? -1 : 1, prec);
rs = compactValFor(rb);
int mcp = mc.precision;
if (mcp > 0 && (prec > mcp)) {
if (rs == INFLATED) {
int drop = prec - mcp;
while (drop > 0) {
scl = checkScaleNonZero((long) scl - drop);
rb = divideAndRoundByTenPow(rb, drop, mc.roundingMode.oldMode);
rs = compactValFor(rb);
if (rs != INFLATED) {
prec = longDigitLength(rs);
break;
}
prec = bigDigitLength(rb);
drop = prec - mcp;
}
}
if (rs != INFLATED) {
int drop = prec - mcp;
while (drop > 0) {
scl = checkScaleNonZero((long) scl - drop);
rs = divideAndRound(rs, LONG_TEN_POWERS_TABLE[drop], mc.roundingMode.oldMode);
prec = longDigitLength(rs);
drop = prec - mcp;
}
rb = null;
}
}
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new NumberFormatException();
} catch (NegativeArraySizeException e) {
throw new NumberFormatException();
}
this.scale = scl;
this.precision = prec;
this.intCompact = rs;
this.intVal = rb;
}
private int adjustScale(int scl, long exp) {
long adjustedScale = scl - exp;
if (adjustedScale > Integer.MAX_VALUE || adjustedScale < Integer.MIN_VALUE)
throw new NumberFormatException("Scale out of range.");
scl = (int) adjustedScale;
return scl;
}
/*
parse exponent
| BigDecimal::parseExp | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(double val, MathContext mc) {
if (Double.isInfinite(val) || Double.isNaN(val))
throw new NumberFormatException("Infinite or NaN");
// Translate the double into sign, exponent and significand, according
// to the formulae in JLS, Section 20.10.22.
long valBits = Double.doubleToLongBits(val);
int sign = ((valBits >> 63) == 0 ? 1 : -1);
int exponent = (int) ((valBits >> 52) & 0x7ffL);
long significand = (exponent == 0
? (valBits & ((1L << 52) - 1)) << 1
: (valBits & ((1L << 52) - 1)) | (1L << 52));
exponent -= 1075;
// At this point, val == sign * significand * 2**exponent.
/*
* Special case zero to supress nonterminating normalization and bogus
* scale calculation.
*/
if (significand == 0) {
this.intVal = BigInteger.ZERO;
this.scale = 0;
this.intCompact = 0;
this.precision = 1;
return;
}
// Normalize
while ((significand & 1) == 0) { // i.e., significand is even
significand >>= 1;
exponent++;
}
int scale = 0;
// Calculate intVal and scale
BigInteger intVal;
long compactVal = sign * significand;
if (exponent == 0) {
intVal = (compactVal == INFLATED) ? INFLATED_BIGINT : null;
} else {
if (exponent < 0) {
intVal = BigInteger.valueOf(5).pow(-exponent).multiply(compactVal);
scale = -exponent;
} else { // (exponent > 0)
intVal = BigInteger.valueOf(2).pow(exponent).multiply(compactVal);
}
compactVal = compactValFor(intVal);
}
int prec = 0;
int mcp = mc.precision;
if (mcp > 0) { // do rounding
int mode = mc.roundingMode.oldMode;
int drop;
if (compactVal == INFLATED) {
prec = bigDigitLength(intVal);
drop = prec - mcp;
while (drop > 0) {
scale = checkScaleNonZero((long) scale - drop);
intVal = divideAndRoundByTenPow(intVal, drop, mode);
compactVal = compactValFor(intVal);
if (compactVal != INFLATED) {
break;
}
prec = bigDigitLength(intVal);
drop = prec - mcp;
}
}
if (compactVal != INFLATED) {
prec = longDigitLength(compactVal);
drop = prec - mcp;
while (drop > 0) {
scale = checkScaleNonZero((long) scale - drop);
compactVal = divideAndRound(compactVal, LONG_TEN_POWERS_TABLE[drop], mc.roundingMode.oldMode);
prec = longDigitLength(compactVal);
drop = prec - mcp;
}
intVal = null;
}
}
this.intVal = intVal;
this.intCompact = compactVal;
this.scale = scale;
this.precision = prec;
} |
Translates a {@code double} into a {@code BigDecimal}, with
rounding according to the context settings. The scale of the
{@code BigDecimal} is the smallest value such that
<tt>(10<sup>scale</sup> × val)</tt> is an integer.
<p>The results of this constructor can be somewhat unpredictable
and its use is generally not recommended; see the notes under
the {@link #BigDecimal(double)} constructor.
@param val {@code double} value to be converted to
{@code BigDecimal}.
@param mc the context to use.
@throws ArithmeticException if the result is inexact but the
RoundingMode is UNNECESSARY.
@throws NumberFormatException if {@code val} is infinite or NaN.
@since 1.5
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(BigInteger val) {
scale = 0;
intVal = val;
intCompact = compactValFor(val);
} |
Translates a {@code BigInteger} into a {@code BigDecimal}.
The scale of the {@code BigDecimal} is zero.
@param val {@code BigInteger} value to be converted to
{@code BigDecimal}.
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(BigInteger val, MathContext mc) {
this(val,0,mc);
} |
Translates a {@code BigInteger} into a {@code BigDecimal}
rounding according to the context settings. The scale of the
{@code BigDecimal} is zero.
@param val {@code BigInteger} value to be converted to
{@code BigDecimal}.
@param mc the context to use.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@since 1.5
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(BigInteger unscaledVal, int scale) {
// Negative scales are now allowed
this.intVal = unscaledVal;
this.intCompact = compactValFor(unscaledVal);
this.scale = scale;
} |
Translates a {@code BigInteger} unscaled value and an
{@code int} scale into a {@code BigDecimal}. The value of
the {@code BigDecimal} is
<tt>(unscaledVal × 10<sup>-scale</sup>)</tt>.
@param unscaledVal unscaled value of the {@code BigDecimal}.
@param scale scale of the {@code BigDecimal}.
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) {
long compactVal = compactValFor(unscaledVal);
int mcp = mc.precision;
int prec = 0;
if (mcp > 0) { // do rounding
int mode = mc.roundingMode.oldMode;
if (compactVal == INFLATED) {
prec = bigDigitLength(unscaledVal);
int drop = prec - mcp;
while (drop > 0) {
scale = checkScaleNonZero((long) scale - drop);
unscaledVal = divideAndRoundByTenPow(unscaledVal, drop, mode);
compactVal = compactValFor(unscaledVal);
if (compactVal != INFLATED) {
break;
}
prec = bigDigitLength(unscaledVal);
drop = prec - mcp;
}
}
if (compactVal != INFLATED) {
prec = longDigitLength(compactVal);
int drop = prec - mcp; // drop can't be more than 18
while (drop > 0) {
scale = checkScaleNonZero((long) scale - drop);
compactVal = divideAndRound(compactVal, LONG_TEN_POWERS_TABLE[drop], mode);
prec = longDigitLength(compactVal);
drop = prec - mcp;
}
unscaledVal = null;
}
}
this.intVal = unscaledVal;
this.intCompact = compactVal;
this.scale = scale;
this.precision = prec;
} |
Translates a {@code BigInteger} unscaled value and an
{@code int} scale into a {@code BigDecimal}, with rounding
according to the context settings. The value of the
{@code BigDecimal} is <tt>(unscaledVal ×
10<sup>-scale</sup>)</tt>, rounded according to the
{@code precision} and rounding mode settings.
@param unscaledVal unscaled value of the {@code BigDecimal}.
@param scale scale of the {@code BigDecimal}.
@param mc the context to use.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@since 1.5
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(int val) {
this.intCompact = val;
this.scale = 0;
this.intVal = null;
} |
Translates an {@code int} into a {@code BigDecimal}. The
scale of the {@code BigDecimal} is zero.
@param val {@code int} value to be converted to
{@code BigDecimal}.
@since 1.5
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(int val, MathContext mc) {
int mcp = mc.precision;
long compactVal = val;
int scale = 0;
int prec = 0;
if (mcp > 0) { // do rounding
prec = longDigitLength(compactVal);
int drop = prec - mcp; // drop can't be more than 18
while (drop > 0) {
scale = checkScaleNonZero((long) scale - drop);
compactVal = divideAndRound(compactVal, LONG_TEN_POWERS_TABLE[drop], mc.roundingMode.oldMode);
prec = longDigitLength(compactVal);
drop = prec - mcp;
}
}
this.intVal = null;
this.intCompact = compactVal;
this.scale = scale;
this.precision = prec;
} |
Translates an {@code int} into a {@code BigDecimal}, with
rounding according to the context settings. The scale of the
{@code BigDecimal}, before any rounding, is zero.
@param val {@code int} value to be converted to {@code BigDecimal}.
@param mc the context to use.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@since 1.5
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(long val) {
this.intCompact = val;
this.intVal = (val == INFLATED) ? INFLATED_BIGINT : null;
this.scale = 0;
} |
Translates a {@code long} into a {@code BigDecimal}. The
scale of the {@code BigDecimal} is zero.
@param val {@code long} value to be converted to {@code BigDecimal}.
@since 1.5
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal(long val, MathContext mc) {
int mcp = mc.precision;
int mode = mc.roundingMode.oldMode;
int prec = 0;
int scale = 0;
BigInteger intVal = (val == INFLATED) ? INFLATED_BIGINT : null;
if (mcp > 0) { // do rounding
if (val == INFLATED) {
prec = 19;
int drop = prec - mcp;
while (drop > 0) {
scale = checkScaleNonZero((long) scale - drop);
intVal = divideAndRoundByTenPow(intVal, drop, mode);
val = compactValFor(intVal);
if (val != INFLATED) {
break;
}
prec = bigDigitLength(intVal);
drop = prec - mcp;
}
}
if (val != INFLATED) {
prec = longDigitLength(val);
int drop = prec - mcp;
while (drop > 0) {
scale = checkScaleNonZero((long) scale - drop);
val = divideAndRound(val, LONG_TEN_POWERS_TABLE[drop], mc.roundingMode.oldMode);
prec = longDigitLength(val);
drop = prec - mcp;
}
intVal = null;
}
}
this.intVal = intVal;
this.intCompact = val;
this.scale = scale;
this.precision = prec;
} |
Translates a {@code long} into a {@code BigDecimal}, with
rounding according to the context settings. The scale of the
{@code BigDecimal}, before any rounding, is zero.
@param val {@code long} value to be converted to {@code BigDecimal}.
@param mc the context to use.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@since 1.5
| BigDecimal::BigDecimal | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public static BigDecimal valueOf(long unscaledVal, int scale) {
if (scale == 0)
return valueOf(unscaledVal);
else if (unscaledVal == 0) {
return zeroValueOf(scale);
}
return new BigDecimal(unscaledVal == INFLATED ?
INFLATED_BIGINT : null,
unscaledVal, scale, 0);
} |
Translates a {@code long} unscaled value and an
{@code int} scale into a {@code BigDecimal}. This
{@literal "static factory method"} is provided in preference to
a ({@code long}, {@code int}) constructor because it
allows for reuse of frequently used {@code BigDecimal} values..
@param unscaledVal unscaled value of the {@code BigDecimal}.
@param scale scale of the {@code BigDecimal}.
@return a {@code BigDecimal} whose value is
<tt>(unscaledVal × 10<sup>-scale</sup>)</tt>.
| BigDecimal::valueOf | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public static BigDecimal valueOf(long val) {
if (val >= 0 && val < zeroThroughTen.length)
return zeroThroughTen[(int)val];
else if (val != INFLATED)
return new BigDecimal(null, val, 0, 0);
return new BigDecimal(INFLATED_BIGINT, val, 0, 0);
} |
Translates a {@code long} value into a {@code BigDecimal}
with a scale of zero. This {@literal "static factory method"}
is provided in preference to a ({@code long}) constructor
because it allows for reuse of frequently used
{@code BigDecimal} values.
@param val value of the {@code BigDecimal}.
@return a {@code BigDecimal} whose value is {@code val}.
| BigDecimal::valueOf | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public static BigDecimal valueOf(double val) {
// Reminder: a zero double returns '0.0', so we cannot fastpath
// to use the constant ZERO. This might be important enough to
// justify a factory approach, a cache, or a few private
// constants, later.
return new BigDecimal(Double.toString(val));
} |
Translates a {@code double} into a {@code BigDecimal}, using
the {@code double}'s canonical string representation provided
by the {@link Double#toString(double)} method.
<p><b>Note:</b> This is generally the preferred way to convert
a {@code double} (or {@code float}) into a
{@code BigDecimal}, as the value returned is equal to that
resulting from constructing a {@code BigDecimal} from the
result of using {@link Double#toString(double)}.
@param val {@code double} to convert to a {@code BigDecimal}.
@return a {@code BigDecimal} whose value is equal to or approximately
equal to the value of {@code val}.
@throws NumberFormatException if {@code val} is infinite or NaN.
@since 1.5
| BigDecimal::valueOf | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal add(BigDecimal augend) {
if (this.intCompact != INFLATED) {
if ((augend.intCompact != INFLATED)) {
return add(this.intCompact, this.scale, augend.intCompact, augend.scale);
} else {
return add(this.intCompact, this.scale, augend.intVal, augend.scale);
}
} else {
if ((augend.intCompact != INFLATED)) {
return add(augend.intCompact, augend.scale, this.intVal, this.scale);
} else {
return add(this.intVal, this.scale, augend.intVal, augend.scale);
}
}
} |
Returns a {@code BigDecimal} whose value is {@code (this +
augend)}, and whose scale is {@code max(this.scale(),
augend.scale())}.
@param augend value to be added to this {@code BigDecimal}.
@return {@code this + augend}
| BigDecimal::add | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal add(BigDecimal augend, MathContext mc) {
if (mc.precision == 0)
return add(augend);
BigDecimal lhs = this;
// If either number is zero then the other number, rounded and
// scaled if necessary, is used as the result.
{
boolean lhsIsZero = lhs.signum() == 0;
boolean augendIsZero = augend.signum() == 0;
if (lhsIsZero || augendIsZero) {
int preferredScale = Math.max(lhs.scale(), augend.scale());
BigDecimal result;
if (lhsIsZero && augendIsZero)
return zeroValueOf(preferredScale);
result = lhsIsZero ? doRound(augend, mc) : doRound(lhs, mc);
if (result.scale() == preferredScale)
return result;
else if (result.scale() > preferredScale) {
return stripZerosToMatchScale(result.intVal, result.intCompact, result.scale, preferredScale);
} else { // result.scale < preferredScale
int precisionDiff = mc.precision - result.precision();
int scaleDiff = preferredScale - result.scale();
if (precisionDiff >= scaleDiff)
return result.setScale(preferredScale); // can achieve target scale
else
return result.setScale(result.scale() + precisionDiff);
}
}
}
long padding = (long) lhs.scale - augend.scale;
if (padding != 0) { // scales differ; alignment needed
BigDecimal arg[] = preAlign(lhs, augend, padding, mc);
matchScale(arg);
lhs = arg[0];
augend = arg[1];
}
return doRound(lhs.inflated().add(augend.inflated()), lhs.scale, mc);
} |
Returns a {@code BigDecimal} whose value is {@code (this + augend)},
with rounding according to the context settings.
If either number is zero and the precision setting is nonzero then
the other number, rounded if necessary, is used as the result.
@param augend value to be added to this {@code BigDecimal}.
@param mc the context to use.
@return {@code this + augend}, rounded as necessary.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@since 1.5
| BigDecimal::add | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
private BigDecimal[] preAlign(BigDecimal lhs, BigDecimal augend, long padding, MathContext mc) {
assert padding != 0;
BigDecimal big;
BigDecimal small;
if (padding < 0) { // lhs is big; augend is small
big = lhs;
small = augend;
} else { // lhs is small; augend is big
big = augend;
small = lhs;
}
/*
* This is the estimated scale of an ulp of the result; it assumes that
* the result doesn't have a carry-out on a true add (e.g. 999 + 1 =>
* 1000) or any subtractive cancellation on borrowing (e.g. 100 - 1.2 =>
* 98.8)
*/
long estResultUlpScale = (long) big.scale - big.precision() + mc.precision;
/*
* The low-order digit position of big is big.scale(). This
* is true regardless of whether big has a positive or
* negative scale. The high-order digit position of small is
* small.scale - (small.precision() - 1). To do the full
* condensation, the digit positions of big and small must be
* disjoint *and* the digit positions of small should not be
* directly visible in the result.
*/
long smallHighDigitPos = (long) small.scale - small.precision() + 1;
if (smallHighDigitPos > big.scale + 2 && // big and small disjoint
smallHighDigitPos > estResultUlpScale + 2) { // small digits not visible
small = BigDecimal.valueOf(small.signum(), this.checkScale(Math.max(big.scale, estResultUlpScale) + 3));
}
// Since addition is symmetric, preserving input order in
// returned operands doesn't matter
BigDecimal[] result = {big, small};
return result;
} |
Returns an array of length two, the sum of whose entries is
equal to the rounded sum of the {@code BigDecimal} arguments.
<p>If the digit positions of the arguments have a sufficient
gap between them, the value smaller in magnitude can be
condensed into a {@literal "sticky bit"} and the end result will
round the same way <em>if</em> the precision of the final
result does not include the high order digit of the small
magnitude operand.
<p>Note that while strictly speaking this is an optimization,
it makes a much wider range of additions practical.
<p>This corresponds to a pre-shift operation in a fixed
precision floating-point adder; this method is complicated by
variable precision of the result as determined by the
MathContext. A more nuanced operation could implement a
{@literal "right shift"} on the smaller magnitude operand so
that the number of digits of the smaller operand could be
reduced even though the significands partially overlapped.
| BigDecimal::preAlign | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal subtract(BigDecimal subtrahend) {
if (this.intCompact != INFLATED) {
if ((subtrahend.intCompact != INFLATED)) {
return add(this.intCompact, this.scale, -subtrahend.intCompact, subtrahend.scale);
} else {
return add(this.intCompact, this.scale, subtrahend.intVal.negate(), subtrahend.scale);
}
} else {
if ((subtrahend.intCompact != INFLATED)) {
// Pair of subtrahend values given before pair of
// values from this BigDecimal to avoid need for
// method overloading on the specialized add method
return add(-subtrahend.intCompact, subtrahend.scale, this.intVal, this.scale);
} else {
return add(this.intVal, this.scale, subtrahend.intVal.negate(), subtrahend.scale);
}
}
} |
Returns a {@code BigDecimal} whose value is {@code (this -
subtrahend)}, and whose scale is {@code max(this.scale(),
subtrahend.scale())}.
@param subtrahend value to be subtracted from this {@code BigDecimal}.
@return {@code this - subtrahend}
| BigDecimal::subtract | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal subtract(BigDecimal subtrahend, MathContext mc) {
if (mc.precision == 0)
return subtract(subtrahend);
// share the special rounding code in add()
return add(subtrahend.negate(), mc);
} |
Returns a {@code BigDecimal} whose value is {@code (this - subtrahend)},
with rounding according to the context settings.
If {@code subtrahend} is zero then this, rounded if necessary, is used as the
result. If this is zero then the result is {@code subtrahend.negate(mc)}.
@param subtrahend value to be subtracted from this {@code BigDecimal}.
@param mc the context to use.
@return {@code this - subtrahend}, rounded as necessary.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@since 1.5
| BigDecimal::subtract | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal multiply(BigDecimal multiplicand) {
int productScale = checkScale((long) scale + multiplicand.scale);
if (this.intCompact != INFLATED) {
if ((multiplicand.intCompact != INFLATED)) {
return multiply(this.intCompact, multiplicand.intCompact, productScale);
} else {
return multiply(this.intCompact, multiplicand.intVal, productScale);
}
} else {
if ((multiplicand.intCompact != INFLATED)) {
return multiply(multiplicand.intCompact, this.intVal, productScale);
} else {
return multiply(this.intVal, multiplicand.intVal, productScale);
}
}
} |
Returns a {@code BigDecimal} whose value is <tt>(this ×
multiplicand)</tt>, and whose scale is {@code (this.scale() +
multiplicand.scale())}.
@param multiplicand value to be multiplied by this {@code BigDecimal}.
@return {@code this * multiplicand}
| BigDecimal::multiply | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal multiply(BigDecimal multiplicand, MathContext mc) {
if (mc.precision == 0)
return multiply(multiplicand);
int productScale = checkScale((long) scale + multiplicand.scale);
if (this.intCompact != INFLATED) {
if ((multiplicand.intCompact != INFLATED)) {
return multiplyAndRound(this.intCompact, multiplicand.intCompact, productScale, mc);
} else {
return multiplyAndRound(this.intCompact, multiplicand.intVal, productScale, mc);
}
} else {
if ((multiplicand.intCompact != INFLATED)) {
return multiplyAndRound(multiplicand.intCompact, this.intVal, productScale, mc);
} else {
return multiplyAndRound(this.intVal, multiplicand.intVal, productScale, mc);
}
}
} |
Returns a {@code BigDecimal} whose value is <tt>(this ×
multiplicand)</tt>, with rounding according to the context settings.
@param multiplicand value to be multiplied by this {@code BigDecimal}.
@param mc the context to use.
@return {@code this * multiplicand}, rounded as necessary.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY}.
@since 1.5
| BigDecimal::multiply | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal divide(BigDecimal divisor, int scale, int roundingMode) {
if (roundingMode < ROUND_UP || roundingMode > ROUND_UNNECESSARY)
throw new IllegalArgumentException("Invalid rounding mode");
if (this.intCompact != INFLATED) {
if ((divisor.intCompact != INFLATED)) {
return divide(this.intCompact, this.scale, divisor.intCompact, divisor.scale, scale, roundingMode);
} else {
return divide(this.intCompact, this.scale, divisor.intVal, divisor.scale, scale, roundingMode);
}
} else {
if ((divisor.intCompact != INFLATED)) {
return divide(this.intVal, this.scale, divisor.intCompact, divisor.scale, scale, roundingMode);
} else {
return divide(this.intVal, this.scale, divisor.intVal, divisor.scale, scale, roundingMode);
}
}
} |
Returns a {@code BigDecimal} whose value is {@code (this /
divisor)}, and whose scale is as specified. If rounding must
be performed to generate a result with the specified scale, the
specified rounding mode is applied.
<p>The new {@link #divide(BigDecimal, int, RoundingMode)} method
should be used in preference to this legacy method.
@param divisor value by which this {@code BigDecimal} is to be divided.
@param scale scale of the {@code BigDecimal} quotient to be returned.
@param roundingMode rounding mode to apply.
@return {@code this / divisor}
@throws ArithmeticException if {@code divisor} is zero,
{@code roundingMode==ROUND_UNNECESSARY} and
the specified scale is insufficient to represent the result
of the division exactly.
@throws IllegalArgumentException if {@code roundingMode} does not
represent a valid rounding mode.
@see #ROUND_UP
@see #ROUND_DOWN
@see #ROUND_CEILING
@see #ROUND_FLOOR
@see #ROUND_HALF_UP
@see #ROUND_HALF_DOWN
@see #ROUND_HALF_EVEN
@see #ROUND_UNNECESSARY
| BigDecimal::divide | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal divide(BigDecimal divisor, int scale, RoundingMode roundingMode) {
return divide(divisor, scale, roundingMode.oldMode);
} |
Returns a {@code BigDecimal} whose value is {@code (this /
divisor)}, and whose scale is as specified. If rounding must
be performed to generate a result with the specified scale, the
specified rounding mode is applied.
@param divisor value by which this {@code BigDecimal} is to be divided.
@param scale scale of the {@code BigDecimal} quotient to be returned.
@param roundingMode rounding mode to apply.
@return {@code this / divisor}
@throws ArithmeticException if {@code divisor} is zero,
{@code roundingMode==RoundingMode.UNNECESSARY} and
the specified scale is insufficient to represent the result
of the division exactly.
@since 1.5
| BigDecimal::divide | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal divide(BigDecimal divisor, int roundingMode) {
return this.divide(divisor, scale, roundingMode);
} |
Returns a {@code BigDecimal} whose value is {@code (this /
divisor)}, and whose scale is {@code this.scale()}. If
rounding must be performed to generate a result with the given
scale, the specified rounding mode is applied.
<p>The new {@link #divide(BigDecimal, RoundingMode)} method
should be used in preference to this legacy method.
@param divisor value by which this {@code BigDecimal} is to be divided.
@param roundingMode rounding mode to apply.
@return {@code this / divisor}
@throws ArithmeticException if {@code divisor==0}, or
{@code roundingMode==ROUND_UNNECESSARY} and
{@code this.scale()} is insufficient to represent the result
of the division exactly.
@throws IllegalArgumentException if {@code roundingMode} does not
represent a valid rounding mode.
@see #ROUND_UP
@see #ROUND_DOWN
@see #ROUND_CEILING
@see #ROUND_FLOOR
@see #ROUND_HALF_UP
@see #ROUND_HALF_DOWN
@see #ROUND_HALF_EVEN
@see #ROUND_UNNECESSARY
| BigDecimal::divide | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal divide(BigDecimal divisor, RoundingMode roundingMode) {
return this.divide(divisor, scale, roundingMode.oldMode);
} |
Returns a {@code BigDecimal} whose value is {@code (this /
divisor)}, and whose scale is {@code this.scale()}. If
rounding must be performed to generate a result with the given
scale, the specified rounding mode is applied.
@param divisor value by which this {@code BigDecimal} is to be divided.
@param roundingMode rounding mode to apply.
@return {@code this / divisor}
@throws ArithmeticException if {@code divisor==0}, or
{@code roundingMode==RoundingMode.UNNECESSARY} and
{@code this.scale()} is insufficient to represent the result
of the division exactly.
@since 1.5
| BigDecimal::divide | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal divide(BigDecimal divisor) {
/*
* Handle zero cases first.
*/
if (divisor.signum() == 0) { // x/0
if (this.signum() == 0) // 0/0
throw new ArithmeticException("Division undefined"); // NaN
throw new ArithmeticException("Division by zero");
}
// Calculate preferred scale
int preferredScale = saturateLong((long) this.scale - divisor.scale);
if (this.signum() == 0) // 0/y
return zeroValueOf(preferredScale);
else {
/*
* If the quotient this/divisor has a terminating decimal
* expansion, the expansion can have no more than
* (a.precision() + ceil(10*b.precision)/3) digits.
* Therefore, create a MathContext object with this
* precision and do a divide with the UNNECESSARY rounding
* mode.
*/
MathContext mc = new MathContext( (int)Math.min(this.precision() +
(long)Math.ceil(10.0*divisor.precision()/3.0),
Integer.MAX_VALUE),
RoundingMode.UNNECESSARY);
BigDecimal quotient;
try {
quotient = this.divide(divisor, mc);
} catch (ArithmeticException e) {
throw new ArithmeticException("Non-terminating decimal expansion; " +
"no exact representable decimal result.");
}
int quotientScale = quotient.scale();
// divide(BigDecimal, mc) tries to adjust the quotient to
// the desired one by removing trailing zeros; since the
// exact divide method does not have an explicit digit
// limit, we can add zeros too.
if (preferredScale > quotientScale)
return quotient.setScale(preferredScale, ROUND_UNNECESSARY);
return quotient;
}
} |
Returns a {@code BigDecimal} whose value is {@code (this /
divisor)}, and whose preferred scale is {@code (this.scale() -
divisor.scale())}; if the exact quotient cannot be
represented (because it has a non-terminating decimal
expansion) an {@code ArithmeticException} is thrown.
@param divisor value by which this {@code BigDecimal} is to be divided.
@throws ArithmeticException if the exact quotient does not have a
terminating decimal expansion
@return {@code this / divisor}
@since 1.5
@author Joseph D. Darcy
| BigDecimal::divide | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal divide(BigDecimal divisor, MathContext mc) {
int mcp = mc.precision;
if (mcp == 0)
return divide(divisor);
BigDecimal dividend = this;
long preferredScale = (long)dividend.scale - divisor.scale;
// Now calculate the answer. We use the existing
// divide-and-round method, but as this rounds to scale we have
// to normalize the values here to achieve the desired result.
// For x/y we first handle y=0 and x=0, and then normalize x and
// y to give x' and y' with the following constraints:
// (a) 0.1 <= x' < 1
// (b) x' <= y' < 10*x'
// Dividing x'/y' with the required scale set to mc.precision then
// will give a result in the range 0.1 to 1 rounded to exactly
// the right number of digits (except in the case of a result of
// 1.000... which can arise when x=y, or when rounding overflows
// The 1.000... case will reduce properly to 1.
if (divisor.signum() == 0) { // x/0
if (dividend.signum() == 0) // 0/0
throw new ArithmeticException("Division undefined"); // NaN
throw new ArithmeticException("Division by zero");
}
if (dividend.signum() == 0) // 0/y
return zeroValueOf(saturateLong(preferredScale));
int xscale = dividend.precision();
int yscale = divisor.precision();
if(dividend.intCompact!=INFLATED) {
if(divisor.intCompact!=INFLATED) {
return divide(dividend.intCompact, xscale, divisor.intCompact, yscale, preferredScale, mc);
} else {
return divide(dividend.intCompact, xscale, divisor.intVal, yscale, preferredScale, mc);
}
} else {
if(divisor.intCompact!=INFLATED) {
return divide(dividend.intVal, xscale, divisor.intCompact, yscale, preferredScale, mc);
} else {
return divide(dividend.intVal, xscale, divisor.intVal, yscale, preferredScale, mc);
}
}
} |
Returns a {@code BigDecimal} whose value is {@code (this /
divisor)}, with rounding according to the context settings.
@param divisor value by which this {@code BigDecimal} is to be divided.
@param mc the context to use.
@return {@code this / divisor}, rounded as necessary.
@throws ArithmeticException if the result is inexact but the
rounding mode is {@code UNNECESSARY} or
{@code mc.precision == 0} and the quotient has a
non-terminating decimal expansion.
@since 1.5
| BigDecimal::divide | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal divideToIntegralValue(BigDecimal divisor) {
// Calculate preferred scale
int preferredScale = saturateLong((long) this.scale - divisor.scale);
if (this.compareMagnitude(divisor) < 0) {
// much faster when this << divisor
return zeroValueOf(preferredScale);
}
if (this.signum() == 0 && divisor.signum() != 0)
return this.setScale(preferredScale, ROUND_UNNECESSARY);
// Perform a divide with enough digits to round to a correct
// integer value; then remove any fractional digits
int maxDigits = (int)Math.min(this.precision() +
(long)Math.ceil(10.0*divisor.precision()/3.0) +
Math.abs((long)this.scale() - divisor.scale()) + 2,
Integer.MAX_VALUE);
BigDecimal quotient = this.divide(divisor, new MathContext(maxDigits,
RoundingMode.DOWN));
if (quotient.scale > 0) {
quotient = quotient.setScale(0, RoundingMode.DOWN);
quotient = stripZerosToMatchScale(quotient.intVal, quotient.intCompact, quotient.scale, preferredScale);
}
if (quotient.scale < preferredScale) {
// pad with zeros if necessary
quotient = quotient.setScale(preferredScale, ROUND_UNNECESSARY);
}
return quotient;
} |
Returns a {@code BigDecimal} whose value is the integer part
of the quotient {@code (this / divisor)} rounded down. The
preferred scale of the result is {@code (this.scale() -
divisor.scale())}.
@param divisor value by which this {@code BigDecimal} is to be divided.
@return The integer part of {@code this / divisor}.
@throws ArithmeticException if {@code divisor==0}
@since 1.5
| BigDecimal::divideToIntegralValue | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal divideToIntegralValue(BigDecimal divisor, MathContext mc) {
if (mc.precision == 0 || // exact result
(this.compareMagnitude(divisor) < 0)) // zero result
return divideToIntegralValue(divisor);
// Calculate preferred scale
int preferredScale = saturateLong((long)this.scale - divisor.scale);
/*
* Perform a normal divide to mc.precision digits. If the
* remainder has absolute value less than the divisor, the
* integer portion of the quotient fits into mc.precision
* digits. Next, remove any fractional digits from the
* quotient and adjust the scale to the preferred value.
*/
BigDecimal result = this.divide(divisor, new MathContext(mc.precision, RoundingMode.DOWN));
if (result.scale() < 0) {
/*
* Result is an integer. See if quotient represents the
* full integer portion of the exact quotient; if it does,
* the computed remainder will be less than the divisor.
*/
BigDecimal product = result.multiply(divisor);
// If the quotient is the full integer value,
// |dividend-product| < |divisor|.
if (this.subtract(product).compareMagnitude(divisor) >= 0) {
throw new ArithmeticException("Division impossible");
}
} else if (result.scale() > 0) {
/*
* Integer portion of quotient will fit into precision
* digits; recompute quotient to scale 0 to avoid double
* rounding and then try to adjust, if necessary.
*/
result = result.setScale(0, RoundingMode.DOWN);
}
// else result.scale() == 0;
int precisionDiff;
if ((preferredScale > result.scale()) &&
(precisionDiff = mc.precision - result.precision()) > 0) {
return result.setScale(result.scale() +
Math.min(precisionDiff, preferredScale - result.scale) );
} else {
return stripZerosToMatchScale(result.intVal,result.intCompact,result.scale,preferredScale);
}
} |
Returns a {@code BigDecimal} whose value is the integer part
of {@code (this / divisor)}. Since the integer part of the
exact quotient does not depend on the rounding mode, the
rounding mode does not affect the values returned by this
method. The preferred scale of the result is
{@code (this.scale() - divisor.scale())}. An
{@code ArithmeticException} is thrown if the integer part of
the exact quotient needs more than {@code mc.precision}
digits.
@param divisor value by which this {@code BigDecimal} is to be divided.
@param mc the context to use.
@return The integer part of {@code this / divisor}.
@throws ArithmeticException if {@code divisor==0}
@throws ArithmeticException if {@code mc.precision} {@literal >} 0 and the result
requires a precision of more than {@code mc.precision} digits.
@since 1.5
@author Joseph D. Darcy
| BigDecimal::divideToIntegralValue | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
public BigDecimal remainder(BigDecimal divisor) {
BigDecimal divrem[] = this.divideAndRemainder(divisor);
return divrem[1];
} |
Returns a {@code BigDecimal} whose value is {@code (this % divisor)}.
<p>The remainder is given by
{@code this.subtract(this.divideToIntegralValue(divisor).multiply(divisor))}.
Note that this is not the modulo operation (the result can be
negative).
@param divisor value by which this {@code BigDecimal} is to be divided.
@return {@code this % divisor}.
@throws ArithmeticException if {@code divisor==0}
@since 1.5
| BigDecimal::remainder | java | google/j2objc | jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | https://github.com/google/j2objc/blob/master/jre_emul/openjdk/src/share/classes/java/math/BigDecimal.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.