code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public MediaCreditList getSeasonCredits(int tvID, int seasonNumber) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SEASON_NUMBER, seasonNumber);
URL url = new ApiUrl(apiKey, MethodBase.SEASON).subMethod(Me... | java |
public URL buildUrl(final TmdbParameters params) {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
LOG.trace("Method: '{}', Sub-method: '{}', Params: {}", method.getValue(), submethod.getValue(),
ToStringBuilder.reflectionToString(params, ToStringStyle.SHORT_PREFIX_STYLE));
... | java |
private StringBuilder queryProcessing(TmdbParameters params) {
StringBuilder urlString = new StringBuilder();
// Append the suffix of the API URL
if (submethod != MethodSub.NONE) {
urlString.append("/").append(submethod.getValue());
}
// Append the key information
... | java |
private StringBuilder idProcessing(final TmdbParameters params) {
StringBuilder urlString = new StringBuilder();
// Append the ID
if (params.has(Param.ID)) {
urlString.append("/").append(params.get(Param.ID));
}
if (params.has(Param.SEASON_NUMBER)) {
url... | java |
private StringBuilder otherProcessing(final TmdbParameters params) {
StringBuilder urlString = new StringBuilder();
for (Map.Entry<Param, String> argEntry : params.getEntries()) {
// Skip the ID an QUERY params
if (IGNORE_PARAMS.contains(argEntry.getKey())) {
con... | java |
public Review getReview(String reviewId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, reviewId);
URL url = new ApiUrl(apiKey, MethodBase.REVIEW).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
... | java |
private String convertToJson(Map<String, ?> map) throws MovieDbException {
try {
return MAPPER.writeValueAsString(map);
} catch (JsonProcessingException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "JSON conversion failed", "", ex);
}
} | java |
public ResultList<ChangeListItem> getChangeList(MethodBase method, Integer page, String startDate, String endDate) throws MovieDbException {
TmdbParameters params = new TmdbParameters();
params.add(Param.PAGE, page);
params.add(Param.START_DATE, startDate);
params.add(Param.END_DATE, end... | java |
public Discover year(int year) {
if (checkYear(year)) {
params.add(Param.YEAR, year);
}
return this;
} | java |
public Discover primaryReleaseYear(int primaryReleaseYear) {
if (checkYear(primaryReleaseYear)) {
params.add(Param.PRIMARY_RELEASE_YEAR, primaryReleaseYear);
}
return this;
} | java |
public Discover firstAirDateYear(int year) {
if (checkYear(year)) {
params.add(Param.FIRST_AIR_DATE_YEAR, year);
}
return this;
} | java |
public Discover firstAirDateYearGte(int year) {
if (checkYear(year)) {
params.add(Param.FIRST_AIR_DATE_GTE, year);
}
return this;
} | java |
public Discover firstAirDateYearLte(int year) {
if (checkYear(year)) {
params.add(Param.FIRST_AIR_DATE_LTE, year);
}
return this;
} | java |
public boolean isValidPosterSize(String posterSize) {
if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) {
return false;
}
return posterSizes.contains(posterSize);
} | java |
public boolean isValidBackdropSize(String backdropSize) {
if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) {
return false;
}
return backdropSizes.contains(backdropSize);
} | java |
public boolean isValidProfileSize(String profileSize) {
if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) {
return false;
}
return profileSizes.contains(profileSize);
} | java |
public boolean isValidLogoSize(String logoSize) {
if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) {
return false;
}
return logoSizes.contains(logoSize);
} | java |
public boolean isValidSize(String sizeToCheck) {
return isValidPosterSize(sizeToCheck)
|| isValidBackdropSize(sizeToCheck)
|| isValidProfileSize(sizeToCheck)
|| isValidLogoSize(sizeToCheck);
} | java |
public ListItem<MovieInfo> getList(String listId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, listId);
URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
... | java |
public boolean checkItemStatus(String listId, int mediaId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, listId);
parameters.add(Param.MOVIE_ID, mediaId);
URL url = new ApiUrl(apiKey, MethodBase.LIST).subMethod(MethodSub.ITEM_STATUS... | java |
private StatusCode modifyMovieList(String sessionId, String listId, int movieId, MethodSub operation) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION_ID, sessionId);
parameters.add(Param.ID, listId);
String jsonBody = new PostTool... | java |
public StatusCode removeItem(String sessionId, String listId, int mediaId) throws MovieDbException {
return modifyMovieList(sessionId, listId, mediaId, MethodSub.REMOVE_ITEM);
} | java |
public StatusCode clear(String sessionId, String listId, boolean confirm) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION_ID, sessionId);
parameters.add(Param.ID, listId);
parameters.add(Param.CONFIRM, confirm);
URL url = ... | java |
public Keyword getKeyword(String keywordId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, keywordId);
URL url = new ApiUrl(apiKey, MethodBase.KEYWORD).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
... | java |
public String getRequest(final URL url) throws MovieDbException {
try {
HttpGet httpGet = new HttpGet(url.toURI());
httpGet.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON);
DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET);
... | java |
private void delay(long multiplier) {
try {
// Wait for the timeout to finish
Thread.sleep(TimeUnit.SECONDS.toMillis(RETRY_DELAY * multiplier));
} catch (InterruptedException ex) {
// Doesn't matter if we're interrupted
}
} | java |
public String deleteRequest(final URL url) throws MovieDbException {
try {
HttpDelete httpDel = new HttpDelete(url.toURI());
return validateResponse(DigestedResponseReader.deleteContent(httpClient, httpDel, CHARSET), url);
} catch (URISyntaxException | IOException ex) {
... | java |
public String postRequest(final URL url, final String jsonBody) throws MovieDbException {
try {
HttpPost httpPost = new HttpPost(url.toURI());
httpPost.addHeader(HTTP.CONTENT_TYPE, APPLICATION_JSON);
httpPost.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON);
String... | java |
private String validateResponse(final DigestedResponse response, final URL url) throws MovieDbException {
if (response.getStatusCode() == 0) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, response.getContent(), response.getStatusCode(), url, null);
} else if (response.getSta... | java |
public void add(final Param key, final String[] value) {
if (value != null && value.length > 0) {
parameters.put(key, toList(value));
}
} | java |
public void add(final Param key, final String value) {
if (StringUtils.isNotBlank(value)) {
parameters.put(key, value);
}
} | java |
public void add(final Param key, final Integer value) {
if (value != null && value > 0) {
parameters.put(key, String.valueOf(value));
}
} | java |
public String toList(final String[] appendToResponse) {
StringBuilder sb = new StringBuilder();
boolean first = Boolean.TRUE;
for (String append : appendToResponse) {
if (first) {
first = Boolean.FALSE;
} else {
sb.append(",");
... | java |
protected static TypeReference getTypeReference(Class aClass) throws MovieDbException {
if (TYPE_REFS.containsKey(aClass)) {
return TYPE_REFS.get(aClass);
} else {
throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Class type reference for '" + aClass.getSimpleName() + "... | java |
protected <T> List<T> processWrapperList(TypeReference typeRef, URL url, String errorMessageSuffix) throws MovieDbException {
WrapperGenericList<T> val = processWrapper(typeRef, url, errorMessageSuffix);
return val.getResults();
} | java |
protected <T> WrapperGenericList<T> processWrapper(TypeReference typeRef, URL url, String errorMessageSuffix) throws MovieDbException {
String webpage = httpTools.getRequest(url);
try {
// Due to type erasure, this doesn't work
// TypeReference<WrapperGenericList<T>> typeRef = ne... | java |
public ResultList<JobDepartment> getJobs() throws MovieDbException {
URL url = new ApiUrl(apiKey, MethodBase.JOB).subMethod(MethodSub.LIST).buildUrl();
String webpage = httpTools.getRequest(url);
try {
WrapperJobList wrapper = MAPPER.readValue(webpage, WrapperJobList.class);
... | java |
public ResultsMap<String, List<String>> getTimezones() throws MovieDbException {
URL url = new ApiUrl(apiKey, MethodBase.TIMEZONES).subMethod(MethodSub.LIST).buildUrl();
String webpage = httpTools.getRequest(url);
List<Map<String, List<String>>> tzList;
try {
tzList = MAPPER... | java |
public ResultList<Genre> getGenreMovieList(String language) throws MovieDbException {
return getGenreList(language, MethodSub.MOVIE_LIST);
} | java |
public ResultList<Genre> getGenreTVList(String language) throws MovieDbException {
return getGenreList(language, MethodSub.TV_LIST);
} | java |
private ResultList<Genre> getGenreList(String language, MethodSub sub) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.GENRE).subMethod(sub).buildUrl(parameters);
String webpage... | java |
public ResultList<MovieBasic> getGenreMovies(int genreId, String language, Integer page, Boolean includeAllMovies, Boolean includeAdult) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, genreId);
parameters.add(Param.LANGUAGE, language);
... | java |
public ResultList<ChangeKeyItem> getEpisodeChanges(int episodeID, String startDate, String endDate) throws MovieDbException {
return getMediaChanges(episodeID, startDate, endDate);
} | java |
public Account getAccount(String sessionId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION_ID, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
... | java |
public StatusCode modifyWatchList(String sessionId, int accountId, MediaType mediaType, Integer movieId, boolean addToWatchlist) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION_ID, sessionId);
parameters.add(Param.ID, accountId);
... | java |
public Company getCompanyInfo(int companyId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, companyId);
URL url = new ApiUrl(apiKey, MethodBase.COMPANY).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {... | java |
public ResultList<AlternativeTitle> getTVAlternativeTitles(int tvID) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.ALT_TITLES).buildUrl(parameters);
WrapperGener... | java |
public ResultList<ChangeKeyItem> getTVChanges(int tvID, String startDate, String endDate) throws MovieDbException {
return getMediaChanges(tvID, startDate, endDate);
} | java |
public ResultList<ContentRating> getTVContentRatings(int tvID) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.CONTENT_RATINGS).buildUrl(parameters);
WrapperGeneri... | java |
public ResultList<Keyword> getTVKeywords(int tvID) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.KEYWORDS).buildUrl(parameters);
WrapperGenericList<Keyword> wrap... | java |
protected void init() {
Log.d(TAG, "init");
if (isInEditMode())
return;
this.mediaPlayer = null;
this.shouldAutoplay = false;
this.fullscreen = false;
this.initialConfigOrientation = -1;
this.videoIsReady = false;
this.surfaceIsReady = false;... | java |
protected void release() {
Log.d(TAG, "release");
releaseObjects();
if (this.mediaPlayer != null) {
this.mediaPlayer.setOnBufferingUpdateListener(null);
this.mediaPlayer.setOnPreparedListener(null);
this.mediaPlayer.setOnErrorListener(null);
this.... | java |
protected void initObjects() {
Log.d(TAG, "initObjects");
if (this.mediaPlayer == null) {
this.mediaPlayer = new MediaPlayer();
this.mediaPlayer.setOnInfoListener(this);
this.mediaPlayer.setOnErrorListener(this);
this.mediaPlayer.setOnPreparedListener(thi... | java |
protected void releaseObjects() {
Log.d(TAG, "releaseObjects");
if (this.mediaPlayer != null) {
this.mediaPlayer.setSurface(null);
this.mediaPlayer.reset();
}
this.videoIsReady = false;
this.surfaceIsReady = false;
this.initialMovieHeight = -1;
... | java |
protected void tryToPrepare() {
Log.d(TAG, "tryToPrepare");
if (this.surfaceIsReady && this.videoIsReady) {
if (this.mediaPlayer != null &&
this.mediaPlayer.getVideoWidth() != 0 &&
this.mediaPlayer.getVideoHeight() != 0) {
this.initialM... | java |
public void setFullscreen(final boolean fullscreen) throws RuntimeException {
if (mediaPlayer == null)
throw new RuntimeException("Media Player is not initialized");
if (this.currentState != State.ERROR) {
if (FullscreenVideoView.this.fullscreen == fullscreen) return;
... | java |
@Override
public void onClick(View v) {
if (v.getId() == R.id.vcv_img_play) {
if (isPlaying()) {
pause();
} else {
start();
}
} else {
setFullscreen(!isFullscreen());
}
} | java |
public void populate(final AnnotationData data, final Annotation annotation, final Class<? extends Annotation> expectedAnnotationClass,
final Method targetMethod) throws Exception {
if (support(expectedAnnotationClass)) {
build(data, annotation, expectedAnnotationClass, targetMethod);
... | java |
protected Cache createCache() throws IOException {
// this factory creates only one single cache and return it if someone invoked this method twice or
// more
if (cache != null) {
throw new IllegalStateException(String.format("This factory has already created memcached client for cac... | java |
@Override
public String getCacheKey(final Object keyObject, final String namespace) {
return namespace + SEPARATOR + defaultKeyProvider.generateKey(keyObject);
} | java |
private String buildCacheKey(final String[] objectIds, final String namespace) {
if (objectIds.length == 1) {
checkKeyPart(objectIds[0]);
return namespace + SEPARATOR + objectIds[0];
}
StringBuilder cacheKey = new StringBuilder(namespace);
cacheKey.append(SEPARAT... | java |
public void removeCache(final String nameOrAlias) {
final Cache cache = cacheMap.get(nameOrAlias);
if (cache == null) {
return;
}
final SSMCache ssmCache = (SSMCache) cache;
if (ssmCache.isRegisterAliases()) {
ssmCache.getCache().getAliases().forE... | java |
protected Object deserialize(final byte[] in) {
Object o = null;
ByteArrayInputStream bis = null;
ConfigurableObjectInputStream is = null;
try {
if (in != null) {
bis = new ByteArrayInputStream(in);
is = new ConfigurableObjectInputStream(bis, ... | java |
@Override
@SuppressWarnings("unchecked")
public <T> T get(final Object key, final Class<T> type) {
if (!cache.isEnabled()) {
LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key);
return null;
}
Object value = getValue(key);
... | java |
@Override
@SuppressWarnings("unchecked")
public <T> T get(final Object key, final Callable<T> valueLoader) {
if (!cache.isEnabled()) {
LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key);
return loadValue(key, valueLoader);
}
final ... | java |
@Override
public ValueWrapper putIfAbsent(final Object key, final Object value) {
if (!cache.isEnabled()) {
LOGGER.warn("Cache {} is disabled. Cannot put value under key {}", cache.getName(), key);
return null;
}
if (key != null) {
final String cacheKey =... | java |
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Seq toScalaSeq(Object[] o) {
ArrayList list = new ArrayList();
for (int i = 0; i < o.length; i++) {
list.add(o[i]);
}
return scala.collection.JavaConversions.asScalaBuffer(list).toList();
} | java |
public static UnsignedInteger64 add(UnsignedInteger64 x, UnsignedInteger64 y) {
return new UnsignedInteger64(x.bigInt.add(y.bigInt));
} | java |
public static UnsignedInteger64 add(UnsignedInteger64 x, int y) {
return new UnsignedInteger64(x.bigInt.add(BigInteger.valueOf(y)));
} | java |
public byte[] toByteArray() {
byte[] raw = new byte[8];
byte[] bi = bigIntValue().toByteArray();
System.arraycopy(bi, 0, raw, raw.length - bi.length, bi.length);
return raw;
} | java |
public void remove(SshPublicKey key) throws SshException,
PublicKeySubsystemException {
try {
Packet msg = createPacket();
msg.writeString("remove");
msg.writeString(key.getAlgorithm());
msg.writeBinaryString(key.getEncoded());
sendMessage(msg);
readStatusResponse();
} catch (IOException e... | java |
public SshPublicKey[] list() throws SshException,
PublicKeySubsystemException {
try {
Packet msg = createPacket();
msg.writeString("list");
sendMessage(msg);
Vector<SshPublicKey> keys = new Vector<SshPublicKey>();
while (true) {
ByteArrayReader response = new ByteArrayReader(nextMessage());... | java |
public void associateCommand(SshPublicKey key, String command)
throws SshException, PublicKeySubsystemException {
try {
Packet msg = createPacket();
msg.writeString("command");
msg.writeString(key.getAlgorithm());
msg.writeBinaryString(key.getEncoded());
msg.writeString(command);
sendMessage(m... | java |
void readStatusResponse() throws SshException, PublicKeySubsystemException {
ByteArrayReader msg = new ByteArrayReader(nextMessage());
try {
msg.readString();
int status = (int) msg.readInt();
String desc = msg.readString();
if (status != PublicKeySubsystemException.SUCCESS) {
throw new PublicKe... | java |
public void setTerminalMode(int mode, int value) throws SshException {
try {
encodedModes.write(mode);
if (version == 1 && mode <= 127) {
encodedModes.write(value);
} else {
encodedModes.writeInt(value);
}
} catch (IOException ex) {
throw new SshException(SshException.INTERNAL_ERROR, ex);
... | java |
protected ProxyMessage exchange(ProxyMessage request)
throws SocksException{
ProxyMessage reply;
try{
request.write(out);
reply = formMessage(in);
}catch(SocksException s_ex){
throw s_ex;
}catch(IOException ioe){
throw(new SocksExcep... | java |
public String[] matchFileNamesWithPattern(File[] files,
String fileNameRegExp) throws SshException, SftpStatusException {
String[] thefile = new String[1];
thefile[0] = files[0].getName();
return thefile;
} | java |
public synchronized void addListener(String threadPrefix,
EventListener listener) {
if (threadPrefix.trim().equals("")) {
globalListeners.addElement(listener);
} else {
keyedListeners.put(threadPrefix.trim(), listener);
}
} | java |
public synchronized void fireEvent(Event evt) {
if (evt == null) {
return;
}
// Process global listeners
for (Enumeration<EventListener> keys = globalListeners.elements(); keys
.hasMoreElements();) {
EventListener mListener = keys.nextElement();
try {
mListener.processEvent(evt);
} catch (T... | java |
public void close() throws IOException {
try {
while (processNextResponse(0))
;
file.close();
} catch (SshException ex) {
throw new SshIOException(ex);
} catch (SftpStatusException ex) {
throw new IOException(ex.getMessage());
}
} | java |
public static void setCharsetEncoding(String charset) {
try {
String test = "123456890";
test.getBytes(charset);
CHARSET_ENCODING = charset;
encode = true;
} catch (UnsupportedEncodingException ex) {
// Reset the encoding to default
CHARSET_ENCODING = "";
encode = false;
}
} | java |
public BigInteger readBigInteger() throws IOException {
int len = (int) readInt();
byte[] raw = new byte[len];
readFully(raw);
return new BigInteger(raw);
} | java |
public String readString(String charset) throws IOException {
long len = readInt();
if (len > available())
throw new IOException("Cannot read string of length " + len
+ " bytes when only " + available()
+ " bytes are available");
byte[] raw = new byte[(int) len];
readFully(raw);
if (encode) {
... | java |
public BigInteger readMPINT32() throws IOException {
int bits = (int) readInt();
byte[] raw = new byte[(bits + 7) / 8 + 1];
raw[0] = 0;
readFully(raw, 1, raw.length - 1);
return new BigInteger(raw);
} | java |
public BigInteger readMPINT() throws IOException {
short bits = readShort();
byte[] raw = new byte[(bits + 7) / 8 + 1];
raw[0] = 0;
readFully(raw, 1, raw.length - 1);
return new BigInteger(raw);
} | java |
public static SocksProxyTransport connectViaSocks4Proxy(String remoteHost,
int remotePort, String proxyHost, int proxyPort, String userId)
throws IOException, UnknownHostException {
SocksProxyTransport proxySocket = new SocksProxyTransport(remoteHost,
remotePort, proxyHost, proxyPort, SOCKS4);
proxySocket... | java |
protected void sendMessage(byte[] msg) throws SshException {
try {
Packet pkt = createPacket();
pkt.write(msg);
sendMessage(pkt);
} catch (IOException ex) {
throw new SshException(SshException.UNEXPECTED_TERMINATION, ex);
}
} | java |
protected Packet createPacket() throws IOException {
synchronized (packets) {
if (packets.size() == 0)
return new Packet();
Packet p = (Packet) packets.elementAt(0);
packets.removeElementAt(0);
return p;
}
} | java |
public static SshKeyPair generateKeyPair(String algorithm, int bits)
throws IOException, SshException {
if (!SSH2_RSA.equalsIgnoreCase(algorithm)
&& !SSH2_DSA.equalsIgnoreCase(algorithm)) {
throw new IOException(algorithm
+ " is not a supported key algorithm!");
}
SshKeyPair pair = new SshKeyPair... | java |
public void setUID(String uid) {
if (version > 3) {
flags |= SSH_FILEXFER_ATTR_OWNERGROUP;
} else
flags |= SSH_FILEXFER_ATTR_UIDGID;
this.uid = uid;
} | java |
public void setGID(String gid) {
if (version > 3) {
flags |= SSH_FILEXFER_ATTR_OWNERGROUP;
} else
flags |= SSH_FILEXFER_ATTR_UIDGID;
this.gid = gid;
} | java |
public void setSize(UnsignedInteger64 size) {
this.size = size;
// Set the flag
if (size != null) {
flags |= SSH_FILEXFER_ATTR_SIZE;
} else {
flags ^= SSH_FILEXFER_ATTR_SIZE;
}
} | java |
public void setPermissions(UnsignedInteger32 permissions) {
this.permissions = permissions;
// Set the flag
if (permissions != null) {
flags |= SSH_FILEXFER_ATTR_PERMISSIONS;
} else {
flags ^= SSH_FILEXFER_ATTR_PERMISSIONS;
}
} | java |
public void setPermissionsFromMaskString(String mask) {
if (mask.length() != 4) {
throw new IllegalArgumentException("Mask length must be 4");
}
try {
setPermissions(new UnsignedInteger32(String.valueOf(Integer
.parseInt(mask, 8))));
} catch (NumberFormatException nfe) {
throw new IllegalArgument... | java |
public void setPermissionsFromUmaskString(String umask) {
if (umask.length() != 4) {
throw new IllegalArgumentException("umask length must be 4");
}
try {
setPermissions(new UnsignedInteger32(String.valueOf(Integer
.parseInt(umask, 8) ^ 0777)));
} catch (NumberFormatException ex) {
throw new Ille... | java |
public String getMaskString() {
StringBuffer buf = new StringBuffer();
if (permissions != null) {
int i = (int) permissions.longValue();
buf.append('0');
buf.append(octal(i, 6));
buf.append(octal(i, 3));
buf.append(octal(i, 0));
} else {
buf.append("----");
}
return buf.toString();
} | java |
public boolean isDirectory() {
if (sftp.getVersion() > 3) {
return type == SSH_FILEXFER_TYPE_DIRECTORY;
} else if (permissions != null
&& (permissions.longValue() & SftpFileAttributes.S_IFDIR) == SftpFileAttributes.S_IFDIR) {
return true;
} else {
return false;
}
} | java |
public boolean isLink() {
if (sftp.getVersion() > 3) {
return type == SSH_FILEXFER_TYPE_SYMLINK;
} else if (permissions != null
&& (permissions.longValue() & SftpFileAttributes.S_IFLNK) == SftpFileAttributes.S_IFLNK) {
return true;
} else {
return false;
}
} | java |
public boolean isFifo() {
if (permissions != null
&& (permissions.longValue() & SftpFileAttributes.S_IFIFO) == SftpFileAttributes.S_IFIFO) {
return true;
}
return false;
} | java |
public boolean isBlock() {
if (permissions != null
&& (permissions.longValue() & SftpFileAttributes.S_IFBLK) == SftpFileAttributes.S_IFBLK) {
return true;
}
return false;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.