use of java.lang.IllegalArgumentException in project clochure by videlalvaro.
the class LispReader method readUnicodeChar.
private static int readUnicodeChar(String token, int offset, int length, int base) {
if (token.length() != offset + length)
throw new IllegalArgumentException("Invalid unicode character: \\" + token);
int uc = 0;
for (int i = offset; i < offset + length; ++i) {
int d = Character.digit(token.charAt(i), base);
if (d == -1)
throw new IllegalArgumentException("Invalid digit: " + token.charAt(i));
uc = uc * base + d;
}
return (char) uc;
}
use of java.lang.IllegalArgumentException in project clochure by videlalvaro.
the class LispReader method readUnicodeChar.
private static int readUnicodeChar(PushbackReader r, int initch, int base, int length, boolean exact) {
int uc = Character.digit(initch, base);
if (uc == -1)
throw new IllegalArgumentException("Invalid digit: " + (char) initch);
int i = 1;
for (; i < length; ++i) {
int ch = read1(r);
if (ch == -1 || isWhitespace(ch) || isMacro(ch)) {
unread(r, ch);
break;
}
int d = Character.digit(ch, base);
if (d == -1)
throw new IllegalArgumentException("Invalid digit: " + (char) ch);
uc = uc * base + d;
}
if (i != length && exact)
throw new IllegalArgumentException("Invalid character length: " + i + ", should be: " + length);
return uc;
}
use of java.lang.IllegalArgumentException in project android_frameworks_base by AOSPA.
the class MediaSource method setupMediaPlayer.
/** Creates a media player, sets it up, and calls prepare */
private synchronized boolean setupMediaPlayer(boolean useUrl) {
mPrepared = false;
mGotSize = false;
mPlaying = false;
mPaused = false;
mCompleted = false;
mNewFrameAvailable = false;
if (mLogVerbose)
Log.v(TAG, "Setting up playback.");
if (mMediaPlayer != null) {
// Clean up existing media players
if (mLogVerbose)
Log.v(TAG, "Resetting existing MediaPlayer.");
mMediaPlayer.reset();
} else {
// Create new media player
if (mLogVerbose)
Log.v(TAG, "Creating new MediaPlayer.");
mMediaPlayer = new MediaPlayer();
}
if (mMediaPlayer == null) {
throw new RuntimeException("Unable to create a MediaPlayer!");
}
// Set up data sources, etc
try {
if (useUrl) {
if (mLogVerbose)
Log.v(TAG, "Setting MediaPlayer source to URI " + mSourceUrl);
if (mContext == null) {
mMediaPlayer.setDataSource(mSourceUrl);
} else {
mMediaPlayer.setDataSource(mContext, Uri.parse(mSourceUrl.toString()));
}
} else {
if (mLogVerbose)
Log.v(TAG, "Setting MediaPlayer source to asset " + mSourceAsset);
mMediaPlayer.setDataSource(mSourceAsset.getFileDescriptor(), mSourceAsset.getStartOffset(), mSourceAsset.getLength());
}
} catch (IOException e) {
mMediaPlayer.release();
mMediaPlayer = null;
if (useUrl) {
throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
} else {
throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
}
} catch (IllegalArgumentException e) {
mMediaPlayer.release();
mMediaPlayer = null;
if (useUrl) {
throw new RuntimeException(String.format("Unable to set MediaPlayer to URL %s!", mSourceUrl), e);
} else {
throw new RuntimeException(String.format("Unable to set MediaPlayer to asset %s!", mSourceAsset), e);
}
}
mMediaPlayer.setLooping(mLooping);
mMediaPlayer.setVolume(mVolume, mVolume);
// Bind it to our media frame
Surface surface = new Surface(mSurfaceTexture);
mMediaPlayer.setSurface(surface);
surface.release();
// Connect Media Player to callbacks
mMediaPlayer.setOnVideoSizeChangedListener(onVideoSizeChangedListener);
mMediaPlayer.setOnPreparedListener(onPreparedListener);
mMediaPlayer.setOnCompletionListener(onCompletionListener);
// Connect SurfaceTexture to callback
mSurfaceTexture.setOnFrameAvailableListener(onMediaFrameAvailableListener);
if (mLogVerbose)
Log.v(TAG, "Preparing MediaPlayer.");
mMediaPlayer.prepareAsync();
return true;
}
use of java.lang.IllegalArgumentException in project XobotOS by xamarin.
the class SIPDate method setSecond.
/**
* Set the second member
* @param s int to set
* @throws IllegalArgumentException if s is not a valid second
*/
public void setSecond(int s) throws IllegalArgumentException {
if (s < 0 || s >= 60)
throw new IllegalArgumentException("Illegal second : " + Integer.toString(s));
javaCal = null;
second = s;
}
use of java.lang.IllegalArgumentException in project XobotOS by xamarin.
the class SIPDate method setMinute.
/**
* Set the minute member
* @param m int to set
* @throws IllegalArgumentException if m is not a valid minute
*/
public void setMinute(int m) throws IllegalArgumentException {
if (m < 0 || m >= 60)
throw new IllegalArgumentException("Illegal minute : " + (Integer.toString(m)));
javaCal = null;
minute = m;
}
Aggregations