repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/UserShortenCountsExpandedRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserShortenCountsExpandedResponse.java
// public class UserShortenCountsExpandedResponse extends MetricsResponse {
//
// /** the user shorten counts grouped by unit */
// public List<UserShortenCount> user_shorten_counts;
//
// /** a bucket for a single unit of time */
// public static class UserShortenCount extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public DateTime dt;
//
// /** the number of shortens made by the specified user in the specified time */
// public long shortens;
// }
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserShortenCountsExpandedResponse;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_shorten_counts">/v3/user/shorten_counts</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserShortenCountsExpandedRequest extends MetricsExpandedRequest<UserShortenCountsExpandedRequest, UserShortenCountsExpandedResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserShortenCountsExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/shorten_counts";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserShortenCountsExpandedResponse.java
// public class UserShortenCountsExpandedResponse extends MetricsResponse {
//
// /** the user shorten counts grouped by unit */
// public List<UserShortenCount> user_shorten_counts;
//
// /** a bucket for a single unit of time */
// public static class UserShortenCount extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public DateTime dt;
//
// /** the number of shortens made by the specified user in the specified time */
// public long shortens;
// }
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/UserShortenCountsExpandedRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserShortenCountsExpandedResponse;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_shorten_counts">/v3/user/shorten_counts</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserShortenCountsExpandedRequest extends MetricsExpandedRequest<UserShortenCountsExpandedRequest, UserShortenCountsExpandedResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserShortenCountsExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/shorten_counts";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<UserShortenCountsExpandedResponse>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/LinkCountriesExpandedRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkCountriesExpanded;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_countries">/v3/link/countries</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkCountriesExpandedRequest extends MetricsExpandedRequest<LinkCountriesExpandedRequest, LinkCountriesExpanded> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkCountriesExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/countries";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/LinkCountriesExpandedRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkCountriesExpanded;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_countries">/v3/link/countries</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkCountriesExpandedRequest extends MetricsExpandedRequest<LinkCountriesExpandedRequest, LinkCountriesExpanded> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkCountriesExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/countries";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<LinkCountriesExpanded>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/UserPopularLinksRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserPopularLinksResponse.java
// public class UserPopularLinksResponse extends MetricsResponse {
//
// /** the links that have received click traffic in the specified timeframe */
// public List<PopularLink> popular_links;
//
// /** a link that has received traffic */
// public static class PopularLink extends ToStringSupport {
//
// /** a bitly link */
// public String link;
//
// /** the number of clicks on that bitly link in the specified timeframe */
// public long clicks;
// }
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserPopularLinksResponse;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_popular_links">/v3/user/popular_links</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserPopularLinksRequest extends MetricsRequest<UserPopularLinksRequest, UserPopularLinksResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserPopularLinksRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/popular_links";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserPopularLinksResponse.java
// public class UserPopularLinksResponse extends MetricsResponse {
//
// /** the links that have received click traffic in the specified timeframe */
// public List<PopularLink> popular_links;
//
// /** a link that has received traffic */
// public static class PopularLink extends ToStringSupport {
//
// /** a bitly link */
// public String link;
//
// /** the number of clicks on that bitly link in the specified timeframe */
// public long clicks;
// }
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/UserPopularLinksRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserPopularLinksResponse;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_popular_links">/v3/user/popular_links</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserPopularLinksRequest extends MetricsRequest<UserPopularLinksRequest, UserPopularLinksResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserPopularLinksRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/popular_links";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<UserPopularLinksResponse>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/LinkReferringDomainsRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferringDomainsResponse.java
// public class LinkReferringDomainsResponse extends MetricsResponse {
//
// /** list of referring domains with click counts */
// public List<LinkReferringDomain> referring_domains;
//
// /** a single referring domain to a link with click counts */
// public static class LinkReferringDomain extends ToStringSupport {
//
// /** the number of clicks referred from this domain */
// public long clicks;
//
// /** the domain referring clicks */
// public String domain;
//
// /** the complete URL of the domain referring clicks */
// public String url;
// }
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferringDomainsResponse;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referring_domains" >/v3/link/referring_domains </a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferringDomainsRequest extends MetricsRequest<LinkReferringDomainsRequest, LinkReferringDomainsResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkReferringDomainsRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/referring_domains";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferringDomainsResponse.java
// public class LinkReferringDomainsResponse extends MetricsResponse {
//
// /** list of referring domains with click counts */
// public List<LinkReferringDomain> referring_domains;
//
// /** a single referring domain to a link with click counts */
// public static class LinkReferringDomain extends ToStringSupport {
//
// /** the number of clicks referred from this domain */
// public long clicks;
//
// /** the domain referring clicks */
// public String domain;
//
// /** the complete URL of the domain referring clicks */
// public String url;
// }
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/LinkReferringDomainsRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferringDomainsResponse;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referring_domains" >/v3/link/referring_domains </a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferringDomainsRequest extends MetricsRequest<LinkReferringDomainsRequest, LinkReferringDomainsResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkReferringDomainsRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/referring_domains";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<LinkReferringDomainsResponse>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/LinkInfoRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkInfoResponse.java
// public class LinkInfoResponse extends ToStringSupport {
//
// public String canonical_url;
// public String category;
// public long content_length;
// public String aggregate_link;
// public String content_type;
// public String domain;
// public String favicon_url;
// public String global_hash;
// public String html_title;
// public int http_code;
// public long indexed;
// public List<LinktagOther> linktags_other;
// public List<MetatagName> metatags_name;
// public String original_url;
// public boolean robots_allowed;
// public String source_domain;
// public String url;
// public String url_fetched;
//
// public static class LinktagOther extends AbstractTag {}
//
// public static class MetatagName extends AbstractTag {}
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkInfoResponse;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/data_apis.html#v3_link_info">/v3/link/info</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkInfoRequest extends MetricsRequest<LinkInfoRequest, LinkInfoResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkInfoRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/info";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkInfoResponse.java
// public class LinkInfoResponse extends ToStringSupport {
//
// public String canonical_url;
// public String category;
// public long content_length;
// public String aggregate_link;
// public String content_type;
// public String domain;
// public String favicon_url;
// public String global_hash;
// public String html_title;
// public int http_code;
// public long indexed;
// public List<LinktagOther> linktags_other;
// public List<MetatagName> metatags_name;
// public String original_url;
// public boolean robots_allowed;
// public String source_domain;
// public String url;
// public String url_fetched;
//
// public static class LinktagOther extends AbstractTag {}
//
// public static class MetatagName extends AbstractTag {}
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/LinkInfoRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkInfoResponse;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/data_apis.html#v3_link_info">/v3/link/info</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkInfoRequest extends MetricsRequest<LinkInfoRequest, LinkInfoResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkInfoRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/info";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<LinkInfoResponse>>() {}.getType(); |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/LinkReferrersIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferrersResponse.java
// public class LinkReferrersResponse extends MetricsResponse {
//
// /** list of referrer referring to this link with click counts */
// public List<LinkReferrer> referrers;
//
// /** a single referrer referring a number of clicks */
// public static class LinkReferrer extends ToStringSupport {
//
// /** the number of clicks referred from this URL */
// public long clicks;
//
// /** the URL referring clicks */
// public String referrer;
// }
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferrersResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referrers">/v3/link/referrers</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferrersIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkReferrers() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferrersResponse.java
// public class LinkReferrersResponse extends MetricsResponse {
//
// /** list of referrer referring to this link with click counts */
// public List<LinkReferrer> referrers;
//
// /** a single referrer referring a number of clicks */
// public static class LinkReferrer extends ToStringSupport {
//
// /** the number of clicks referred from this URL */
// public long clicks;
//
// /** the URL referring clicks */
// public String referrer;
// }
// }
// Path: src/intTest/java/net/swisstech/bitly/test/LinkReferrersIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferrersResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referrers">/v3/link/referrers</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferrersIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkReferrers() { | Response<LinkReferrersResponse> resp = getClient().linkReferrers() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/LinkReferrersIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferrersResponse.java
// public class LinkReferrersResponse extends MetricsResponse {
//
// /** list of referrer referring to this link with click counts */
// public List<LinkReferrer> referrers;
//
// /** a single referrer referring a number of clicks */
// public static class LinkReferrer extends ToStringSupport {
//
// /** the number of clicks referred from this URL */
// public long clicks;
//
// /** the URL referring clicks */
// public String referrer;
// }
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferrersResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referrers">/v3/link/referrers</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferrersIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkReferrers() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferrersResponse.java
// public class LinkReferrersResponse extends MetricsResponse {
//
// /** list of referrer referring to this link with click counts */
// public List<LinkReferrer> referrers;
//
// /** a single referrer referring a number of clicks */
// public static class LinkReferrer extends ToStringSupport {
//
// /** the number of clicks referred from this URL */
// public long clicks;
//
// /** the URL referring clicks */
// public String referrer;
// }
// }
// Path: src/intTest/java/net/swisstech/bitly/test/LinkReferrersIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferrersResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referrers">/v3/link/referrers</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferrersIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkReferrers() { | Response<LinkReferrersResponse> resp = getClient().linkReferrers() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/LinkClicksIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksExpanded.java
// public class LinkClicksExpanded extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public List<LinkClick> link_clicks;
//
// /** single link click */
// public static class LinkClick extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public long dt;
//
// /** the number of clicks on this link */
// public long clicks;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksRolledUp.java
// public class LinkClicksRolledUp extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public long link_clicks;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksExpanded;
import net.swisstech.bitly.model.v3.LinkClicksRolledUp;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkClicksRolledUp() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksExpanded.java
// public class LinkClicksExpanded extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public List<LinkClick> link_clicks;
//
// /** single link click */
// public static class LinkClick extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public long dt;
//
// /** the number of clicks on this link */
// public long clicks;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksRolledUp.java
// public class LinkClicksRolledUp extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public long link_clicks;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/LinkClicksIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksExpanded;
import net.swisstech.bitly.model.v3.LinkClicksRolledUp;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkClicksRolledUp() { | Response<LinkClicksRolledUp> resp = getClient().linkClicksRolledUp() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/LinkClicksIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksExpanded.java
// public class LinkClicksExpanded extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public List<LinkClick> link_clicks;
//
// /** single link click */
// public static class LinkClick extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public long dt;
//
// /** the number of clicks on this link */
// public long clicks;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksRolledUp.java
// public class LinkClicksRolledUp extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public long link_clicks;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksExpanded;
import net.swisstech.bitly.model.v3.LinkClicksRolledUp;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkClicksRolledUp() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksExpanded.java
// public class LinkClicksExpanded extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public List<LinkClick> link_clicks;
//
// /** single link click */
// public static class LinkClick extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public long dt;
//
// /** the number of clicks on this link */
// public long clicks;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksRolledUp.java
// public class LinkClicksRolledUp extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public long link_clicks;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/LinkClicksIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksExpanded;
import net.swisstech.bitly.model.v3.LinkClicksRolledUp;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkClicksRolledUp() { | Response<LinkClicksRolledUp> resp = getClient().linkClicksRolledUp() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/LinkClicksIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksExpanded.java
// public class LinkClicksExpanded extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public List<LinkClick> link_clicks;
//
// /** single link click */
// public static class LinkClick extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public long dt;
//
// /** the number of clicks on this link */
// public long clicks;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksRolledUp.java
// public class LinkClicksRolledUp extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public long link_clicks;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksExpanded;
import net.swisstech.bitly.model.v3.LinkClicksRolledUp;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkClicksRolledUp() {
Response<LinkClicksRolledUp> resp = getClient().linkClicksRolledUp() //
.setLink("http://bit.ly/LfXpbF") //
.setUnit("hour") //
.setUnits(-1) //
.setTimezone(0) //
.setLimit(1000) //
.call();
printAndVerify(resp, LinkClicksRolledUp.class);
assertTrue(resp.data.link_clicks > 0);
assertEquals(resp.data.tz_offset, 0);
assertEquals(resp.data.unit, "hour");
assertEquals(resp.data.units, -1);
}
@Test
public void callLinkClicksExpanded() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksExpanded.java
// public class LinkClicksExpanded extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public List<LinkClick> link_clicks;
//
// /** single link click */
// public static class LinkClick extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public long dt;
//
// /** the number of clicks on this link */
// public long clicks;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksRolledUp.java
// public class LinkClicksRolledUp extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public long link_clicks;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/LinkClicksIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksExpanded;
import net.swisstech.bitly.model.v3.LinkClicksRolledUp;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkClicksRolledUp() {
Response<LinkClicksRolledUp> resp = getClient().linkClicksRolledUp() //
.setLink("http://bit.ly/LfXpbF") //
.setUnit("hour") //
.setUnits(-1) //
.setTimezone(0) //
.setLimit(1000) //
.call();
printAndVerify(resp, LinkClicksRolledUp.class);
assertTrue(resp.data.link_clicks > 0);
assertEquals(resp.data.tz_offset, 0);
assertEquals(resp.data.unit, "hour");
assertEquals(resp.data.units, -1);
}
@Test
public void callLinkClicksExpanded() { | Response<LinkClicksExpanded> resp = getClient().linkClicksExpanded() // |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/UserCountriesRolledUpRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRolledUpRequest.java
// public abstract class MetricsRolledUpRequest<REQ extends MetricsRolledUpRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRolledUpRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", true);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRolledUpRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserCountriesRolledUpResponse;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_countries">/v3/user/countries</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserCountriesRolledUpRequest extends MetricsRolledUpRequest<UserCountriesRolledUpRequest, UserCountriesRolledUpResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserCountriesRolledUpRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/countries";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRolledUpRequest.java
// public abstract class MetricsRolledUpRequest<REQ extends MetricsRolledUpRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRolledUpRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", true);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/UserCountriesRolledUpRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRolledUpRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserCountriesRolledUpResponse;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_countries">/v3/user/countries</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserCountriesRolledUpRequest extends MetricsRolledUpRequest<UserCountriesRolledUpRequest, UserCountriesRolledUpResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserCountriesRolledUpRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/countries";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<UserCountriesRolledUpResponse>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/QueryParameter.java | // Path: src/main/java/net/swisstech/bitly/util/EncodingUtil.java
// public final class EncodingUtil {
//
// /** Encoding to be used */
// private static final String ENCODING = "UTF-8";
//
// /** private constructor for utility class */
// private EncodingUtil() {}
//
// /**
// * URL-Encode a String. Throws a RuntimeException if the JVM does not support UTF-8.
// * @param unencodedString the String to be encoded
// * @return the encoded String
// */
// public static String encode(String unencodedString) {
// try {
// return URLEncoder.encode(unencodedString, ENCODING);
// }
// catch (UnsupportedEncodingException e) {
// throw new BitlyClientException("Error encoding String '" + unencodedString + "' with charset '" + ENCODING + "'", e);
// }
// }
// }
| import net.swisstech.bitly.util.EncodingUtil; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder;
/**
* Represents a single parameter in an url query as in <code>name=value</code>
* @author Patrick Huber (gmail: stackmagic)
*/
public class QueryParameter {
/** the name of the parameter */
private final String name;
/** the value of the parameter */
private final String value;
/**
* Constructs a new QueryParameter
* @param name the Name of the parameter
* @param value the Value of the parameter
*/
public QueryParameter(String name, String value) {
this.name = name; | // Path: src/main/java/net/swisstech/bitly/util/EncodingUtil.java
// public final class EncodingUtil {
//
// /** Encoding to be used */
// private static final String ENCODING = "UTF-8";
//
// /** private constructor for utility class */
// private EncodingUtil() {}
//
// /**
// * URL-Encode a String. Throws a RuntimeException if the JVM does not support UTF-8.
// * @param unencodedString the String to be encoded
// * @return the encoded String
// */
// public static String encode(String unencodedString) {
// try {
// return URLEncoder.encode(unencodedString, ENCODING);
// }
// catch (UnsupportedEncodingException e) {
// throw new BitlyClientException("Error encoding String '" + unencodedString + "' with charset '" + ENCODING + "'", e);
// }
// }
// }
// Path: src/main/java/net/swisstech/bitly/builder/QueryParameter.java
import net.swisstech.bitly.util.EncodingUtil;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder;
/**
* Represents a single parameter in an url query as in <code>name=value</code>
* @author Patrick Huber (gmail: stackmagic)
*/
public class QueryParameter {
/** the name of the parameter */
private final String name;
/** the value of the parameter */
private final String value;
/**
* Constructs a new QueryParameter
* @param name the Name of the parameter
* @param value the Value of the parameter
*/
public QueryParameter(String name, String value) {
this.name = name; | this.value = EncodingUtil.encode(value); |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserNetworkHistoryIntegrationTest.java | // Path: src/intTest/java/net/swisstech/bitly/test/util/AssertUtil.java
// public static void assertGreater(long first, long second) {
// if (first <= second) {
// throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second));
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import static net.swisstech.bitly.test.util.AssertUtil.assertGreater;
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertNotNull;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse.NetworkHistoryEntry;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse.Save;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_network_history">/v3/user/network_history</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserNetworkHistoryIntegrationTest extends AbstractBitlyClientIntegrationTest {
private static final Logger LOG = LoggerFactory.getLogger(UserNetworkHistoryIntegrationTest.class);
@Test
public void callUserNetworkHistory() { | // Path: src/intTest/java/net/swisstech/bitly/test/util/AssertUtil.java
// public static void assertGreater(long first, long second) {
// if (first <= second) {
// throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second));
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserNetworkHistoryIntegrationTest.java
import static net.swisstech.bitly.test.util.AssertUtil.assertGreater;
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertNotNull;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse.NetworkHistoryEntry;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse.Save;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_network_history">/v3/user/network_history</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserNetworkHistoryIntegrationTest extends AbstractBitlyClientIntegrationTest {
private static final Logger LOG = LoggerFactory.getLogger(UserNetworkHistoryIntegrationTest.class);
@Test
public void callUserNetworkHistory() { | Response<UserNetworkHistoryResponse> resp = getClient().userNetworkHistory() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserNetworkHistoryIntegrationTest.java | // Path: src/intTest/java/net/swisstech/bitly/test/util/AssertUtil.java
// public static void assertGreater(long first, long second) {
// if (first <= second) {
// throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second));
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import static net.swisstech.bitly.test.util.AssertUtil.assertGreater;
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertNotNull;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse.NetworkHistoryEntry;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse.Save;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_network_history">/v3/user/network_history</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserNetworkHistoryIntegrationTest extends AbstractBitlyClientIntegrationTest {
private static final Logger LOG = LoggerFactory.getLogger(UserNetworkHistoryIntegrationTest.class);
@Test
public void callUserNetworkHistory() {
Response<UserNetworkHistoryResponse> resp = getClient().userNetworkHistory() //
.call();
printAndVerify(resp, UserNetworkHistoryResponse.class);
| // Path: src/intTest/java/net/swisstech/bitly/test/util/AssertUtil.java
// public static void assertGreater(long first, long second) {
// if (first <= second) {
// throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second));
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserNetworkHistoryIntegrationTest.java
import static net.swisstech.bitly.test.util.AssertUtil.assertGreater;
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertNotNull;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse.NetworkHistoryEntry;
import net.swisstech.bitly.model.v3.UserNetworkHistoryResponse.Save;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_network_history">/v3/user/network_history</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserNetworkHistoryIntegrationTest extends AbstractBitlyClientIntegrationTest {
private static final Logger LOG = LoggerFactory.getLogger(UserNetworkHistoryIntegrationTest.class);
@Test
public void callUserNetworkHistory() {
Response<UserNetworkHistoryResponse> resp = getClient().userNetworkHistory() //
.call();
printAndVerify(resp, UserNetworkHistoryResponse.class);
| assertGreater(resp.data.total, 0); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/UserClicksRolledUpRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRolledUpRequest.java
// public abstract class MetricsRolledUpRequest<REQ extends MetricsRolledUpRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRolledUpRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", true);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRolledUpRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserClicksRolledUp;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_clicks">/v3/user/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserClicksRolledUpRequest extends MetricsRolledUpRequest<UserClicksRolledUpRequest, UserClicksRolledUp> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserClicksRolledUpRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/clicks";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRolledUpRequest.java
// public abstract class MetricsRolledUpRequest<REQ extends MetricsRolledUpRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRolledUpRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", true);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/UserClicksRolledUpRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRolledUpRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserClicksRolledUp;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_clicks">/v3/user/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserClicksRolledUpRequest extends MetricsRolledUpRequest<UserClicksRolledUpRequest, UserClicksRolledUp> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserClicksRolledUpRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/clicks";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<UserClicksRolledUp>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/LinkClicksExpandedRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksExpanded.java
// public class LinkClicksExpanded extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public List<LinkClick> link_clicks;
//
// /** single link click */
// public static class LinkClick extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public long dt;
//
// /** the number of clicks on this link */
// public long clicks;
// }
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksExpanded;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksExpandedRequest extends MetricsExpandedRequest<LinkClicksExpandedRequest, LinkClicksExpanded> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkClicksExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/clicks";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksExpanded.java
// public class LinkClicksExpanded extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public List<LinkClick> link_clicks;
//
// /** single link click */
// public static class LinkClick extends ToStringSupport {
//
// /** a unix timestamp representing the beginning of this <code>unit</code> */
// public long dt;
//
// /** the number of clicks on this link */
// public long clicks;
// }
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/LinkClicksExpandedRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksExpanded;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksExpandedRequest extends MetricsExpandedRequest<LinkClicksExpandedRequest, LinkClicksExpanded> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkClicksExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/clicks";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<LinkClicksExpanded>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/util/EncodingUtil.java | // Path: src/main/java/net/swisstech/bitly/BitlyClientException.java
// public class BitlyClientException extends RuntimeException {
//
// private static final long serialVersionUID = 5810677972369016949L;
//
// /** Construct a new RequestBuilderException */
// public BitlyClientException() {
// super();
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// * @param cause the Cause
// */
// public BitlyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// */
// public BitlyClientException(String message) {
// super(message);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param cause the Cause
// */
// public BitlyClientException(Throwable cause) {
// super(cause);
// }
// }
| import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import net.swisstech.bitly.BitlyClientException; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.util;
/**
* Encoding Utilities
* @author Patrick Huber (gmail: stackmagic)
*/
public final class EncodingUtil {
/** Encoding to be used */
private static final String ENCODING = "UTF-8";
/** private constructor for utility class */
private EncodingUtil() {}
/**
* URL-Encode a String. Throws a RuntimeException if the JVM does not support UTF-8.
* @param unencodedString the String to be encoded
* @return the encoded String
*/
public static String encode(String unencodedString) {
try {
return URLEncoder.encode(unencodedString, ENCODING);
}
catch (UnsupportedEncodingException e) { | // Path: src/main/java/net/swisstech/bitly/BitlyClientException.java
// public class BitlyClientException extends RuntimeException {
//
// private static final long serialVersionUID = 5810677972369016949L;
//
// /** Construct a new RequestBuilderException */
// public BitlyClientException() {
// super();
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// * @param cause the Cause
// */
// public BitlyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// */
// public BitlyClientException(String message) {
// super(message);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param cause the Cause
// */
// public BitlyClientException(Throwable cause) {
// super(cause);
// }
// }
// Path: src/main/java/net/swisstech/bitly/util/EncodingUtil.java
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import net.swisstech.bitly.BitlyClientException;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.util;
/**
* Encoding Utilities
* @author Patrick Huber (gmail: stackmagic)
*/
public final class EncodingUtil {
/** Encoding to be used */
private static final String ENCODING = "UTF-8";
/** private constructor for utility class */
private EncodingUtil() {}
/**
* URL-Encode a String. Throws a RuntimeException if the JVM does not support UTF-8.
* @param unencodedString the String to be encoded
* @return the encoded String
*/
public static String encode(String unencodedString) {
try {
return URLEncoder.encode(unencodedString, ENCODING);
}
catch (UnsupportedEncodingException e) { | throw new BitlyClientException("Error encoding String '" + unencodedString + "' with charset '" + ENCODING + "'", e); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/UserReferringDomainsRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserReferringDomainsResponse.java
// public class UserReferringDomainsResponse extends MetricsResponse {
//
// /** a list of domains referring traffic to this user's links */
// public List<ReferringDomain> user_referring_domains;
//
// /** a domain referring traffic to this user's links */
// public static class ReferringDomain extends ToStringSupport {
//
// /** the number of clicks referred from this domain */
// public long clicks;
//
// /** the domain referring clicks */
// public String domain;
//
// /** the complete URL of the domain referring clicks (null if the domain is "direct") */
// public String url;
// }
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserReferringDomainsResponse;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_referring_domains">/v3/user/referring_domains</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserReferringDomainsRequest extends MetricsRequest<UserReferringDomainsRequest, UserReferringDomainsResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserReferringDomainsRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/referring_domains";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserReferringDomainsResponse.java
// public class UserReferringDomainsResponse extends MetricsResponse {
//
// /** a list of domains referring traffic to this user's links */
// public List<ReferringDomain> user_referring_domains;
//
// /** a domain referring traffic to this user's links */
// public static class ReferringDomain extends ToStringSupport {
//
// /** the number of clicks referred from this domain */
// public long clicks;
//
// /** the domain referring clicks */
// public String domain;
//
// /** the complete URL of the domain referring clicks (null if the domain is "direct") */
// public String url;
// }
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/UserReferringDomainsRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserReferringDomainsResponse;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_referring_domains">/v3/user/referring_domains</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserReferringDomainsRequest extends MetricsRequest<UserReferringDomainsRequest, UserReferringDomainsResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserReferringDomainsRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/referring_domains";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<UserReferringDomainsResponse>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/UserClicksExpandedRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserClicksExpanded;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_clicks">/v3/user/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserClicksExpandedRequest extends MetricsExpandedRequest<UserClicksExpandedRequest, UserClicksExpanded> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserClicksExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/clicks";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/UserClicksExpandedRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserClicksExpanded;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_clicks">/v3/user/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserClicksExpandedRequest extends MetricsExpandedRequest<UserClicksExpandedRequest, UserClicksExpanded> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserClicksExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/clicks";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<UserClicksExpanded>>() {}.getType(); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/Request.java | // Path: src/main/java/net/swisstech/bitly/BitlyClientException.java
// public class BitlyClientException extends RuntimeException {
//
// private static final long serialVersionUID = 5810677972369016949L;
//
// /** Construct a new RequestBuilderException */
// public BitlyClientException() {
// super();
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// * @param cause the Cause
// */
// public BitlyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// */
// public BitlyClientException(String message) {
// super(message);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param cause the Cause
// */
// public BitlyClientException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/gson/GsonFactory.java
// public final class GsonFactory {
//
// private static final Gson GSON;
//
// /** private constructor for utility class */
// private GsonFactory() {}
//
// static {
// GsonBuilder builder = new GsonBuilder();
// builder.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter());
// builder.registerTypeAdapter(Instant.class, new InstantTypeConverter());
// builder.registerTypeAdapter(LinktagOther.class, new AbstractTagConverter<LinktagOther>(LinktagOther.class));
// builder.registerTypeAdapter(MetatagName.class, new AbstractTagConverter<MetatagName>(MetatagName.class));
// GSON = builder.create();
// }
//
// /**
// * Get the Gson instance
// * @return the Gson instance
// */
// public static Gson getGson() {
// return GSON;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/ResponsePartial.java
// public class ResponsePartial extends ToStringSupport {
//
// /**
// * The status_code is 200 for a successful request, 403 when rate limited, 503 for temporary unavailability, 404 to indicate not-found responses, and 500
// * for all other invalid requests or responses
// */
// public int status_code;
//
// /**
// * status_txt will be a value that describes the nature of any error encountered. Common values are RATE_LIMIT_EXCEEDED, MISSING_ARG_%s to denote a missing
// * URL parameter, and INVALID_%s to denote an invalid value in a request parameter (where %s is substituted with the name of the request parameter)
// */
// public String status_txt;
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.swisstech.bitly.BitlyClientException;
import net.swisstech.bitly.gson.GsonFactory;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.ResponsePartial;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonParseException; | * @param queryParameters the QueryParameters
* @return the URL
*/
protected String buildUrl(List<QueryParameter> queryParameters) {
// TODO find a way to pass the collection to addQuery in a simple and
// extensible way without breaking but extending the normal
// addQueryParameter methods
List<QueryParameter> params = new LinkedList<QueryParameter>(queryParameters);
params.add(new QueryParameter("access_token", accessToken));
StringBuffer url = new StringBuffer();
url.append(getEndpoint());
url.append("?");
Iterator<QueryParameter> paramIter = params.iterator();
while (paramIter.hasNext()) {
String param = paramIter.next().toString();
url.append(param);
if (paramIter.hasNext()) {
url.append("&");
}
}
return url.toString();
}
/**
* Make the call to the API and return the result
* @return the Response
*/ | // Path: src/main/java/net/swisstech/bitly/BitlyClientException.java
// public class BitlyClientException extends RuntimeException {
//
// private static final long serialVersionUID = 5810677972369016949L;
//
// /** Construct a new RequestBuilderException */
// public BitlyClientException() {
// super();
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// * @param cause the Cause
// */
// public BitlyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// */
// public BitlyClientException(String message) {
// super(message);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param cause the Cause
// */
// public BitlyClientException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/gson/GsonFactory.java
// public final class GsonFactory {
//
// private static final Gson GSON;
//
// /** private constructor for utility class */
// private GsonFactory() {}
//
// static {
// GsonBuilder builder = new GsonBuilder();
// builder.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter());
// builder.registerTypeAdapter(Instant.class, new InstantTypeConverter());
// builder.registerTypeAdapter(LinktagOther.class, new AbstractTagConverter<LinktagOther>(LinktagOther.class));
// builder.registerTypeAdapter(MetatagName.class, new AbstractTagConverter<MetatagName>(MetatagName.class));
// GSON = builder.create();
// }
//
// /**
// * Get the Gson instance
// * @return the Gson instance
// */
// public static Gson getGson() {
// return GSON;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/ResponsePartial.java
// public class ResponsePartial extends ToStringSupport {
//
// /**
// * The status_code is 200 for a successful request, 403 when rate limited, 503 for temporary unavailability, 404 to indicate not-found responses, and 500
// * for all other invalid requests or responses
// */
// public int status_code;
//
// /**
// * status_txt will be a value that describes the nature of any error encountered. Common values are RATE_LIMIT_EXCEEDED, MISSING_ARG_%s to denote a missing
// * URL parameter, and INVALID_%s to denote an invalid value in a request parameter (where %s is substituted with the name of the request parameter)
// */
// public String status_txt;
// }
// Path: src/main/java/net/swisstech/bitly/builder/Request.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.swisstech.bitly.BitlyClientException;
import net.swisstech.bitly.gson.GsonFactory;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.ResponsePartial;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
* @param queryParameters the QueryParameters
* @return the URL
*/
protected String buildUrl(List<QueryParameter> queryParameters) {
// TODO find a way to pass the collection to addQuery in a simple and
// extensible way without breaking but extending the normal
// addQueryParameter methods
List<QueryParameter> params = new LinkedList<QueryParameter>(queryParameters);
params.add(new QueryParameter("access_token", accessToken));
StringBuffer url = new StringBuffer();
url.append(getEndpoint());
url.append("?");
Iterator<QueryParameter> paramIter = params.iterator();
while (paramIter.hasNext()) {
String param = paramIter.next().toString();
url.append(param);
if (paramIter.hasNext()) {
url.append("&");
}
}
return url.toString();
}
/**
* Make the call to the API and return the result
* @return the Response
*/ | public Response<T> call() { |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/Request.java | // Path: src/main/java/net/swisstech/bitly/BitlyClientException.java
// public class BitlyClientException extends RuntimeException {
//
// private static final long serialVersionUID = 5810677972369016949L;
//
// /** Construct a new RequestBuilderException */
// public BitlyClientException() {
// super();
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// * @param cause the Cause
// */
// public BitlyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// */
// public BitlyClientException(String message) {
// super(message);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param cause the Cause
// */
// public BitlyClientException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/gson/GsonFactory.java
// public final class GsonFactory {
//
// private static final Gson GSON;
//
// /** private constructor for utility class */
// private GsonFactory() {}
//
// static {
// GsonBuilder builder = new GsonBuilder();
// builder.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter());
// builder.registerTypeAdapter(Instant.class, new InstantTypeConverter());
// builder.registerTypeAdapter(LinktagOther.class, new AbstractTagConverter<LinktagOther>(LinktagOther.class));
// builder.registerTypeAdapter(MetatagName.class, new AbstractTagConverter<MetatagName>(MetatagName.class));
// GSON = builder.create();
// }
//
// /**
// * Get the Gson instance
// * @return the Gson instance
// */
// public static Gson getGson() {
// return GSON;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/ResponsePartial.java
// public class ResponsePartial extends ToStringSupport {
//
// /**
// * The status_code is 200 for a successful request, 403 when rate limited, 503 for temporary unavailability, 404 to indicate not-found responses, and 500
// * for all other invalid requests or responses
// */
// public int status_code;
//
// /**
// * status_txt will be a value that describes the nature of any error encountered. Common values are RATE_LIMIT_EXCEEDED, MISSING_ARG_%s to denote a missing
// * URL parameter, and INVALID_%s to denote an invalid value in a request parameter (where %s is substituted with the name of the request parameter)
// */
// public String status_txt;
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.swisstech.bitly.BitlyClientException;
import net.swisstech.bitly.gson.GsonFactory;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.ResponsePartial;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonParseException; | /**
* Make the call to the API and return the result
* @return the Response
*/
public Response<T> call() {
try {
String url = buildUrl();
LOG.debug("Calling URL: {}", url);
URLConnection conn = new URL(url).openConnection();
conn.connect();
StringBuffer respBuf = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
respBuf.append(line);
}
String resp = respBuf.toString();
LOG.trace("Response received: {}", resp);
try {
return deserializeFull(resp);
}
catch (JsonParseException e) {
return deserializePartial(resp);
}
}
catch (IOException e) { | // Path: src/main/java/net/swisstech/bitly/BitlyClientException.java
// public class BitlyClientException extends RuntimeException {
//
// private static final long serialVersionUID = 5810677972369016949L;
//
// /** Construct a new RequestBuilderException */
// public BitlyClientException() {
// super();
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// * @param cause the Cause
// */
// public BitlyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// */
// public BitlyClientException(String message) {
// super(message);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param cause the Cause
// */
// public BitlyClientException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/gson/GsonFactory.java
// public final class GsonFactory {
//
// private static final Gson GSON;
//
// /** private constructor for utility class */
// private GsonFactory() {}
//
// static {
// GsonBuilder builder = new GsonBuilder();
// builder.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter());
// builder.registerTypeAdapter(Instant.class, new InstantTypeConverter());
// builder.registerTypeAdapter(LinktagOther.class, new AbstractTagConverter<LinktagOther>(LinktagOther.class));
// builder.registerTypeAdapter(MetatagName.class, new AbstractTagConverter<MetatagName>(MetatagName.class));
// GSON = builder.create();
// }
//
// /**
// * Get the Gson instance
// * @return the Gson instance
// */
// public static Gson getGson() {
// return GSON;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/ResponsePartial.java
// public class ResponsePartial extends ToStringSupport {
//
// /**
// * The status_code is 200 for a successful request, 403 when rate limited, 503 for temporary unavailability, 404 to indicate not-found responses, and 500
// * for all other invalid requests or responses
// */
// public int status_code;
//
// /**
// * status_txt will be a value that describes the nature of any error encountered. Common values are RATE_LIMIT_EXCEEDED, MISSING_ARG_%s to denote a missing
// * URL parameter, and INVALID_%s to denote an invalid value in a request parameter (where %s is substituted with the name of the request parameter)
// */
// public String status_txt;
// }
// Path: src/main/java/net/swisstech/bitly/builder/Request.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.swisstech.bitly.BitlyClientException;
import net.swisstech.bitly.gson.GsonFactory;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.ResponsePartial;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
/**
* Make the call to the API and return the result
* @return the Response
*/
public Response<T> call() {
try {
String url = buildUrl();
LOG.debug("Calling URL: {}", url);
URLConnection conn = new URL(url).openConnection();
conn.connect();
StringBuffer respBuf = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
respBuf.append(line);
}
String resp = respBuf.toString();
LOG.trace("Response received: {}", resp);
try {
return deserializeFull(resp);
}
catch (JsonParseException e) {
return deserializePartial(resp);
}
}
catch (IOException e) { | throw new BitlyClientException(e); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/Request.java | // Path: src/main/java/net/swisstech/bitly/BitlyClientException.java
// public class BitlyClientException extends RuntimeException {
//
// private static final long serialVersionUID = 5810677972369016949L;
//
// /** Construct a new RequestBuilderException */
// public BitlyClientException() {
// super();
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// * @param cause the Cause
// */
// public BitlyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// */
// public BitlyClientException(String message) {
// super(message);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param cause the Cause
// */
// public BitlyClientException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/gson/GsonFactory.java
// public final class GsonFactory {
//
// private static final Gson GSON;
//
// /** private constructor for utility class */
// private GsonFactory() {}
//
// static {
// GsonBuilder builder = new GsonBuilder();
// builder.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter());
// builder.registerTypeAdapter(Instant.class, new InstantTypeConverter());
// builder.registerTypeAdapter(LinktagOther.class, new AbstractTagConverter<LinktagOther>(LinktagOther.class));
// builder.registerTypeAdapter(MetatagName.class, new AbstractTagConverter<MetatagName>(MetatagName.class));
// GSON = builder.create();
// }
//
// /**
// * Get the Gson instance
// * @return the Gson instance
// */
// public static Gson getGson() {
// return GSON;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/ResponsePartial.java
// public class ResponsePartial extends ToStringSupport {
//
// /**
// * The status_code is 200 for a successful request, 403 when rate limited, 503 for temporary unavailability, 404 to indicate not-found responses, and 500
// * for all other invalid requests or responses
// */
// public int status_code;
//
// /**
// * status_txt will be a value that describes the nature of any error encountered. Common values are RATE_LIMIT_EXCEEDED, MISSING_ARG_%s to denote a missing
// * URL parameter, and INVALID_%s to denote an invalid value in a request parameter (where %s is substituted with the name of the request parameter)
// */
// public String status_txt;
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.swisstech.bitly.BitlyClientException;
import net.swisstech.bitly.gson.GsonFactory;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.ResponsePartial;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonParseException; | LOG.trace("Response received: {}", resp);
try {
return deserializeFull(resp);
}
catch (JsonParseException e) {
return deserializePartial(resp);
}
}
catch (IOException e) {
throw new BitlyClientException(e);
}
}
/**
* Attempt to fully deserialize bitly's response
* @param resp bitly's response data
* @return the Response
*/
private Response<T> deserializeFull(String resp) {
return GSON.fromJson(resp, getTypeForGson());
}
/**
* Only deserialize the status fields, copy them into a Response and set the <code>deserialize_error</code> flag.
* @param resp bitly's response data
* @return the Response
*/
private Response<T> deserializePartial(String resp) { | // Path: src/main/java/net/swisstech/bitly/BitlyClientException.java
// public class BitlyClientException extends RuntimeException {
//
// private static final long serialVersionUID = 5810677972369016949L;
//
// /** Construct a new RequestBuilderException */
// public BitlyClientException() {
// super();
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// * @param cause the Cause
// */
// public BitlyClientException(String message, Throwable cause) {
// super(message, cause);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param message the Message
// */
// public BitlyClientException(String message) {
// super(message);
// }
//
// /**
// * Construct a new RequestBuilderException
// * @param cause the Cause
// */
// public BitlyClientException(Throwable cause) {
// super(cause);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/gson/GsonFactory.java
// public final class GsonFactory {
//
// private static final Gson GSON;
//
// /** private constructor for utility class */
// private GsonFactory() {}
//
// static {
// GsonBuilder builder = new GsonBuilder();
// builder.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter());
// builder.registerTypeAdapter(Instant.class, new InstantTypeConverter());
// builder.registerTypeAdapter(LinktagOther.class, new AbstractTagConverter<LinktagOther>(LinktagOther.class));
// builder.registerTypeAdapter(MetatagName.class, new AbstractTagConverter<MetatagName>(MetatagName.class));
// GSON = builder.create();
// }
//
// /**
// * Get the Gson instance
// * @return the Gson instance
// */
// public static Gson getGson() {
// return GSON;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/ResponsePartial.java
// public class ResponsePartial extends ToStringSupport {
//
// /**
// * The status_code is 200 for a successful request, 403 when rate limited, 503 for temporary unavailability, 404 to indicate not-found responses, and 500
// * for all other invalid requests or responses
// */
// public int status_code;
//
// /**
// * status_txt will be a value that describes the nature of any error encountered. Common values are RATE_LIMIT_EXCEEDED, MISSING_ARG_%s to denote a missing
// * URL parameter, and INVALID_%s to denote an invalid value in a request parameter (where %s is substituted with the name of the request parameter)
// */
// public String status_txt;
// }
// Path: src/main/java/net/swisstech/bitly/builder/Request.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.swisstech.bitly.BitlyClientException;
import net.swisstech.bitly.gson.GsonFactory;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.ResponsePartial;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
LOG.trace("Response received: {}", resp);
try {
return deserializeFull(resp);
}
catch (JsonParseException e) {
return deserializePartial(resp);
}
}
catch (IOException e) {
throw new BitlyClientException(e);
}
}
/**
* Attempt to fully deserialize bitly's response
* @param resp bitly's response data
* @return the Response
*/
private Response<T> deserializeFull(String resp) {
return GSON.fromJson(resp, getTypeForGson());
}
/**
* Only deserialize the status fields, copy them into a Response and set the <code>deserialize_error</code> flag.
* @param resp bitly's response data
* @return the Response
*/
private Response<T> deserializePartial(String resp) { | ResponsePartial partial = GSON.fromJson(resp, ResponsePartial.class); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/UserReferrersExpandedRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserReferrersExpanded.java
// public class UserReferrersExpanded extends MetricsResponse {
//
// /** a list of URLs referring traffic to this user's links */
// public List<Referrer> user_referrers;
//
// /** a single source of clicks, a referrer */
// public static class Referrer {
//
// /** the URL referring clicks */
// public String referrer;
//
// /** the number of clicks referred from this URL */
// public long clicks;
// }
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserReferrersExpanded;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_referrers">/v3/user/referrers</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserReferrersExpandedRequest extends MetricsExpandedRequest<UserReferrersExpandedRequest, UserReferrersExpanded> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserReferrersExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/referrers";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsExpandedRequest.java
// public abstract class MetricsExpandedRequest<REQ extends MetricsExpandedRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsExpandedRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", false);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserReferrersExpanded.java
// public class UserReferrersExpanded extends MetricsResponse {
//
// /** a list of URLs referring traffic to this user's links */
// public List<Referrer> user_referrers;
//
// /** a single source of clicks, a referrer */
// public static class Referrer {
//
// /** the URL referring clicks */
// public String referrer;
//
// /** the number of clicks referred from this URL */
// public long clicks;
// }
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/UserReferrersExpandedRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsExpandedRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserReferrersExpanded;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_referrers">/v3/user/referrers</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserReferrersExpandedRequest extends MetricsExpandedRequest<UserReferrersExpandedRequest, UserReferrersExpanded> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserReferrersExpandedRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/referrers";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<UserReferrersExpanded>>() {}.getType(); |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserTrackingDomainListIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserTrackingDomainListResponse.java
// public class UserTrackingDomainListResponse extends ToStringSupport {
//
// /** a list of tracking domains configured for the authenticated user */
// public List<String> tracking_domains;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserTrackingDomainListResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_tracking_domain_list">/v3/user/tracking_domain_list</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserTrackingDomainListIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserTrackingDomainList() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserTrackingDomainListResponse.java
// public class UserTrackingDomainListResponse extends ToStringSupport {
//
// /** a list of tracking domains configured for the authenticated user */
// public List<String> tracking_domains;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserTrackingDomainListIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserTrackingDomainListResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_tracking_domain_list">/v3/user/tracking_domain_list</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserTrackingDomainListIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserTrackingDomainList() { | Response<UserTrackingDomainListResponse> resp = getClient().userTrackingDomainList() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserTrackingDomainListIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserTrackingDomainListResponse.java
// public class UserTrackingDomainListResponse extends ToStringSupport {
//
// /** a list of tracking domains configured for the authenticated user */
// public List<String> tracking_domains;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserTrackingDomainListResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_tracking_domain_list">/v3/user/tracking_domain_list</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserTrackingDomainListIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserTrackingDomainList() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserTrackingDomainListResponse.java
// public class UserTrackingDomainListResponse extends ToStringSupport {
//
// /** a list of tracking domains configured for the authenticated user */
// public List<String> tracking_domains;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserTrackingDomainListIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserTrackingDomainListResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_tracking_domain_list">/v3/user/tracking_domain_list</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserTrackingDomainListIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserTrackingDomainList() { | Response<UserTrackingDomainListResponse> resp = getClient().userTrackingDomainList() // |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/LinkReferrersRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferrersResponse.java
// public class LinkReferrersResponse extends MetricsResponse {
//
// /** list of referrer referring to this link with click counts */
// public List<LinkReferrer> referrers;
//
// /** a single referrer referring a number of clicks */
// public static class LinkReferrer extends ToStringSupport {
//
// /** the number of clicks referred from this URL */
// public long clicks;
//
// /** the URL referring clicks */
// public String referrer;
// }
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferrersResponse;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referrers">/v3/link/referrers</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferrersRequest extends MetricsRequest<LinkReferrersRequest, LinkReferrersResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkReferrersRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/referrers";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRequest.java
// public abstract class MetricsRequest<REQ extends MetricsRequest<REQ, DATA>, DATA> extends Request<DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRequest(String accessToken) {
// super(accessToken);
// }
//
// /**
// * set the link TODO this isn't used/allowed in all metrics requests!
// * @param link a bitly link
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLink(String link) {
// addQueryParameter("link", link);
// return (REQ) this;
// }
//
// /**
// * set the unit
// * @param unit <code>minute</code> | <code>hour</code> | <code>day</code> | <code>week</code> | <code>month</code> default:<code>day</code> <br/>
// * <strong>Note:</strong> when <code>unit</code> is <code>minute</code> the maximum value for <code>units</code> is <code>60</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnit(String unit) {
// addQueryParameter("unit", unit);
// return (REQ) this;
// }
//
// /**
// * set the units
// * @param units an integer representing the time units to query data for. pass <code>-1</code> to return all units of time
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnits(long units) {
// addQueryParameter("units", units);
// return (REQ) this;
// }
//
// /**
// * set the timezone
// * @param timezone an integer hour offset from UTC (-12..12), or a timezone string default:<code>America/New_York</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setTimezone(long timezone) {
// addQueryParameter("timezone", timezone);
// return (REQ) this;
// }
//
// /**
// * set the limit
// * @param limit 1..1000 (default=100)
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setLimit(long limit) {
// addQueryParameter("limit", limit);
// return (REQ) this;
// }
//
// /**
// * set the newest point in time from where to fetch data backwards into the past
// * @param unit_reference_ts an epoch timestamp, indicating the most recent time for which to pull metrics. default:<code>now</code> <br/>
// * <strong>Note:</strong> the value of <code>unit_reference_ts</code> rounds to the nearest <code>unit</code>. <br/>
// * <strong>Note:</strong> historical data is stored hourly beyond the most recent 60 minutes. If a <code>unit_reference_ts</code> is specified,
// * <code>unit</code> cannot be <code>minute</code>
// * @return this builder
// */
// @SuppressWarnings("unchecked")
// public REQ setUnitReferenceTs(DateTime unit_reference_ts) {
// addQueryParameter("unit_reference_ts", unit_reference_ts);
// return (REQ) this;
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferrersResponse.java
// public class LinkReferrersResponse extends MetricsResponse {
//
// /** list of referrer referring to this link with click counts */
// public List<LinkReferrer> referrers;
//
// /** a single referrer referring a number of clicks */
// public static class LinkReferrer extends ToStringSupport {
//
// /** the number of clicks referred from this URL */
// public long clicks;
//
// /** the URL referring clicks */
// public String referrer;
// }
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/LinkReferrersRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferrersResponse;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referrers">/v3/link/referrers</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferrersRequest extends MetricsRequest<LinkReferrersRequest, LinkReferrersResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkReferrersRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/referrers";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<LinkReferrersResponse>>() {}.getType(); |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserLinkSaveIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserLinkEditResponse;
import net.swisstech.bitly.model.v3.UserLinkSaveResponse;
import org.joda.time.DateTime;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/links.html#v3_user_link_save">/v3/user/link_save</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserLinkSaveIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserLinkSaveExistingLink() {
// must have a unique link and so we add milliseconds | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserLinkSaveIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserLinkEditResponse;
import net.swisstech.bitly.model.v3.UserLinkSaveResponse;
import org.joda.time.DateTime;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/links.html#v3_user_link_save">/v3/user/link_save</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserLinkSaveIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserLinkSaveExistingLink() {
// must have a unique link and so we add milliseconds | Response<UserLinkSaveResponse> resp = getClient().userLinkSave() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/ShortenIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.ShortenResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/links.html#v3_shorten">/v3/shorten</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class ShortenIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callShorten() throws IOException { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/ShortenIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.ShortenResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/links.html#v3_shorten">/v3/shorten</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class ShortenIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callShorten() throws IOException { | Response<ShortenResponse> resp = getClient().shorten() // |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/model/ToStringSupport.java | // Path: src/main/java/net/swisstech/bitly/gson/GsonFactory.java
// public final class GsonFactory {
//
// private static final Gson GSON;
//
// /** private constructor for utility class */
// private GsonFactory() {}
//
// static {
// GsonBuilder builder = new GsonBuilder();
// builder.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter());
// builder.registerTypeAdapter(Instant.class, new InstantTypeConverter());
// builder.registerTypeAdapter(LinktagOther.class, new AbstractTagConverter<LinktagOther>(LinktagOther.class));
// builder.registerTypeAdapter(MetatagName.class, new AbstractTagConverter<MetatagName>(MetatagName.class));
// GSON = builder.create();
// }
//
// /**
// * Get the Gson instance
// * @return the Gson instance
// */
// public static Gson getGson() {
// return GSON;
// }
// }
| import net.swisstech.bitly.gson.GsonFactory; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.model;
/**
* Extend this class to have simple toString support (will be serialized to json using GSON).
* @author Patrick Huber (gmail: stackmagic)
*/
public abstract class ToStringSupport {
@Override
public String toString() { | // Path: src/main/java/net/swisstech/bitly/gson/GsonFactory.java
// public final class GsonFactory {
//
// private static final Gson GSON;
//
// /** private constructor for utility class */
// private GsonFactory() {}
//
// static {
// GsonBuilder builder = new GsonBuilder();
// builder.registerTypeAdapter(DateTime.class, new DateTimeTypeConverter());
// builder.registerTypeAdapter(Instant.class, new InstantTypeConverter());
// builder.registerTypeAdapter(LinktagOther.class, new AbstractTagConverter<LinktagOther>(LinktagOther.class));
// builder.registerTypeAdapter(MetatagName.class, new AbstractTagConverter<MetatagName>(MetatagName.class));
// GSON = builder.create();
// }
//
// /**
// * Get the Gson instance
// * @return the Gson instance
// */
// public static Gson getGson() {
// return GSON;
// }
// }
// Path: src/main/java/net/swisstech/bitly/model/ToStringSupport.java
import net.swisstech.bitly.gson.GsonFactory;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.model;
/**
* Extend this class to have simple toString support (will be serialized to json using GSON).
* @author Patrick Huber (gmail: stackmagic)
*/
public abstract class ToStringSupport {
@Override
public String toString() { | return GsonFactory.getGson().toJson(this); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/UserShortenCountsRolledUpRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRolledUpRequest.java
// public abstract class MetricsRolledUpRequest<REQ extends MetricsRolledUpRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRolledUpRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", true);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserShortenCountsRolledUpResponse.java
// public class UserShortenCountsRolledUpResponse extends MetricsResponse {
//
// /** the user shorten counts */
// public long user_shorten_counts;
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRolledUpRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserShortenCountsRolledUpResponse;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_shorten_counts">/v3/user/shorten_counts</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserShortenCountsRolledUpRequest extends MetricsRolledUpRequest<UserShortenCountsRolledUpRequest, UserShortenCountsRolledUpResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserShortenCountsRolledUpRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/shorten_counts";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRolledUpRequest.java
// public abstract class MetricsRolledUpRequest<REQ extends MetricsRolledUpRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRolledUpRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", true);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserShortenCountsRolledUpResponse.java
// public class UserShortenCountsRolledUpResponse extends MetricsResponse {
//
// /** the user shorten counts */
// public long user_shorten_counts;
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/UserShortenCountsRolledUpRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRolledUpRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserShortenCountsRolledUpResponse;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_metrics.html#v3_user_shorten_counts">/v3/user/shorten_counts</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserShortenCountsRolledUpRequest extends MetricsRolledUpRequest<UserShortenCountsRolledUpRequest, UserShortenCountsRolledUpResponse> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public UserShortenCountsRolledUpRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/user/shorten_counts";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<UserShortenCountsRolledUpResponse>>() {}.getType(); |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserClicksIntegrationTest.java | // Path: src/intTest/java/net/swisstech/bitly/test/util/AssertUtil.java
// public static void assertGreater(long first, long second) {
// if (first <= second) {
// throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second));
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import static net.swisstech.bitly.test.util.AssertUtil.assertGreater;
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserClicksExpanded;
import net.swisstech.bitly.model.v3.UserClicksRolledUp;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
public class UserClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserClicksExpanded() { | // Path: src/intTest/java/net/swisstech/bitly/test/util/AssertUtil.java
// public static void assertGreater(long first, long second) {
// if (first <= second) {
// throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second));
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserClicksIntegrationTest.java
import static net.swisstech.bitly.test.util.AssertUtil.assertGreater;
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserClicksExpanded;
import net.swisstech.bitly.model.v3.UserClicksRolledUp;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
public class UserClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserClicksExpanded() { | Response<UserClicksExpanded> resp = getClient().userClicksExpanded() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserClicksIntegrationTest.java | // Path: src/intTest/java/net/swisstech/bitly/test/util/AssertUtil.java
// public static void assertGreater(long first, long second) {
// if (first <= second) {
// throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second));
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
| import static net.swisstech.bitly.test.util.AssertUtil.assertGreater;
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserClicksExpanded;
import net.swisstech.bitly.model.v3.UserClicksRolledUp;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
public class UserClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserClicksExpanded() {
Response<UserClicksExpanded> resp = getClient().userClicksExpanded() //
.setUnit("day") //
.setUnits(500) //
.call();
printAndVerify(resp, UserClicksExpanded.class);
| // Path: src/intTest/java/net/swisstech/bitly/test/util/AssertUtil.java
// public static void assertGreater(long first, long second) {
// if (first <= second) {
// throw new AssertionError(String.format("expected <%d> to be greater than <%d>", first, second));
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserClicksIntegrationTest.java
import static net.swisstech.bitly.test.util.AssertUtil.assertGreater;
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserClicksExpanded;
import net.swisstech.bitly.model.v3.UserClicksRolledUp;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
public class UserClicksIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserClicksExpanded() {
Response<UserClicksExpanded> resp = getClient().userClicksExpanded() //
.setUnit("day") //
.setUnits(500) //
.call();
printAndVerify(resp, UserClicksExpanded.class);
| assertGreater(resp.data.user_clicks.size(), 0); |
stackmagic/bitly-api-client | src/main/java/net/swisstech/bitly/builder/v3/LinkClicksRolledUpRequest.java | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRolledUpRequest.java
// public abstract class MetricsRolledUpRequest<REQ extends MetricsRolledUpRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRolledUpRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", true);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksRolledUp.java
// public class LinkClicksRolledUp extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public long link_clicks;
// }
| import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRolledUpRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksRolledUp;
import com.google.gson.reflect.TypeToken; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksRolledUpRequest extends MetricsRolledUpRequest<LinkClicksRolledUpRequest, LinkClicksRolledUp> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkClicksRolledUpRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/clicks";
}
@Override
protected Type getTypeForGson() { | // Path: src/main/java/net/swisstech/bitly/builder/MetricsRolledUpRequest.java
// public abstract class MetricsRolledUpRequest<REQ extends MetricsRolledUpRequest<REQ, DATA>, DATA> extends MetricsRequest<REQ, DATA> {
//
// /**
// * Create a new request builder
// * @param accessToken the access token to access the bitly api
// */
// public MetricsRolledUpRequest(String accessToken) {
// super(accessToken);
// addQueryParameter("rollup", true);
// }
// }
//
// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkClicksRolledUp.java
// public class LinkClicksRolledUp extends MetricsResponse {
//
// /** the number of clicks on the specified bitly link */
// public long link_clicks;
// }
// Path: src/main/java/net/swisstech/bitly/builder/v3/LinkClicksRolledUpRequest.java
import java.lang.reflect.Type;
import net.swisstech.bitly.builder.MetricsRolledUpRequest;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkClicksRolledUp;
import com.google.gson.reflect.TypeToken;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.builder.v3;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_clicks">/v3/link/clicks</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkClicksRolledUpRequest extends MetricsRolledUpRequest<LinkClicksRolledUpRequest, LinkClicksRolledUp> {
/**
* Create a new request builder
* @param accessToken the access token to access the bitly api
*/
public LinkClicksRolledUpRequest(String accessToken) {
super(accessToken);
}
@Override
public String getEndpoint() {
return "https://api-ssl.bitly.com/v3/link/clicks";
}
@Override
protected Type getTypeForGson() { | return new TypeToken<Response<LinkClicksRolledUp>>() {}.getType(); |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserInfoIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserInfoResponse.java
// public class UserInfoResponse extends ToStringSupport {
//
// /** the user's login (always returned in the response) */
// public String login;
//
// /** URL of user's profile page (always returned in the response) */
// public String profile_url;
//
// /** URL of user's profile image (always returned in the response) */
// public String profile_image;
//
// /** Unix timestamp for the moment the user signed up (always returned in the response) */
// public DateTime member_since;
//
// /** the user's full name, if set (optional, always returned in the response) */
// public String full_name;
//
// /** the user's display name, if set (optional, always returned in the response) */
// public String display_name;
//
// /**
// * a list of the share accounts (Twitter or Facebook) linked to the user's account (optional, always returned in the response) TODO substructure unclear
// */
// public List<Object> share_accounts;
//
// /** the user's bitly API key (optional, only included in requests for a user's own info) */
// public String apiKey;
//
// /**
// * <code>0</code> or <code>1</code> to indicate if this account is signed up for bitly enterprise (optional, only included in requests for a user's own
// * info)
// */
// public boolean is_enterprise;
//
// /**
// * A short domain registered with this account that can be used in place of <code>bit.ly</code> for shortening links (optional, only included in requests
// * for a user's own info)
// */
// public String custom_short_domain;
//
// /**
// * A list of domains configured for analytics tracking (optional, only included in requests for a user's own info) TODO substructure unclear
// */
// public List<Object> tracking_domains;
//
// /**
// * <code>public</code> or <code>private</code> indicating the default privacy setting for new links (optional, only included in requests for a user's own
// * info)
// */
// public String default_link_privacy;
//
// /**
// * list of accounts associated with this account (optional, only included for enterprise accounts (is_enterprise == 1)) TODO substructure unclear
// */
// public List<Object> sub_accounts;
//
// /**
// * list of domains associated with this <code>custom_short_domain</code> (optional, only included for enterprise accounts (is_enterprise == 1)) TODO
// * substructure unclear
// */
// public List<Object> e2e_domains;
//
// /**
// * the login of a master account, if this is associated with an enterprise account (optional, only included for enterprise accounts (is_enterprise == 1))
// */
// public String master_account;
//
// /**
// * list of enterprise permissions associated with this account (optional, only included for enterprise accounts (is_enterprise == 1)) TODO substructure
// * unclear
// */
// public List<Object> enterprise_permissions;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserInfoResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_info">/v3/user/info</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserInfoIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserInfoForAccessTokenUser() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserInfoResponse.java
// public class UserInfoResponse extends ToStringSupport {
//
// /** the user's login (always returned in the response) */
// public String login;
//
// /** URL of user's profile page (always returned in the response) */
// public String profile_url;
//
// /** URL of user's profile image (always returned in the response) */
// public String profile_image;
//
// /** Unix timestamp for the moment the user signed up (always returned in the response) */
// public DateTime member_since;
//
// /** the user's full name, if set (optional, always returned in the response) */
// public String full_name;
//
// /** the user's display name, if set (optional, always returned in the response) */
// public String display_name;
//
// /**
// * a list of the share accounts (Twitter or Facebook) linked to the user's account (optional, always returned in the response) TODO substructure unclear
// */
// public List<Object> share_accounts;
//
// /** the user's bitly API key (optional, only included in requests for a user's own info) */
// public String apiKey;
//
// /**
// * <code>0</code> or <code>1</code> to indicate if this account is signed up for bitly enterprise (optional, only included in requests for a user's own
// * info)
// */
// public boolean is_enterprise;
//
// /**
// * A short domain registered with this account that can be used in place of <code>bit.ly</code> for shortening links (optional, only included in requests
// * for a user's own info)
// */
// public String custom_short_domain;
//
// /**
// * A list of domains configured for analytics tracking (optional, only included in requests for a user's own info) TODO substructure unclear
// */
// public List<Object> tracking_domains;
//
// /**
// * <code>public</code> or <code>private</code> indicating the default privacy setting for new links (optional, only included in requests for a user's own
// * info)
// */
// public String default_link_privacy;
//
// /**
// * list of accounts associated with this account (optional, only included for enterprise accounts (is_enterprise == 1)) TODO substructure unclear
// */
// public List<Object> sub_accounts;
//
// /**
// * list of domains associated with this <code>custom_short_domain</code> (optional, only included for enterprise accounts (is_enterprise == 1)) TODO
// * substructure unclear
// */
// public List<Object> e2e_domains;
//
// /**
// * the login of a master account, if this is associated with an enterprise account (optional, only included for enterprise accounts (is_enterprise == 1))
// */
// public String master_account;
//
// /**
// * list of enterprise permissions associated with this account (optional, only included for enterprise accounts (is_enterprise == 1)) TODO substructure
// * unclear
// */
// public List<Object> enterprise_permissions;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserInfoIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserInfoResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_info">/v3/user/info</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserInfoIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserInfoForAccessTokenUser() { | Response<UserInfoResponse> resp = getClient().userInfo() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/UserInfoIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserInfoResponse.java
// public class UserInfoResponse extends ToStringSupport {
//
// /** the user's login (always returned in the response) */
// public String login;
//
// /** URL of user's profile page (always returned in the response) */
// public String profile_url;
//
// /** URL of user's profile image (always returned in the response) */
// public String profile_image;
//
// /** Unix timestamp for the moment the user signed up (always returned in the response) */
// public DateTime member_since;
//
// /** the user's full name, if set (optional, always returned in the response) */
// public String full_name;
//
// /** the user's display name, if set (optional, always returned in the response) */
// public String display_name;
//
// /**
// * a list of the share accounts (Twitter or Facebook) linked to the user's account (optional, always returned in the response) TODO substructure unclear
// */
// public List<Object> share_accounts;
//
// /** the user's bitly API key (optional, only included in requests for a user's own info) */
// public String apiKey;
//
// /**
// * <code>0</code> or <code>1</code> to indicate if this account is signed up for bitly enterprise (optional, only included in requests for a user's own
// * info)
// */
// public boolean is_enterprise;
//
// /**
// * A short domain registered with this account that can be used in place of <code>bit.ly</code> for shortening links (optional, only included in requests
// * for a user's own info)
// */
// public String custom_short_domain;
//
// /**
// * A list of domains configured for analytics tracking (optional, only included in requests for a user's own info) TODO substructure unclear
// */
// public List<Object> tracking_domains;
//
// /**
// * <code>public</code> or <code>private</code> indicating the default privacy setting for new links (optional, only included in requests for a user's own
// * info)
// */
// public String default_link_privacy;
//
// /**
// * list of accounts associated with this account (optional, only included for enterprise accounts (is_enterprise == 1)) TODO substructure unclear
// */
// public List<Object> sub_accounts;
//
// /**
// * list of domains associated with this <code>custom_short_domain</code> (optional, only included for enterprise accounts (is_enterprise == 1)) TODO
// * substructure unclear
// */
// public List<Object> e2e_domains;
//
// /**
// * the login of a master account, if this is associated with an enterprise account (optional, only included for enterprise accounts (is_enterprise == 1))
// */
// public String master_account;
//
// /**
// * list of enterprise permissions associated with this account (optional, only included for enterprise accounts (is_enterprise == 1)) TODO substructure
// * unclear
// */
// public List<Object> enterprise_permissions;
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserInfoResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_info">/v3/user/info</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserInfoIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserInfoForAccessTokenUser() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/UserInfoResponse.java
// public class UserInfoResponse extends ToStringSupport {
//
// /** the user's login (always returned in the response) */
// public String login;
//
// /** URL of user's profile page (always returned in the response) */
// public String profile_url;
//
// /** URL of user's profile image (always returned in the response) */
// public String profile_image;
//
// /** Unix timestamp for the moment the user signed up (always returned in the response) */
// public DateTime member_since;
//
// /** the user's full name, if set (optional, always returned in the response) */
// public String full_name;
//
// /** the user's display name, if set (optional, always returned in the response) */
// public String display_name;
//
// /**
// * a list of the share accounts (Twitter or Facebook) linked to the user's account (optional, always returned in the response) TODO substructure unclear
// */
// public List<Object> share_accounts;
//
// /** the user's bitly API key (optional, only included in requests for a user's own info) */
// public String apiKey;
//
// /**
// * <code>0</code> or <code>1</code> to indicate if this account is signed up for bitly enterprise (optional, only included in requests for a user's own
// * info)
// */
// public boolean is_enterprise;
//
// /**
// * A short domain registered with this account that can be used in place of <code>bit.ly</code> for shortening links (optional, only included in requests
// * for a user's own info)
// */
// public String custom_short_domain;
//
// /**
// * A list of domains configured for analytics tracking (optional, only included in requests for a user's own info) TODO substructure unclear
// */
// public List<Object> tracking_domains;
//
// /**
// * <code>public</code> or <code>private</code> indicating the default privacy setting for new links (optional, only included in requests for a user's own
// * info)
// */
// public String default_link_privacy;
//
// /**
// * list of accounts associated with this account (optional, only included for enterprise accounts (is_enterprise == 1)) TODO substructure unclear
// */
// public List<Object> sub_accounts;
//
// /**
// * list of domains associated with this <code>custom_short_domain</code> (optional, only included for enterprise accounts (is_enterprise == 1)) TODO
// * substructure unclear
// */
// public List<Object> e2e_domains;
//
// /**
// * the login of a master account, if this is associated with an enterprise account (optional, only included for enterprise accounts (is_enterprise == 1))
// */
// public String master_account;
//
// /**
// * list of enterprise permissions associated with this account (optional, only included for enterprise accounts (is_enterprise == 1)) TODO substructure
// * unclear
// */
// public List<Object> enterprise_permissions;
// }
// Path: src/intTest/java/net/swisstech/bitly/test/UserInfoIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserInfoResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/user_info.html#v3_user_info">/v3/user/info</a> request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class UserInfoIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callUserInfoForAccessTokenUser() { | Response<UserInfoResponse> resp = getClient().userInfo() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/LinkReferringDomainsIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferringDomainsResponse.java
// public class LinkReferringDomainsResponse extends MetricsResponse {
//
// /** list of referring domains with click counts */
// public List<LinkReferringDomain> referring_domains;
//
// /** a single referring domain to a link with click counts */
// public static class LinkReferringDomain extends ToStringSupport {
//
// /** the number of clicks referred from this domain */
// public long clicks;
//
// /** the domain referring clicks */
// public String domain;
//
// /** the complete URL of the domain referring clicks */
// public String url;
// }
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferringDomainsResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referring_domains">/v3/link/referring_domains</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferringDomainsIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkReferringDomains() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferringDomainsResponse.java
// public class LinkReferringDomainsResponse extends MetricsResponse {
//
// /** list of referring domains with click counts */
// public List<LinkReferringDomain> referring_domains;
//
// /** a single referring domain to a link with click counts */
// public static class LinkReferringDomain extends ToStringSupport {
//
// /** the number of clicks referred from this domain */
// public long clicks;
//
// /** the domain referring clicks */
// public String domain;
//
// /** the complete URL of the domain referring clicks */
// public String url;
// }
// }
// Path: src/intTest/java/net/swisstech/bitly/test/LinkReferringDomainsIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferringDomainsResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referring_domains">/v3/link/referring_domains</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferringDomainsIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkReferringDomains() { | Response<LinkReferringDomainsResponse> resp = getClient().linkReferringDomains() // |
stackmagic/bitly-api-client | src/intTest/java/net/swisstech/bitly/test/LinkReferringDomainsIntegrationTest.java | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferringDomainsResponse.java
// public class LinkReferringDomainsResponse extends MetricsResponse {
//
// /** list of referring domains with click counts */
// public List<LinkReferringDomain> referring_domains;
//
// /** a single referring domain to a link with click counts */
// public static class LinkReferringDomain extends ToStringSupport {
//
// /** the number of clicks referred from this domain */
// public long clicks;
//
// /** the domain referring clicks */
// public String domain;
//
// /** the complete URL of the domain referring clicks */
// public String url;
// }
// }
| import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferringDomainsResponse;
import org.testng.annotations.Test; | /*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referring_domains">/v3/link/referring_domains</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferringDomainsIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkReferringDomains() { | // Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
//
// /** This flag will be set if there was a deserialization error */
// public boolean deserialize_error = false;
//
// /** the actual response data */
// public T data;
// }
//
// Path: src/main/java/net/swisstech/bitly/model/v3/LinkReferringDomainsResponse.java
// public class LinkReferringDomainsResponse extends MetricsResponse {
//
// /** list of referring domains with click counts */
// public List<LinkReferringDomain> referring_domains;
//
// /** a single referring domain to a link with click counts */
// public static class LinkReferringDomain extends ToStringSupport {
//
// /** the number of clicks referred from this domain */
// public long clicks;
//
// /** the domain referring clicks */
// public String domain;
//
// /** the complete URL of the domain referring clicks */
// public String url;
// }
// }
// Path: src/intTest/java/net/swisstech/bitly/test/LinkReferringDomainsIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.LinkReferringDomainsResponse;
import org.testng.annotations.Test;
/*
* Copyright (c) Patrick Huber (gmail: stackmagic)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.swisstech.bitly.test;
/**
* <p>
* Please see the bit.ly documentation for the <a href="http://dev.bitly.com/link_metrics.html#v3_link_referring_domains">/v3/link/referring_domains</a>
* request.
* </p>
* @author Patrick Huber (gmail: stackmagic)
*/
public class LinkReferringDomainsIntegrationTest extends AbstractBitlyClientIntegrationTest {
@Test
public void callLinkReferringDomains() { | Response<LinkReferringDomainsResponse> resp = getClient().linkReferringDomains() // |
johann-petrak/gateplugin-StringAnnotation | src/com/jpetrak/gate/stringannotation/utils/StoreArrayOfCharArrays.java | // Path: src/com/jpetrak/gate/stringannotation/extendedgazetteer/trie/Utils.java
// public class Utils {
//
// /**
// * Converts two characters two an int number
// *
// * @param chars
// * @return
// */
// public static int twoChars2Int(char ch, char cl) {
// int l = (ch << 16) + cl;
// return l;
// }
//
// public static int twoChars2Int(char[] cs) {
// if(cs.length != 2) {
// throw new RuntimeException("Called twoChars2Int with an array that does not have 2 elements but "+cs.length);
// }
// return twoChars2Int(cs[0],cs[1]);
// }
//
// /**
// * Converts an int into an array of two characters with the high bits
// * in the first element and the low bits in the second element
// * @param i
// * @return
// */
// public static char[] int2TwoChars(int i) {
// char[] asChars = new char[2];
// asChars[0] = (char)(i >>> 16);
// asChars[1] = (char)(i & 0xFFFF);
// return asChars;
// }
//
// /**
// * Sets two characters at position pos to the representation of int as two successive
// * characters.
// * @param i
// * @param chars
// * @param pos
// */
// public static void setTwoCharsFromInt(int i, char[] chars, int pos) {
// chars[pos] = (char)(i >>> 16);
// chars[pos+1] = (char)(i & 0xFFFF);
// }
//
//
// /**
// * Converts four characters two a long number
// *
// * @param chars
// * @return
// */
// public static long fourChars2Long(char c4, char c3, char c2, char c1) {
// long l = c1;
// l += ((long)c2) << 16;
// l += ((long)c3) << 32;
// l += ((long)c4) << 48;
// return l;
// }
//
// public static long fourChars2Long(char[] cs) {
// if(cs.length != 4) {
// throw new RuntimeException("Called fourChars2Long with an array that does not have 4 elements but "+cs.length);
// }
// return fourChars2Long(cs[0],cs[1],cs[2],cs[3]);
// }
//
//
// /**
// * Converts a long to a char array of four elements
// * @param i
// * @return
// */
// public static char[] long2FourChars(long i) {
// char[] asChars = new char[4];
// asChars[0] = (char)(i >>> 48);
// asChars[1] = (char)((i >>> 32) & 0xFFFF);
// asChars[2] = (char)((i >>> 16) & 0xFFFF);
// asChars[3] = (char)(i & 0xFFFF);
// return asChars;
// }
//
//
// }
| import gate.util.GateRuntimeException;
import it.unimi.dsi.fastutil.chars.CharBigArrayBigList;
import com.jpetrak.gate.stringannotation.extendedgazetteer.trie.Utils;
import java.io.Serializable; | /*
* Copyright (c) 2010- Austrian Research Institute for Artificial Intelligence (OFAI).
* Copyright (C) 2014-2016 The University of Sheffield.
*
* This file is part of gateplugin-StringAnnotation
* (see https://github.com/johann-petrak/gateplugin-StringAnnotation)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpetrak.gate.stringannotation.utils;
/**
* This represents a store that can add and retrieve char[] elements. Each char[] chunk
* is identified by an int index which is returned when adding the chunk and which
* must be used to get it back. The number of chunks in a store is limited to 2^31, and
* the length of each chunk is also limited to 2^31, but the total amount of chars in
* the store can exceed 2^32 (unsigned 32 bit).
* <p>
* The store supports storing the following:
* <ul>
* <li>Varying length chunks. Internally, these are stored by two characters representing
* the length of the data followed by the data itself.
* <li>Fixed length chunks. The data is stored as-is, but the client must know
* the length of the data at retrieval time!
* <li>Lists: each list consists of one or more elements of varying length chunks.
* Internally, the first
* of a list consists of the the chunk length, the list size, the index of the next element chunk
* and the actual chunk data for the first element. Elements 2-N consist of the chunk length,
* the index of the next element chunk and the actual chunk data. Next chunk index and in the
* first element, the list size are included in chunk length, the chunk length field itself
* is not.
* </ul>
*
* @author Johann Petrak
*
*/
public class StoreArrayOfCharArrays implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1238979454339893943L;
CharBigArrayBigList theList = new CharBigArrayBigList();
int curIndex = 0;
| // Path: src/com/jpetrak/gate/stringannotation/extendedgazetteer/trie/Utils.java
// public class Utils {
//
// /**
// * Converts two characters two an int number
// *
// * @param chars
// * @return
// */
// public static int twoChars2Int(char ch, char cl) {
// int l = (ch << 16) + cl;
// return l;
// }
//
// public static int twoChars2Int(char[] cs) {
// if(cs.length != 2) {
// throw new RuntimeException("Called twoChars2Int with an array that does not have 2 elements but "+cs.length);
// }
// return twoChars2Int(cs[0],cs[1]);
// }
//
// /**
// * Converts an int into an array of two characters with the high bits
// * in the first element and the low bits in the second element
// * @param i
// * @return
// */
// public static char[] int2TwoChars(int i) {
// char[] asChars = new char[2];
// asChars[0] = (char)(i >>> 16);
// asChars[1] = (char)(i & 0xFFFF);
// return asChars;
// }
//
// /**
// * Sets two characters at position pos to the representation of int as two successive
// * characters.
// * @param i
// * @param chars
// * @param pos
// */
// public static void setTwoCharsFromInt(int i, char[] chars, int pos) {
// chars[pos] = (char)(i >>> 16);
// chars[pos+1] = (char)(i & 0xFFFF);
// }
//
//
// /**
// * Converts four characters two a long number
// *
// * @param chars
// * @return
// */
// public static long fourChars2Long(char c4, char c3, char c2, char c1) {
// long l = c1;
// l += ((long)c2) << 16;
// l += ((long)c3) << 32;
// l += ((long)c4) << 48;
// return l;
// }
//
// public static long fourChars2Long(char[] cs) {
// if(cs.length != 4) {
// throw new RuntimeException("Called fourChars2Long with an array that does not have 4 elements but "+cs.length);
// }
// return fourChars2Long(cs[0],cs[1],cs[2],cs[3]);
// }
//
//
// /**
// * Converts a long to a char array of four elements
// * @param i
// * @return
// */
// public static char[] long2FourChars(long i) {
// char[] asChars = new char[4];
// asChars[0] = (char)(i >>> 48);
// asChars[1] = (char)((i >>> 32) & 0xFFFF);
// asChars[2] = (char)((i >>> 16) & 0xFFFF);
// asChars[3] = (char)(i & 0xFFFF);
// return asChars;
// }
//
//
// }
// Path: src/com/jpetrak/gate/stringannotation/utils/StoreArrayOfCharArrays.java
import gate.util.GateRuntimeException;
import it.unimi.dsi.fastutil.chars.CharBigArrayBigList;
import com.jpetrak.gate.stringannotation.extendedgazetteer.trie.Utils;
import java.io.Serializable;
/*
* Copyright (c) 2010- Austrian Research Institute for Artificial Intelligence (OFAI).
* Copyright (C) 2014-2016 The University of Sheffield.
*
* This file is part of gateplugin-StringAnnotation
* (see https://github.com/johann-petrak/gateplugin-StringAnnotation)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpetrak.gate.stringannotation.utils;
/**
* This represents a store that can add and retrieve char[] elements. Each char[] chunk
* is identified by an int index which is returned when adding the chunk and which
* must be used to get it back. The number of chunks in a store is limited to 2^31, and
* the length of each chunk is also limited to 2^31, but the total amount of chars in
* the store can exceed 2^32 (unsigned 32 bit).
* <p>
* The store supports storing the following:
* <ul>
* <li>Varying length chunks. Internally, these are stored by two characters representing
* the length of the data followed by the data itself.
* <li>Fixed length chunks. The data is stored as-is, but the client must know
* the length of the data at retrieval time!
* <li>Lists: each list consists of one or more elements of varying length chunks.
* Internally, the first
* of a list consists of the the chunk length, the list size, the index of the next element chunk
* and the actual chunk data for the first element. Elements 2-N consist of the chunk length,
* the index of the next element chunk and the actual chunk data. Next chunk index and in the
* first element, the list size are included in chunk length, the chunk length field itself
* is not.
* </ul>
*
* @author Johann Petrak
*
*/
public class StoreArrayOfCharArrays implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1238979454339893943L;
CharBigArrayBigList theList = new CharBigArrayBigList();
int curIndex = 0;
| private char[] zeroChars = Utils.int2TwoChars(0); |
BorderTech/wcomponents | wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/AccessKeyRendererUtil.java | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AccessKeyable.java
// public interface AccessKeyable extends WComponent {
//
// /**
// * @return the component's access key.
// */
// char getAccessKey();
//
// /**
// * Set the access key on the component.
// *
// * @param accessKey the key that will form a keyboard shortcut to the component.
// */
// void setAccessKey(final char accessKey);
//
// /**
// * Returns the access key character as a String. If the character is not a letter or digit then <code>null</code> is
// * returned.
// *
// * @return the access key character as a String (may be <code>null</code>).
// */
// default String getAccessKeyAsString() {
// char accessKey = getAccessKey();
//
// if (Character.isLetterOrDigit(accessKey)) {
// return String.valueOf(accessKey);
// }
//
// return null;
// }
//
// }
| import com.github.bordertech.wcomponents.AccessKeyable;
import com.github.bordertech.wcomponents.XmlStringBuilder;
import com.github.bordertech.wcomponents.servlet.WebXmlRenderContext;
import com.github.bordertech.wcomponents.util.Util; | package com.github.bordertech.wcomponents.render.webxml;
/**
* Utility methods for rendering access key details.
*/
public final class AccessKeyRendererUtil {
/**
* Prevent instantiation of utility class.
*/
private AccessKeyRendererUtil() {
// Do nothing
}
/**
* Add the optional XML attribute for access key.
*
* @param component the component with an access key
* @param renderContext the RenderContext to paint to
*/ | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/AccessKeyable.java
// public interface AccessKeyable extends WComponent {
//
// /**
// * @return the component's access key.
// */
// char getAccessKey();
//
// /**
// * Set the access key on the component.
// *
// * @param accessKey the key that will form a keyboard shortcut to the component.
// */
// void setAccessKey(final char accessKey);
//
// /**
// * Returns the access key character as a String. If the character is not a letter or digit then <code>null</code> is
// * returned.
// *
// * @return the access key character as a String (may be <code>null</code>).
// */
// default String getAccessKeyAsString() {
// char accessKey = getAccessKey();
//
// if (Character.isLetterOrDigit(accessKey)) {
// return String.valueOf(accessKey);
// }
//
// return null;
// }
//
// }
// Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/AccessKeyRendererUtil.java
import com.github.bordertech.wcomponents.AccessKeyable;
import com.github.bordertech.wcomponents.XmlStringBuilder;
import com.github.bordertech.wcomponents.servlet.WebXmlRenderContext;
import com.github.bordertech.wcomponents.util.Util;
package com.github.bordertech.wcomponents.render.webxml;
/**
* Utility methods for rendering access key details.
*/
public final class AccessKeyRendererUtil {
/**
* Prevent instantiation of utility class.
*/
private AccessKeyRendererUtil() {
// Do nothing
}
/**
* Add the optional XML attribute for access key.
*
* @param component the component with an access key
* @param renderContext the RenderContext to paint to
*/ | public static void appendOptionalAccessKeyXMLAttribute(final AccessKeyable component, final WebXmlRenderContext renderContext) { |
BorderTech/wcomponents | wcomponents-core/src/test/java/com/github/bordertech/wcomponents/autocomplete/AutocompleteableURL_Test.java | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/type/Url.java
// public enum Url {
// /**
// * Indicates the field represents a home page or other Web page corresponding to the company, person, address, or contact information in the
// * other fields associated with this field.
// */
// URL("url"),
// /**
// * Indicates the field represents a URL representing an instant messaging protocol endpoint (for example, "aim:goim?screenname=example" or
// * "xmpp:user@example.net").
// */
// IMPP("impp"),
// /**
// * Indicates the field represents a photograph, icon, or other image corresponding to the company, person, address, or contact information in
// * the other fields associated with this field.
// */
// PHOTO("photo");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// Url(final String val) {
// value = val;
// }
//
// /**
// * @return the {@code autocomplete} attribute value for the enum member.
// */
// public String getValue() {
// return value;
// }
//
// }
| import com.github.bordertech.wcomponents.Container;
import com.github.bordertech.wcomponents.Environment;
import com.github.bordertech.wcomponents.Headers;
import com.github.bordertech.wcomponents.RenderContext;
import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.WLabel;
import com.github.bordertech.wcomponents.autocomplete.type.Url;
import com.github.bordertech.wcomponents.util.HtmlClassProperties;
import com.github.bordertech.wcomponents.validation.Diagnostic;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test; | package com.github.bordertech.wcomponents.autocomplete;
/**
* JUnit tests of default methods of Interface {@link AutocompleteableURL}.
* @author Mark Reeves
* @since 1.5.3
*/
public class AutocompleteableURL_Test {
/**
* Meta test to improve confidence in other tests.
*/
@Test
public void testGetAutocomplete() {
String testString = "foo";
MyAutocompleteable component = new MyAutocompleteable();
// ensure the component's autocompete is set to a specific thing outside the interface setters.
component.setAutocompleteDirectly(testString);
Assert.assertEquals(testString, component.getAutocomplete());
}
@Test
public void testSetUrlAutocomplete() {
MyAutocompleteable component = new MyAutocompleteable();
component.setUrlAutocomplete(); | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/type/Url.java
// public enum Url {
// /**
// * Indicates the field represents a home page or other Web page corresponding to the company, person, address, or contact information in the
// * other fields associated with this field.
// */
// URL("url"),
// /**
// * Indicates the field represents a URL representing an instant messaging protocol endpoint (for example, "aim:goim?screenname=example" or
// * "xmpp:user@example.net").
// */
// IMPP("impp"),
// /**
// * Indicates the field represents a photograph, icon, or other image corresponding to the company, person, address, or contact information in
// * the other fields associated with this field.
// */
// PHOTO("photo");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// Url(final String val) {
// value = val;
// }
//
// /**
// * @return the {@code autocomplete} attribute value for the enum member.
// */
// public String getValue() {
// return value;
// }
//
// }
// Path: wcomponents-core/src/test/java/com/github/bordertech/wcomponents/autocomplete/AutocompleteableURL_Test.java
import com.github.bordertech.wcomponents.Container;
import com.github.bordertech.wcomponents.Environment;
import com.github.bordertech.wcomponents.Headers;
import com.github.bordertech.wcomponents.RenderContext;
import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.WLabel;
import com.github.bordertech.wcomponents.autocomplete.type.Url;
import com.github.bordertech.wcomponents.util.HtmlClassProperties;
import com.github.bordertech.wcomponents.validation.Diagnostic;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
package com.github.bordertech.wcomponents.autocomplete;
/**
* JUnit tests of default methods of Interface {@link AutocompleteableURL}.
* @author Mark Reeves
* @since 1.5.3
*/
public class AutocompleteableURL_Test {
/**
* Meta test to improve confidence in other tests.
*/
@Test
public void testGetAutocomplete() {
String testString = "foo";
MyAutocompleteable component = new MyAutocompleteable();
// ensure the component's autocompete is set to a specific thing outside the interface setters.
component.setAutocompleteDirectly(testString);
Assert.assertEquals(testString, component.getAutocomplete());
}
@Test
public void testSetUrlAutocomplete() {
MyAutocompleteable component = new MyAutocompleteable();
component.setUrlAutocomplete(); | Assert.assertEquals(Url.URL.getValue(), component.getAutocomplete()); |
BorderTech/wcomponents | wcomponents-core/src/test/java/com/github/bordertech/wcomponents/autocomplete/AutocompleteablePhone_Test.java | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/segment/PhoneFormat.java
// public enum PhoneFormat implements AutocompleteSegment {
// /**
// * Indicates the field represents a number for contacting someone at their residence.
// */
// HOME("home"),
// /**
// * Indicates the field represents a number for contacting someone at their workplace.
// */
// WORK("work"),
// /**
// * Indicates the field represents a number for contacting someone regardless of location.
// */
// MOBILE("mobile"),
// /**
// * Indicates the field represents a fax machine's contact details.
// */
// FAX("fax"),
// /**
// * Indicates the field represents a pager's or beeper's contact details.
// */
// PAGER("pager");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// PhoneFormat(final String val) {
// this.value = val;
// }
//
// @Override
// public String getValue() {
// return this.value;
// }
//
// }
//
// Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/type/Telephone.java
// public enum Telephone {
// /**
// * Indicates the field represents a full telephone number, including country code, in the form of ASCII digits and optional U+0020 SPACE
// * characters, prefixed by a U+002B PLUS SIGN character (+); may be applied to a {@link com.github.bordertech.wcomponents.WPhoneNumberField}.
// */
// FULL("tel"),
// /**
// * Indicates the field represents a telephone number without the country code and area code components, in the form of ASCII digits but not to
// * be used with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// LOCAL("tel-local");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// Telephone(final String val) {
// this.value = val;
// }
//
// /**
// * @return the {@code autocomplete} attribute value for the enum member.
// */
// public String getValue() {
// return this.value;
// }
//
// }
| import com.github.bordertech.wcomponents.Container;
import com.github.bordertech.wcomponents.Environment;
import com.github.bordertech.wcomponents.Headers;
import com.github.bordertech.wcomponents.RenderContext;
import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.WLabel;
import com.github.bordertech.wcomponents.autocomplete.segment.PhoneFormat;
import com.github.bordertech.wcomponents.autocomplete.type.Telephone;
import com.github.bordertech.wcomponents.util.HtmlClassProperties;
import com.github.bordertech.wcomponents.validation.Diagnostic;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test; | package com.github.bordertech.wcomponents.autocomplete;
/**
* JUnit test of the {@link Autocompleteable} Interface.
* @author Mark Reeves
*/
public class AutocompleteablePhone_Test {
/**
* Meta test to improve confidence in other tests.
*/
@Test
public void testGetAucomplete() {
String testString = "foo";
MyAutocompleteable component = new MyAutocompleteable();
// ensure the component's autocompete is set to a specific thing outside the
// interface setters.
component.setAutocompleteDirectly(testString);
Assert.assertEquals(testString, component.getAutocomplete());
}
@Test
public void testSetFullPhoneAutocompleteWithType() {
MyAutocompleteable component = new MyAutocompleteable();
String expected;
| // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/segment/PhoneFormat.java
// public enum PhoneFormat implements AutocompleteSegment {
// /**
// * Indicates the field represents a number for contacting someone at their residence.
// */
// HOME("home"),
// /**
// * Indicates the field represents a number for contacting someone at their workplace.
// */
// WORK("work"),
// /**
// * Indicates the field represents a number for contacting someone regardless of location.
// */
// MOBILE("mobile"),
// /**
// * Indicates the field represents a fax machine's contact details.
// */
// FAX("fax"),
// /**
// * Indicates the field represents a pager's or beeper's contact details.
// */
// PAGER("pager");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// PhoneFormat(final String val) {
// this.value = val;
// }
//
// @Override
// public String getValue() {
// return this.value;
// }
//
// }
//
// Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/type/Telephone.java
// public enum Telephone {
// /**
// * Indicates the field represents a full telephone number, including country code, in the form of ASCII digits and optional U+0020 SPACE
// * characters, prefixed by a U+002B PLUS SIGN character (+); may be applied to a {@link com.github.bordertech.wcomponents.WPhoneNumberField}.
// */
// FULL("tel"),
// /**
// * Indicates the field represents a telephone number without the country code and area code components, in the form of ASCII digits but not to
// * be used with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// LOCAL("tel-local");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// Telephone(final String val) {
// this.value = val;
// }
//
// /**
// * @return the {@code autocomplete} attribute value for the enum member.
// */
// public String getValue() {
// return this.value;
// }
//
// }
// Path: wcomponents-core/src/test/java/com/github/bordertech/wcomponents/autocomplete/AutocompleteablePhone_Test.java
import com.github.bordertech.wcomponents.Container;
import com.github.bordertech.wcomponents.Environment;
import com.github.bordertech.wcomponents.Headers;
import com.github.bordertech.wcomponents.RenderContext;
import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.WLabel;
import com.github.bordertech.wcomponents.autocomplete.segment.PhoneFormat;
import com.github.bordertech.wcomponents.autocomplete.type.Telephone;
import com.github.bordertech.wcomponents.util.HtmlClassProperties;
import com.github.bordertech.wcomponents.validation.Diagnostic;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
package com.github.bordertech.wcomponents.autocomplete;
/**
* JUnit test of the {@link Autocompleteable} Interface.
* @author Mark Reeves
*/
public class AutocompleteablePhone_Test {
/**
* Meta test to improve confidence in other tests.
*/
@Test
public void testGetAucomplete() {
String testString = "foo";
MyAutocompleteable component = new MyAutocompleteable();
// ensure the component's autocompete is set to a specific thing outside the
// interface setters.
component.setAutocompleteDirectly(testString);
Assert.assertEquals(testString, component.getAutocomplete());
}
@Test
public void testSetFullPhoneAutocompleteWithType() {
MyAutocompleteable component = new MyAutocompleteable();
String expected;
| for (PhoneFormat phoneType : PhoneFormat.values()) { |
BorderTech/wcomponents | wcomponents-core/src/test/java/com/github/bordertech/wcomponents/autocomplete/AutocompleteablePhone_Test.java | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/segment/PhoneFormat.java
// public enum PhoneFormat implements AutocompleteSegment {
// /**
// * Indicates the field represents a number for contacting someone at their residence.
// */
// HOME("home"),
// /**
// * Indicates the field represents a number for contacting someone at their workplace.
// */
// WORK("work"),
// /**
// * Indicates the field represents a number for contacting someone regardless of location.
// */
// MOBILE("mobile"),
// /**
// * Indicates the field represents a fax machine's contact details.
// */
// FAX("fax"),
// /**
// * Indicates the field represents a pager's or beeper's contact details.
// */
// PAGER("pager");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// PhoneFormat(final String val) {
// this.value = val;
// }
//
// @Override
// public String getValue() {
// return this.value;
// }
//
// }
//
// Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/type/Telephone.java
// public enum Telephone {
// /**
// * Indicates the field represents a full telephone number, including country code, in the form of ASCII digits and optional U+0020 SPACE
// * characters, prefixed by a U+002B PLUS SIGN character (+); may be applied to a {@link com.github.bordertech.wcomponents.WPhoneNumberField}.
// */
// FULL("tel"),
// /**
// * Indicates the field represents a telephone number without the country code and area code components, in the form of ASCII digits but not to
// * be used with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// LOCAL("tel-local");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// Telephone(final String val) {
// this.value = val;
// }
//
// /**
// * @return the {@code autocomplete} attribute value for the enum member.
// */
// public String getValue() {
// return this.value;
// }
//
// }
| import com.github.bordertech.wcomponents.Container;
import com.github.bordertech.wcomponents.Environment;
import com.github.bordertech.wcomponents.Headers;
import com.github.bordertech.wcomponents.RenderContext;
import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.WLabel;
import com.github.bordertech.wcomponents.autocomplete.segment.PhoneFormat;
import com.github.bordertech.wcomponents.autocomplete.type.Telephone;
import com.github.bordertech.wcomponents.util.HtmlClassProperties;
import com.github.bordertech.wcomponents.validation.Diagnostic;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test; | package com.github.bordertech.wcomponents.autocomplete;
/**
* JUnit test of the {@link Autocompleteable} Interface.
* @author Mark Reeves
*/
public class AutocompleteablePhone_Test {
/**
* Meta test to improve confidence in other tests.
*/
@Test
public void testGetAucomplete() {
String testString = "foo";
MyAutocompleteable component = new MyAutocompleteable();
// ensure the component's autocompete is set to a specific thing outside the
// interface setters.
component.setAutocompleteDirectly(testString);
Assert.assertEquals(testString, component.getAutocomplete());
}
@Test
public void testSetFullPhoneAutocompleteWithType() {
MyAutocompleteable component = new MyAutocompleteable();
String expected;
for (PhoneFormat phoneType : PhoneFormat.values()) { | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/segment/PhoneFormat.java
// public enum PhoneFormat implements AutocompleteSegment {
// /**
// * Indicates the field represents a number for contacting someone at their residence.
// */
// HOME("home"),
// /**
// * Indicates the field represents a number for contacting someone at their workplace.
// */
// WORK("work"),
// /**
// * Indicates the field represents a number for contacting someone regardless of location.
// */
// MOBILE("mobile"),
// /**
// * Indicates the field represents a fax machine's contact details.
// */
// FAX("fax"),
// /**
// * Indicates the field represents a pager's or beeper's contact details.
// */
// PAGER("pager");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// PhoneFormat(final String val) {
// this.value = val;
// }
//
// @Override
// public String getValue() {
// return this.value;
// }
//
// }
//
// Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/type/Telephone.java
// public enum Telephone {
// /**
// * Indicates the field represents a full telephone number, including country code, in the form of ASCII digits and optional U+0020 SPACE
// * characters, prefixed by a U+002B PLUS SIGN character (+); may be applied to a {@link com.github.bordertech.wcomponents.WPhoneNumberField}.
// */
// FULL("tel"),
// /**
// * Indicates the field represents a telephone number without the country code and area code components, in the form of ASCII digits but not to
// * be used with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// LOCAL("tel-local");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// Telephone(final String val) {
// this.value = val;
// }
//
// /**
// * @return the {@code autocomplete} attribute value for the enum member.
// */
// public String getValue() {
// return this.value;
// }
//
// }
// Path: wcomponents-core/src/test/java/com/github/bordertech/wcomponents/autocomplete/AutocompleteablePhone_Test.java
import com.github.bordertech.wcomponents.Container;
import com.github.bordertech.wcomponents.Environment;
import com.github.bordertech.wcomponents.Headers;
import com.github.bordertech.wcomponents.RenderContext;
import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.WLabel;
import com.github.bordertech.wcomponents.autocomplete.segment.PhoneFormat;
import com.github.bordertech.wcomponents.autocomplete.type.Telephone;
import com.github.bordertech.wcomponents.util.HtmlClassProperties;
import com.github.bordertech.wcomponents.validation.Diagnostic;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
package com.github.bordertech.wcomponents.autocomplete;
/**
* JUnit test of the {@link Autocompleteable} Interface.
* @author Mark Reeves
*/
public class AutocompleteablePhone_Test {
/**
* Meta test to improve confidence in other tests.
*/
@Test
public void testGetAucomplete() {
String testString = "foo";
MyAutocompleteable component = new MyAutocompleteable();
// ensure the component's autocompete is set to a specific thing outside the
// interface setters.
component.setAutocompleteDirectly(testString);
Assert.assertEquals(testString, component.getAutocomplete());
}
@Test
public void testSetFullPhoneAutocompleteWithType() {
MyAutocompleteable component = new MyAutocompleteable();
String expected;
for (PhoneFormat phoneType : PhoneFormat.values()) { | expected = AutocompleteUtil.getCombinedAutocomplete(phoneType.getValue(), Telephone.FULL.getValue()); |
BorderTech/wcomponents | wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WNumberFieldExample.java | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/type/Numeric.java
// public enum Numeric {
// /**
// * Indicates the field represents the day component of birthday as a valid integer from 1 to 31; used in conjunction with
// * {@link com.github.bordertech.wcomponents.WNumberField} or an appropriately configured selection tool such as
// * {@link com.github.bordertech.wcomponents.WDropdown}.
// */
// BIRTHDAY_DAY("bday-day"),
// /**
// * Indicates the field represents the month component of birthday as a valid integer from 1 to 12; used in conjunction with
// * {@link com.github.bordertech.wcomponents.WNumberField} or an appropriately configured selection tool such as
// * {@link com.github.bordertech.wcomponents.WDropdown}.
// */
// BIRTHDAY_MONTH("bday-month"),
// /**
// * Indicates the field represents the year component of birthday as a valid positive integer; used in conjunction with
// * {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// BIRTHDAY_YEAR("bday-year"),
// /**
// * Indicates the field represents the month component of the expiration date of the payment instrument as an integer from 1 to 12 and should
// * be used in conjunction with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// CREDIT_CARD_EXPIRY_MONTH("cc-exp-month"),
// /**
// * Indicates the field represents the year component of the expiration date of the payment instrument as a positive integer and should be used
// * in conjunction with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// CREDIT_CARD_EXPIRY_YEAR("cc-exp-year"),
// /**
// * Indicates the field represents the amount that the user would like for the transaction (for example when entering a bid or sale price) as a
// * floating point number; used in conjunction with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// TRANSACTION_AMOUNT("transaction-amount");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// Numeric(final String val) {
// value = val;
// }
//
// /**
// * @return the {@code autocomplete} attribute value for the enum member.
// */
// public String getValue() {
// return value;
// }
//
// }
| import com.github.bordertech.wcomponents.WContainer;
import com.github.bordertech.wcomponents.WFieldLayout;
import com.github.bordertech.wcomponents.WNumberField;
import com.github.bordertech.wcomponents.autocomplete.type.Numeric; | numberField.setNumber(3);
numberField.setDisabled(true);
layout.addField("Disabled input with value", numberField);
numberField = new WNumberField();
numberField.setMandatory(true);
layout.addField("Mandatory input", numberField);
numberField = new WNumberField();
numberField.setReadOnly(true);
layout.addField("Read only input", numberField);
numberField = new WNumberField();
numberField.setNumber(3);
numberField.setReadOnly(true);
layout.addField("Read only input with value", numberField);
// constraints
numberField = new WNumberField();
numberField.setMaxValue(200);
layout.addField("Max 200", numberField);
numberField = new WNumberField();
numberField.setMinValue(0);
layout.addField("Min 0", numberField);
numberField = new WNumberField();
numberField.setMinValue(0);
numberField.setStep(5);
layout.addField("Min 0, step 5", numberField);
//autocomplete | // Path: wcomponents-core/src/main/java/com/github/bordertech/wcomponents/autocomplete/type/Numeric.java
// public enum Numeric {
// /**
// * Indicates the field represents the day component of birthday as a valid integer from 1 to 31; used in conjunction with
// * {@link com.github.bordertech.wcomponents.WNumberField} or an appropriately configured selection tool such as
// * {@link com.github.bordertech.wcomponents.WDropdown}.
// */
// BIRTHDAY_DAY("bday-day"),
// /**
// * Indicates the field represents the month component of birthday as a valid integer from 1 to 12; used in conjunction with
// * {@link com.github.bordertech.wcomponents.WNumberField} or an appropriately configured selection tool such as
// * {@link com.github.bordertech.wcomponents.WDropdown}.
// */
// BIRTHDAY_MONTH("bday-month"),
// /**
// * Indicates the field represents the year component of birthday as a valid positive integer; used in conjunction with
// * {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// BIRTHDAY_YEAR("bday-year"),
// /**
// * Indicates the field represents the month component of the expiration date of the payment instrument as an integer from 1 to 12 and should
// * be used in conjunction with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// CREDIT_CARD_EXPIRY_MONTH("cc-exp-month"),
// /**
// * Indicates the field represents the year component of the expiration date of the payment instrument as a positive integer and should be used
// * in conjunction with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// CREDIT_CARD_EXPIRY_YEAR("cc-exp-year"),
// /**
// * Indicates the field represents the amount that the user would like for the transaction (for example when entering a bid or sale price) as a
// * floating point number; used in conjunction with {@link com.github.bordertech.wcomponents.WNumberField}.
// */
// TRANSACTION_AMOUNT("transaction-amount");
// /**
// * The the {@code autocomplete} attribute value.
// */
// private final String value;
//
// /**
// * Creates each entry in the enumeration to allow for moderately type-safe auto-fill mnemonics.
// *
// * @param val the string to place in the {@code autocomplete} attribute
// */
// Numeric(final String val) {
// value = val;
// }
//
// /**
// * @return the {@code autocomplete} attribute value for the enum member.
// */
// public String getValue() {
// return value;
// }
//
// }
// Path: wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WNumberFieldExample.java
import com.github.bordertech.wcomponents.WContainer;
import com.github.bordertech.wcomponents.WFieldLayout;
import com.github.bordertech.wcomponents.WNumberField;
import com.github.bordertech.wcomponents.autocomplete.type.Numeric;
numberField.setNumber(3);
numberField.setDisabled(true);
layout.addField("Disabled input with value", numberField);
numberField = new WNumberField();
numberField.setMandatory(true);
layout.addField("Mandatory input", numberField);
numberField = new WNumberField();
numberField.setReadOnly(true);
layout.addField("Read only input", numberField);
numberField = new WNumberField();
numberField.setNumber(3);
numberField.setReadOnly(true);
layout.addField("Read only input with value", numberField);
// constraints
numberField = new WNumberField();
numberField.setMaxValue(200);
layout.addField("Max 200", numberField);
numberField = new WNumberField();
numberField.setMinValue(0);
layout.addField("Min 0", numberField);
numberField = new WNumberField();
numberField.setMinValue(0);
numberField.setStep(5);
layout.addField("Min 0, step 5", numberField);
//autocomplete | for (Numeric number : Numeric.values()) { |
scop/portecle | src/main/net/sf/portecle/DExport.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Window;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.text.MessageFormat;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import net.sf.portecle.crypto.CryptoException; | /*
* DExport.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2004-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog used to export keystore entries. A number of export types and formats are available depending on the
* entries content.
*/
class DExport
extends PortecleJDialog
{
/** Head certificate only export type radio button */
private JRadioButton m_jrbHeadCertOnly;
/** Certificate chain export type radio button */
private JRadioButton m_jrbCertChain;
/** Private key and certificate chain export type radio button */
private JRadioButton m_jrbPrivKeyCertChain;
/** DER Encoded export format radio button */
private JRadioButton m_jrbDEREncoded;
/** PEM Encoded export format radio button */
private JRadioButton m_jrbPemEncoded;
/** PKCS #7 export format radio button */
private JRadioButton m_jrbPKCS7;
/** PkiPath export format radio button */
private JRadioButton m_jrbPkiPath;
/** PKCS #12 export format radio button */
private JRadioButton m_jrbPKCS12;
/** The keystore to to export from */
private final KeyStoreWrapper m_keyStoreWrap;
/** The keystore entry to export */
private final String m_sEntryAlias;
/** Records whether or not the an export is selected */
private boolean m_bExportSelected;
/**
* Creates new DExport dialog.
*
* @param parent The parent window
* @param keyStore The keystore to export from
* @param sEntryAlias The keystore entry to export
* @throws CryptoException Problem accessing the keystore entry
*/
public DExport(Window parent, KeyStoreWrapper keyStore, String sEntryAlias)
throws CryptoException
{
super(parent, true);
m_keyStoreWrap = keyStore;
m_sEntryAlias = sEntryAlias;
initComponents();
}
/**
* Initialize the dialog's GUI components.
*
* @throws CryptoException Problem accessing the keystore entry
*/
private void initComponents()
throws CryptoException
{
// Export type controls
JPanel jpExportType = new JPanel(new GridLayout(3, 1)); | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/DExport.java
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Window;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.text.MessageFormat;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import net.sf.portecle.crypto.CryptoException;
/*
* DExport.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2004-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog used to export keystore entries. A number of export types and formats are available depending on the
* entries content.
*/
class DExport
extends PortecleJDialog
{
/** Head certificate only export type radio button */
private JRadioButton m_jrbHeadCertOnly;
/** Certificate chain export type radio button */
private JRadioButton m_jrbCertChain;
/** Private key and certificate chain export type radio button */
private JRadioButton m_jrbPrivKeyCertChain;
/** DER Encoded export format radio button */
private JRadioButton m_jrbDEREncoded;
/** PEM Encoded export format radio button */
private JRadioButton m_jrbPemEncoded;
/** PKCS #7 export format radio button */
private JRadioButton m_jrbPKCS7;
/** PkiPath export format radio button */
private JRadioButton m_jrbPkiPath;
/** PKCS #12 export format radio button */
private JRadioButton m_jrbPKCS12;
/** The keystore to to export from */
private final KeyStoreWrapper m_keyStoreWrap;
/** The keystore entry to export */
private final String m_sEntryAlias;
/** Records whether or not the an export is selected */
private boolean m_bExportSelected;
/**
* Creates new DExport dialog.
*
* @param parent The parent window
* @param keyStore The keystore to export from
* @param sEntryAlias The keystore entry to export
* @throws CryptoException Problem accessing the keystore entry
*/
public DExport(Window parent, KeyStoreWrapper keyStore, String sEntryAlias)
throws CryptoException
{
super(parent, true);
m_keyStoreWrap = keyStore;
m_sEntryAlias = sEntryAlias;
initComponents();
}
/**
* Initialize the dialog's GUI components.
*
* @throws CryptoException Problem accessing the keystore entry
*/
private void initComponents()
throws CryptoException
{
// Export type controls
JPanel jpExportType = new JPanel(new GridLayout(3, 1)); | jpExportType.setBorder(new TitledBorder(RB.getString("DExport.jpExportType.text"))); |
scop/portecle | src/main/net/sf/portecle/DGetAlias.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/gui/SwingHelper.java
// public final class SwingHelper
// {
// /** Not needed. */
// private SwingHelper()
// {
// // Ignored
// }
//
// /**
// * Makes the given Window visible and waits for it to return.
// *
// * @param window The window
// */
// public static void showAndWait(final Window window)
// {
// if (SwingUtilities.isEventDispatchThread())
// {
// window.setVisible(true);
// }
// else
// {
// try
// {
// SwingUtilities.invokeAndWait(new Runnable()
// {
// @Override
// public void run()
// {
// window.setVisible(true);
// }
// });
// }
// catch (InterruptedException | InvocationTargetException e)
// {
// LOG.log(Level.WARNING, "Error setting window visible", e); // TODO?
// }
// }
// }
//
// /**
// * Select all text in a text component and focus it.
// *
// * @param component the text component
// */
// public static void selectAndFocus(JComponent component)
// {
// JTextComponent textComponent = null;
// if (component instanceof JTextComponent)
// {
// textComponent = (JTextComponent) component;
// }
// if (component instanceof JComboBox)
// {
// Component editorComponent = ((JComboBox<?>) component).getEditor().getEditorComponent();
// if (editorComponent instanceof JTextComponent)
// {
// textComponent = (JTextComponent) editorComponent;
// }
// }
// if (textComponent != null)
// {
// textComponent.select(0, textComponent.getText().length());
// }
// component.requestFocusInWindow();
// }
//
// /**
// * Shows a simple yes/no confirmation dialog, with the "no" option selected by default. This method exists only
// * because there's apparently no easy way to accomplish that with JOptionPane's static helper methods.
// *
// * @param parentComponent
// * @param message
// * @param title
// * @return
// * @see JOptionPane#showConfirmDialog(Component, Object, String, int)
// */
// public static int showConfirmDialog(Component parentComponent, Object message, String title)
// {
// String[] options = { "Yes", "No" };
// return JOptionPane.showOptionDialog(parentComponent, message, title, JOptionPane.YES_NO_OPTION,
// JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
// }
// }
| import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.gui.SwingHelper;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JLabel; | /*
* DGetAlias.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog used for entering a keystore alias.
*/
class DGetAlias
extends PortecleJDialog
{
/** Alias text field */
private JTextField m_jtfAlias;
/** Stores the alias entered by the user */
private String m_sAlias;
/**
* Creates new DGetAlias dialog.
*
* @param parent The parent window
* @param sTitle The dialog's title
* @param sOldAlias The alias to display initially
* @param select Whether to pre-select the initially displayed alias
*/
public DGetAlias(Window parent, String sTitle, String sOldAlias, boolean select)
{
super(parent, sTitle, true);
initComponents(sOldAlias, select);
}
/**
* Get the alias entered by the user.
*
* @return The alias, or null if none was entered
*/
public String getAlias()
{
return m_sAlias;
}
/**
* Initialize the dialog's GUI components.
*
* @param sOldAlias The alias to display initially
* @param select Whether to pre-select the initially displayed alias
*/
private void initComponents(String sOldAlias, boolean select)
{
getContentPane().setLayout(new BorderLayout());
| // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/gui/SwingHelper.java
// public final class SwingHelper
// {
// /** Not needed. */
// private SwingHelper()
// {
// // Ignored
// }
//
// /**
// * Makes the given Window visible and waits for it to return.
// *
// * @param window The window
// */
// public static void showAndWait(final Window window)
// {
// if (SwingUtilities.isEventDispatchThread())
// {
// window.setVisible(true);
// }
// else
// {
// try
// {
// SwingUtilities.invokeAndWait(new Runnable()
// {
// @Override
// public void run()
// {
// window.setVisible(true);
// }
// });
// }
// catch (InterruptedException | InvocationTargetException e)
// {
// LOG.log(Level.WARNING, "Error setting window visible", e); // TODO?
// }
// }
// }
//
// /**
// * Select all text in a text component and focus it.
// *
// * @param component the text component
// */
// public static void selectAndFocus(JComponent component)
// {
// JTextComponent textComponent = null;
// if (component instanceof JTextComponent)
// {
// textComponent = (JTextComponent) component;
// }
// if (component instanceof JComboBox)
// {
// Component editorComponent = ((JComboBox<?>) component).getEditor().getEditorComponent();
// if (editorComponent instanceof JTextComponent)
// {
// textComponent = (JTextComponent) editorComponent;
// }
// }
// if (textComponent != null)
// {
// textComponent.select(0, textComponent.getText().length());
// }
// component.requestFocusInWindow();
// }
//
// /**
// * Shows a simple yes/no confirmation dialog, with the "no" option selected by default. This method exists only
// * because there's apparently no easy way to accomplish that with JOptionPane's static helper methods.
// *
// * @param parentComponent
// * @param message
// * @param title
// * @return
// * @see JOptionPane#showConfirmDialog(Component, Object, String, int)
// */
// public static int showConfirmDialog(Component parentComponent, Object message, String title)
// {
// String[] options = { "Yes", "No" };
// return JOptionPane.showOptionDialog(parentComponent, message, title, JOptionPane.YES_NO_OPTION,
// JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
// }
// }
// Path: src/main/net/sf/portecle/DGetAlias.java
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.gui.SwingHelper;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JLabel;
/*
* DGetAlias.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog used for entering a keystore alias.
*/
class DGetAlias
extends PortecleJDialog
{
/** Alias text field */
private JTextField m_jtfAlias;
/** Stores the alias entered by the user */
private String m_sAlias;
/**
* Creates new DGetAlias dialog.
*
* @param parent The parent window
* @param sTitle The dialog's title
* @param sOldAlias The alias to display initially
* @param select Whether to pre-select the initially displayed alias
*/
public DGetAlias(Window parent, String sTitle, String sOldAlias, boolean select)
{
super(parent, sTitle, true);
initComponents(sOldAlias, select);
}
/**
* Get the alias entered by the user.
*
* @return The alias, or null if none was entered
*/
public String getAlias()
{
return m_sAlias;
}
/**
* Initialize the dialog's GUI components.
*
* @param sOldAlias The alias to display initially
* @param select Whether to pre-select the initially displayed alias
*/
private void initComponents(String sOldAlias, boolean select)
{
getContentPane().setLayout(new BorderLayout());
| JLabel jlAlias = new JLabel(RB.getString("DGetAlias.jlAlias.text")); |
scop/portecle | src/main/net/sf/portecle/DGetAlias.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/gui/SwingHelper.java
// public final class SwingHelper
// {
// /** Not needed. */
// private SwingHelper()
// {
// // Ignored
// }
//
// /**
// * Makes the given Window visible and waits for it to return.
// *
// * @param window The window
// */
// public static void showAndWait(final Window window)
// {
// if (SwingUtilities.isEventDispatchThread())
// {
// window.setVisible(true);
// }
// else
// {
// try
// {
// SwingUtilities.invokeAndWait(new Runnable()
// {
// @Override
// public void run()
// {
// window.setVisible(true);
// }
// });
// }
// catch (InterruptedException | InvocationTargetException e)
// {
// LOG.log(Level.WARNING, "Error setting window visible", e); // TODO?
// }
// }
// }
//
// /**
// * Select all text in a text component and focus it.
// *
// * @param component the text component
// */
// public static void selectAndFocus(JComponent component)
// {
// JTextComponent textComponent = null;
// if (component instanceof JTextComponent)
// {
// textComponent = (JTextComponent) component;
// }
// if (component instanceof JComboBox)
// {
// Component editorComponent = ((JComboBox<?>) component).getEditor().getEditorComponent();
// if (editorComponent instanceof JTextComponent)
// {
// textComponent = (JTextComponent) editorComponent;
// }
// }
// if (textComponent != null)
// {
// textComponent.select(0, textComponent.getText().length());
// }
// component.requestFocusInWindow();
// }
//
// /**
// * Shows a simple yes/no confirmation dialog, with the "no" option selected by default. This method exists only
// * because there's apparently no easy way to accomplish that with JOptionPane's static helper methods.
// *
// * @param parentComponent
// * @param message
// * @param title
// * @return
// * @see JOptionPane#showConfirmDialog(Component, Object, String, int)
// */
// public static int showConfirmDialog(Component parentComponent, Object message, String title)
// {
// String[] options = { "Yes", "No" };
// return JOptionPane.showOptionDialog(parentComponent, message, title, JOptionPane.YES_NO_OPTION,
// JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
// }
// }
| import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.gui.SwingHelper;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JLabel; | private void initComponents(String sOldAlias, boolean select)
{
getContentPane().setLayout(new BorderLayout());
JLabel jlAlias = new JLabel(RB.getString("DGetAlias.jlAlias.text"));
m_jtfAlias = new JTextField(sOldAlias, 15);
m_jtfAlias.setCaretPosition(sOldAlias.length());
jlAlias.setLabelFor(m_jtfAlias);
JButton jbOK = getOkButton(false);
JButton jbCancel = getCancelButton();
JPanel jpAlias = new JPanel(new FlowLayout(FlowLayout.CENTER));
jpAlias.add(jlAlias);
jpAlias.add(m_jtfAlias);
jpAlias.setBorder(new EmptyBorder(5, 5, 5, 5));
JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
jpButtons.add(jbOK);
jpButtons.add(jbCancel);
getContentPane().add(jpAlias, BorderLayout.CENTER);
getContentPane().add(jpButtons, BorderLayout.SOUTH);
getRootPane().setDefaultButton(jbOK);
initDialog();
if (select)
{ | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/gui/SwingHelper.java
// public final class SwingHelper
// {
// /** Not needed. */
// private SwingHelper()
// {
// // Ignored
// }
//
// /**
// * Makes the given Window visible and waits for it to return.
// *
// * @param window The window
// */
// public static void showAndWait(final Window window)
// {
// if (SwingUtilities.isEventDispatchThread())
// {
// window.setVisible(true);
// }
// else
// {
// try
// {
// SwingUtilities.invokeAndWait(new Runnable()
// {
// @Override
// public void run()
// {
// window.setVisible(true);
// }
// });
// }
// catch (InterruptedException | InvocationTargetException e)
// {
// LOG.log(Level.WARNING, "Error setting window visible", e); // TODO?
// }
// }
// }
//
// /**
// * Select all text in a text component and focus it.
// *
// * @param component the text component
// */
// public static void selectAndFocus(JComponent component)
// {
// JTextComponent textComponent = null;
// if (component instanceof JTextComponent)
// {
// textComponent = (JTextComponent) component;
// }
// if (component instanceof JComboBox)
// {
// Component editorComponent = ((JComboBox<?>) component).getEditor().getEditorComponent();
// if (editorComponent instanceof JTextComponent)
// {
// textComponent = (JTextComponent) editorComponent;
// }
// }
// if (textComponent != null)
// {
// textComponent.select(0, textComponent.getText().length());
// }
// component.requestFocusInWindow();
// }
//
// /**
// * Shows a simple yes/no confirmation dialog, with the "no" option selected by default. This method exists only
// * because there's apparently no easy way to accomplish that with JOptionPane's static helper methods.
// *
// * @param parentComponent
// * @param message
// * @param title
// * @return
// * @see JOptionPane#showConfirmDialog(Component, Object, String, int)
// */
// public static int showConfirmDialog(Component parentComponent, Object message, String title)
// {
// String[] options = { "Yes", "No" };
// return JOptionPane.showOptionDialog(parentComponent, message, title, JOptionPane.YES_NO_OPTION,
// JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
// }
// }
// Path: src/main/net/sf/portecle/DGetAlias.java
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.gui.SwingHelper;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JLabel;
private void initComponents(String sOldAlias, boolean select)
{
getContentPane().setLayout(new BorderLayout());
JLabel jlAlias = new JLabel(RB.getString("DGetAlias.jlAlias.text"));
m_jtfAlias = new JTextField(sOldAlias, 15);
m_jtfAlias.setCaretPosition(sOldAlias.length());
jlAlias.setLabelFor(m_jtfAlias);
JButton jbOK = getOkButton(false);
JButton jbCancel = getCancelButton();
JPanel jpAlias = new JPanel(new FlowLayout(FlowLayout.CENTER));
jpAlias.add(jlAlias);
jpAlias.add(m_jtfAlias);
jpAlias.setBorder(new EmptyBorder(5, 5, 5, 5));
JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
jpButtons.add(jbOK);
jpButtons.add(jbCancel);
getContentPane().add(jpAlias, BorderLayout.CENTER);
getContentPane().add(jpButtons, BorderLayout.SOUTH);
getRootPane().setDefaultButton(jbOK);
initDialog();
if (select)
{ | SwingHelper.selectAndFocus(m_jtfAlias); |
scop/portecle | src/main/net/sf/portecle/ExtensionsTableHeadRend.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder; | /*
* ExtensionsTableHeadRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the headers of the Extensions table of DViewExtensions.
*/
class ExtensionsTableHeadRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered header cell for the supplied value and column.
*
* @param jtExtensions The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtExtensions, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
// Get header renderer
JLabel header = (JLabel) jtExtensions.getColumnModel().getColumn(iCol).getHeaderRenderer();
// The Critical header contains an icon
if (iCol == 0)
{
header.setText("");
ImageIcon icon = | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/ExtensionsTableHeadRend.java
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
/*
* ExtensionsTableHeadRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the headers of the Extensions table of DViewExtensions.
*/
class ExtensionsTableHeadRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered header cell for the supplied value and column.
*
* @param jtExtensions The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtExtensions, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
// Get header renderer
JLabel header = (JLabel) jtExtensions.getColumnModel().getColumn(iCol).getHeaderRenderer();
// The Critical header contains an icon
if (iCol == 0)
{
header.setText("");
ImageIcon icon = | new ImageIcon(getClass().getResource(RB.getString("ExtensionsTableHeadRend.CriticalColumn.image"))); |
scop/portecle | src/main/net/sf/portecle/crypto/X509Ext.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import static net.sf.portecle.FPortecle.RB;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.MissingResourceException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bouncycastle.asn1.ASN1Boolean;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1GeneralizedTime;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1String;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERGeneralString;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.DERUTCTime;
import org.bouncycastle.asn1.microsoft.MicrosoftObjectIdentifiers;
import org.bouncycastle.asn1.misc.MiscObjectIdentifiers;
import org.bouncycastle.asn1.misc.NetscapeCertType;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.smime.SMIMECapabilities;
import org.bouncycastle.asn1.smime.SMIMECapability;
import org.bouncycastle.asn1.x509.AccessDescription;
import org.bouncycastle.asn1.x509.AuthorityInformationAccess;
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.CRLDistPoint;
import org.bouncycastle.asn1.x509.CRLReason;
import org.bouncycastle.asn1.x509.DistributionPoint;
import org.bouncycastle.asn1.x509.DistributionPointName;
import org.bouncycastle.asn1.x509.ExtendedKeyUsage;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.KeyPurposeId;
import org.bouncycastle.asn1.x509.KeyUsage;
import org.bouncycastle.asn1.x509.PolicyInformation;
import org.bouncycastle.asn1.x509.PolicyQualifierId;
import org.bouncycastle.asn1.x509.PrivateKeyUsagePeriod;
import org.bouncycastle.asn1.x509.ReasonFlags;
import org.bouncycastle.asn1.x509.SubjectKeyIdentifier;
import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
import net.sf.portecle.StringUtil; | * <pre>
* KeyUsage ::= BIT STRING {
* digitalSignature (0),
* nonRepudiation (1),
* keyEncipherment (2),
* dataEncipherment (3),
* keyAgreement (4),
* keyCertSign (5),
* cRLSign (6),
* encipherOnly (7),
* decipherOnly (8) }
* </pre>
*
* @param bValue The octet string value
* @return Extension value as a string
* @throws IOException If an I/O problem occurs
*/
private String getKeyUsageStringValue(byte[] bValue)
throws IOException
{
int val = ((DERBitString) ASN1Primitive.fromByteArray(bValue)).intValue();
StringBuilder strBuff = new StringBuilder();
for (int type : KEY_USAGES)
{
if ((val & type) == type)
{
if (strBuff.length() != 0)
{
strBuff.append("<br><br>");
} | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/crypto/X509Ext.java
import static net.sf.portecle.FPortecle.RB;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.MissingResourceException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bouncycastle.asn1.ASN1Boolean;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1GeneralizedTime;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1String;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DERBitString;
import org.bouncycastle.asn1.DERGeneralString;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.DERUTCTime;
import org.bouncycastle.asn1.microsoft.MicrosoftObjectIdentifiers;
import org.bouncycastle.asn1.misc.MiscObjectIdentifiers;
import org.bouncycastle.asn1.misc.NetscapeCertType;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.asn1.smime.SMIMECapabilities;
import org.bouncycastle.asn1.smime.SMIMECapability;
import org.bouncycastle.asn1.x509.AccessDescription;
import org.bouncycastle.asn1.x509.AuthorityInformationAccess;
import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.CRLDistPoint;
import org.bouncycastle.asn1.x509.CRLReason;
import org.bouncycastle.asn1.x509.DistributionPoint;
import org.bouncycastle.asn1.x509.DistributionPointName;
import org.bouncycastle.asn1.x509.ExtendedKeyUsage;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.GeneralNames;
import org.bouncycastle.asn1.x509.KeyPurposeId;
import org.bouncycastle.asn1.x509.KeyUsage;
import org.bouncycastle.asn1.x509.PolicyInformation;
import org.bouncycastle.asn1.x509.PolicyQualifierId;
import org.bouncycastle.asn1.x509.PrivateKeyUsagePeriod;
import org.bouncycastle.asn1.x509.ReasonFlags;
import org.bouncycastle.asn1.x509.SubjectKeyIdentifier;
import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
import net.sf.portecle.StringUtil;
* <pre>
* KeyUsage ::= BIT STRING {
* digitalSignature (0),
* nonRepudiation (1),
* keyEncipherment (2),
* dataEncipherment (3),
* keyAgreement (4),
* keyCertSign (5),
* cRLSign (6),
* encipherOnly (7),
* decipherOnly (8) }
* </pre>
*
* @param bValue The octet string value
* @return Extension value as a string
* @throws IOException If an I/O problem occurs
*/
private String getKeyUsageStringValue(byte[] bValue)
throws IOException
{
int val = ((DERBitString) ASN1Primitive.fromByteArray(bValue)).intValue();
StringBuilder strBuff = new StringBuilder();
for (int type : KEY_USAGES)
{
if ((val & type) == type)
{
if (strBuff.length() != 0)
{
strBuff.append("<br><br>");
} | strBuff.append(RB.getString("KeyUsage." + type)); |
scop/portecle | src/main/net/sf/portecle/gui/password/DGetNewPassword.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/PortecleJDialog.java
// public class PortecleJDialog
// extends JDialog
// {
// /** Key from input map to action map for the cancel button */
// private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
//
// public PortecleJDialog(Window parent, boolean modal)
// {
// super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// public PortecleJDialog(Window parent, String title, boolean modal)
// {
// super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// /**
// * Initialize the dialog.
// */
// protected void initDialog()
// {
// addWindowListener(new WindowAdapter()
// {
// @Override
// public void windowClosing(WindowEvent evt)
// {
// closeDialog();
// }
// });
//
// setResizable(false);
//
// pack();
// }
//
// /**
// * Get OK button.
// *
// * @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
// * @return
// */
// protected JButton getOkButton(boolean escPresses)
// {
// Action okAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// okPressed();
// }
// };
//
// JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text"));
//
// jbOK.addActionListener(okAction);
//
// if (escPresses)
// {
// jbOK.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbOK.getActionMap().put(ESC_KEY, okAction);
// }
//
// return jbOK;
// }
//
// /**
// * Get cancel button.
// *
// * @return
// */
// protected JButton getCancelButton()
// {
// Action cancelAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// cancelPressed();
// }
// };
//
// JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text"));
//
// jbCancel.addActionListener(cancelAction);
//
// jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbCancel.getActionMap().put(ESC_KEY, cancelAction);
//
// return jbCancel;
// }
//
// /**
// * OK button pressed or otherwise activated.
// */
// protected void okPressed()
// {
// closeDialog();
// }
//
// /**
// * Cancel button pressed or otherwise activated.
// */
// protected void cancelPressed()
// {
// closeDialog();
// }
//
// /**
// * Closes the dialog.
// */
// protected void closeDialog()
// {
// setVisible(false);
// dispose();
// }
// }
| import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.PortecleJDialog;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Window;
import javax.swing.JButton; | /*
* DGetNewPassword.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2006-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.password;
/**
* Modal dialog used for entering and confirming a password.
*/
public class DGetNewPassword
extends PortecleJDialog
{
/** First password entry password field */
private JPasswordField m_jpfFirst;
/** Password confirmation entry password field */
private JPasswordField m_jpfConfirm;
/** Stores new password entered */
private char[] m_cPassword;
/**
* Creates new DGetNewPassword dialog.
*
* @param parent Parent window
* @param sTitle The dialog's title
*/
public DGetNewPassword(Window parent, String sTitle)
{ | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/PortecleJDialog.java
// public class PortecleJDialog
// extends JDialog
// {
// /** Key from input map to action map for the cancel button */
// private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
//
// public PortecleJDialog(Window parent, boolean modal)
// {
// super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// public PortecleJDialog(Window parent, String title, boolean modal)
// {
// super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// /**
// * Initialize the dialog.
// */
// protected void initDialog()
// {
// addWindowListener(new WindowAdapter()
// {
// @Override
// public void windowClosing(WindowEvent evt)
// {
// closeDialog();
// }
// });
//
// setResizable(false);
//
// pack();
// }
//
// /**
// * Get OK button.
// *
// * @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
// * @return
// */
// protected JButton getOkButton(boolean escPresses)
// {
// Action okAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// okPressed();
// }
// };
//
// JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text"));
//
// jbOK.addActionListener(okAction);
//
// if (escPresses)
// {
// jbOK.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbOK.getActionMap().put(ESC_KEY, okAction);
// }
//
// return jbOK;
// }
//
// /**
// * Get cancel button.
// *
// * @return
// */
// protected JButton getCancelButton()
// {
// Action cancelAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// cancelPressed();
// }
// };
//
// JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text"));
//
// jbCancel.addActionListener(cancelAction);
//
// jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbCancel.getActionMap().put(ESC_KEY, cancelAction);
//
// return jbCancel;
// }
//
// /**
// * OK button pressed or otherwise activated.
// */
// protected void okPressed()
// {
// closeDialog();
// }
//
// /**
// * Cancel button pressed or otherwise activated.
// */
// protected void cancelPressed()
// {
// closeDialog();
// }
//
// /**
// * Closes the dialog.
// */
// protected void closeDialog()
// {
// setVisible(false);
// dispose();
// }
// }
// Path: src/main/net/sf/portecle/gui/password/DGetNewPassword.java
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.PortecleJDialog;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Window;
import javax.swing.JButton;
/*
* DGetNewPassword.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2006-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.password;
/**
* Modal dialog used for entering and confirming a password.
*/
public class DGetNewPassword
extends PortecleJDialog
{
/** First password entry password field */
private JPasswordField m_jpfFirst;
/** Password confirmation entry password field */
private JPasswordField m_jpfConfirm;
/** Stores new password entered */
private char[] m_cPassword;
/**
* Creates new DGetNewPassword dialog.
*
* @param parent Parent window
* @param sTitle The dialog's title
*/
public DGetNewPassword(Window parent, String sTitle)
{ | super(parent, (sTitle == null) ? RB.getString("DGetNewPassword.Title") : sTitle, true); |
scop/portecle | src/main/net/sf/portecle/DOptions.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Map;
import java.util.TreeMap;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder; | /*
* DOptions.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2004-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog to allow the users to configure Portecle options, CA certificates keystore, and look & feel.
*/
class DOptions
extends PortecleJDialog
{
/** Use CA certificates check box */
private JCheckBox m_jcbUseCaCerts;
/** CA certificates file text field */
private JTextField m_jtfCaCertsFile;
/** Look & feel combo box */
private JComboBox<String> m_jcbLookFeel;
/** Look & feel decorated check box */
private JCheckBox m_jcbLookFeelDecorated;
/** Use CA certificates keystore file? */
private boolean m_bUseCaCerts;
/** Chosen CA certificates keystore file */
private File m_fCaCertsFile;
/** Available Look and Feel information - reflects what is in choice box */
private final TreeMap<String, UIManager.LookAndFeelInfo> lookFeelInfos = new TreeMap<>();
/** Chosen look & feel information */
private String lookFeelClassName;
/** Use look & feel for window decoration? */
private boolean m_bLookFeelDecorated;
/**
* Creates new DOptions dialog.
*
* @param parent The parent window
* @param bUseCaCerts Use CA certificates keystore file?
* @param fCaCertsFile CA certificates keystore file
*/
public DOptions(Window parent, boolean bUseCaCerts, File fCaCertsFile)
{
super(parent, true);
m_bUseCaCerts = bUseCaCerts;
m_fCaCertsFile = fCaCertsFile;
initComponents();
}
/**
* Initialise the dialog's GUI components.
*/
private void initComponents()
{
// Setup tabbed panels of options
// CA certs options tab panel | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/DOptions.java
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Map;
import java.util.TreeMap;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
/*
* DOptions.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2004-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog to allow the users to configure Portecle options, CA certificates keystore, and look & feel.
*/
class DOptions
extends PortecleJDialog
{
/** Use CA certificates check box */
private JCheckBox m_jcbUseCaCerts;
/** CA certificates file text field */
private JTextField m_jtfCaCertsFile;
/** Look & feel combo box */
private JComboBox<String> m_jcbLookFeel;
/** Look & feel decorated check box */
private JCheckBox m_jcbLookFeelDecorated;
/** Use CA certificates keystore file? */
private boolean m_bUseCaCerts;
/** Chosen CA certificates keystore file */
private File m_fCaCertsFile;
/** Available Look and Feel information - reflects what is in choice box */
private final TreeMap<String, UIManager.LookAndFeelInfo> lookFeelInfos = new TreeMap<>();
/** Chosen look & feel information */
private String lookFeelClassName;
/** Use look & feel for window decoration? */
private boolean m_bLookFeelDecorated;
/**
* Creates new DOptions dialog.
*
* @param parent The parent window
* @param bUseCaCerts Use CA certificates keystore file?
* @param fCaCertsFile CA certificates keystore file
*/
public DOptions(Window parent, boolean bUseCaCerts, File fCaCertsFile)
{
super(parent, true);
m_bUseCaCerts = bUseCaCerts;
m_fCaCertsFile = fCaCertsFile;
initComponents();
}
/**
* Initialise the dialog's GUI components.
*/
private void initComponents()
{
// Setup tabbed panels of options
// CA certs options tab panel | m_jcbUseCaCerts = new JCheckBox(RB.getString("DOptions.m_jcbUseCaCerts.text"), m_bUseCaCerts); |
scop/portecle | src/main/net/sf/portecle/KeyStoreTableHeadRend.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder; | /*
* KeyStoreTableTypeHeadRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the headers of the keystore table of FPortecle.
*/
class KeyStoreTableHeadRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered header cell for the supplied value and column.
*
* @param jtKeyStore The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately *
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtKeyStore, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
// Get header renderer
JLabel header = (JLabel) jtKeyStore.getColumnModel().getColumn(iCol).getHeaderRenderer();
// The entry type header contains an icon
if (iCol == 0)
{
header.setText("");
ImageIcon icon = | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/KeyStoreTableHeadRend.java
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
/*
* KeyStoreTableTypeHeadRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the headers of the keystore table of FPortecle.
*/
class KeyStoreTableHeadRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered header cell for the supplied value and column.
*
* @param jtKeyStore The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately *
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtKeyStore, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
// Get header renderer
JLabel header = (JLabel) jtKeyStore.getColumnModel().getColumn(iCol).getHeaderRenderer();
// The entry type header contains an icon
if (iCol == 0)
{
header.setText("");
ImageIcon icon = | new ImageIcon(getClass().getResource(RB.getString("KeyStoreTableHeadRend.TypeColumn.image"))); |
scop/portecle | src/main/net/sf/portecle/gui/error/ThrowableTreeCellRend.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer; | /*
* ThrowableTreeCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.error;
/**
* Custom cell renderer for the cells of the DThrowableDetail tree.
*/
class ThrowableTreeCellRend
extends DefaultTreeCellRenderer
{
/**
* Returns the rendered cell for the supplied value.
*
* @param jtrThrowable The JTree
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param bIsExpanded True if cell is expanded
* @param bLeaf True if cell is a leaf
* @param iRow The row of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTreeCellRendererComponent(JTree jtrThrowable, Object value, boolean bIsSelected,
boolean bIsExpanded, boolean bLeaf, int iRow, boolean bHasFocus)
{
JLabel cell = (JLabel) super.getTreeCellRendererComponent(jtrThrowable, value, bIsSelected, bIsExpanded, bLeaf,
iRow, bHasFocus);
cell.setText(value.toString());
// Sanity check of value
if (value instanceof DefaultMutableTreeNode)
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Object userValue = node.getUserObject();
ImageIcon icon;
// Each node type has a different icon and tool tip text
if (userValue instanceof Throwable)
{
// Throwable | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/gui/error/ThrowableTreeCellRend.java
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
/*
* ThrowableTreeCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.error;
/**
* Custom cell renderer for the cells of the DThrowableDetail tree.
*/
class ThrowableTreeCellRend
extends DefaultTreeCellRenderer
{
/**
* Returns the rendered cell for the supplied value.
*
* @param jtrThrowable The JTree
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param bIsExpanded True if cell is expanded
* @param bLeaf True if cell is a leaf
* @param iRow The row of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTreeCellRendererComponent(JTree jtrThrowable, Object value, boolean bIsSelected,
boolean bIsExpanded, boolean bLeaf, int iRow, boolean bHasFocus)
{
JLabel cell = (JLabel) super.getTreeCellRendererComponent(jtrThrowable, value, bIsSelected, bIsExpanded, bLeaf,
iRow, bHasFocus);
cell.setText(value.toString());
// Sanity check of value
if (value instanceof DefaultMutableTreeNode)
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
Object userValue = node.getUserObject();
ImageIcon icon;
// Each node type has a different icon and tool tip text
if (userValue instanceof Throwable)
{
// Throwable | icon = new ImageIcon(getClass().getResource(RB.getString("ThrowableTreeCellRend.Throwable.image"))); |
scop/portecle | src/main/net/sf/portecle/gui/help/FHelp.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.URL;
import java.text.MessageFormat;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener; | /*
* FHelp.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option)any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.help;
/**
* Simple help system that displays two panes: a table of contents and the current help topic. Rudimentary navigation is
* provided using the home, forward and back buttons of the tool bar.
*/
public class FHelp
extends JFrame
implements HistoryEventListener
{
/** Help frame's title */
private final String m_sTitle;
/** History home page */
private URL m_home;
/** Back toolbar button */
private final JButton m_jbBack;
/** Forward toolbar button */
private final JButton m_jbForward;
/** Help navigation history */
private final History m_history;
/**
* Constructs a new help window with the specified title, icon, home page, and contents page.
*
* @param sTitle A title for the window
* @param home URL of the help home page
* @param toc URL of the help contents page
*/
public FHelp(String sTitle, URL home, URL toc)
{
super(sTitle);
m_sTitle = sTitle;
// Help topic pane
final JEditorPane jepTopic = new JEditorPane();
jepTopic.setEditable(false);
jepTopic.setPreferredSize(new Dimension(450, 400));
jepTopic.addHyperlinkListener(new HyperlinkListener()
{
@Override
public void hyperlinkUpdate(HyperlinkEvent evt)
{
try
{
if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
jepTopic.setPage(evt.getURL());
m_history.visit(evt.getURL());
}
}
catch (IOException ex)
{
JOptionPane.showMessageDialog(FHelp.this, | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/gui/help/FHelp.java
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.URL;
import java.text.MessageFormat;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
/*
* FHelp.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option)any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.help;
/**
* Simple help system that displays two panes: a table of contents and the current help topic. Rudimentary navigation is
* provided using the home, forward and back buttons of the tool bar.
*/
public class FHelp
extends JFrame
implements HistoryEventListener
{
/** Help frame's title */
private final String m_sTitle;
/** History home page */
private URL m_home;
/** Back toolbar button */
private final JButton m_jbBack;
/** Forward toolbar button */
private final JButton m_jbForward;
/** Help navigation history */
private final History m_history;
/**
* Constructs a new help window with the specified title, icon, home page, and contents page.
*
* @param sTitle A title for the window
* @param home URL of the help home page
* @param toc URL of the help contents page
*/
public FHelp(String sTitle, URL home, URL toc)
{
super(sTitle);
m_sTitle = sTitle;
// Help topic pane
final JEditorPane jepTopic = new JEditorPane();
jepTopic.setEditable(false);
jepTopic.setPreferredSize(new Dimension(450, 400));
jepTopic.addHyperlinkListener(new HyperlinkListener()
{
@Override
public void hyperlinkUpdate(HyperlinkEvent evt)
{
try
{
if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
jepTopic.setPage(evt.getURL());
m_history.visit(evt.getURL());
}
}
catch (IOException ex)
{
JOptionPane.showMessageDialog(FHelp.this, | MessageFormat.format(RB.getString("FHelp.NoLocateUrl.message"), evt.getURL()), m_sTitle, |
scop/portecle | src/main/net/sf/portecle/RevokedCertsTableHeadRend.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import javax.swing.table.DefaultTableCellRenderer;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder; | /*
* RevokedCertsTableHeadRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the headers of the RevokedCerts table of DViewCRL.
*/
class RevokedCertsTableHeadRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered header cell for the supplied value and column.
*
* @param jtRevokedCerts The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtRevokedCerts, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
// Get header renderer
JLabel header = (JLabel) jtRevokedCerts.getColumnModel().getColumn(iCol).getHeaderRenderer();
// The headers contain text
header.setText(value.toString());
header.setHorizontalAlignment(LEFT);
// Set tool tips
if (iCol == 0)
{ | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/RevokedCertsTableHeadRend.java
import javax.swing.table.DefaultTableCellRenderer;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
/*
* RevokedCertsTableHeadRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the headers of the RevokedCerts table of DViewCRL.
*/
class RevokedCertsTableHeadRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered header cell for the supplied value and column.
*
* @param jtRevokedCerts The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtRevokedCerts, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
// Get header renderer
JLabel header = (JLabel) jtRevokedCerts.getColumnModel().getColumn(iCol).getHeaderRenderer();
// The headers contain text
header.setText(value.toString());
header.setHorizontalAlignment(LEFT);
// Set tool tips
if (iCol == 0)
{ | header.setToolTipText(RB.getString("RevokedCertsTableHeadRend.SerialNumberColumn.tooltip")); |
scop/portecle | src/main/net/sf/portecle/KeyStoreTableCellRend.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import java.text.DateFormat;
import java.util.Date;
import javax.swing.ImageIcon;
import javax.swing.JLabel; | /*
* KeyStoreTableTypeCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2008-2017 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the cells of the keystore table of FPortecle.
*/
class KeyStoreTableCellRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered cell for the supplied value and column.
*
* @param jtKeyStore The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtKeyStore, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
JLabel cell =
(JLabel) super.getTableCellRendererComponent(jtKeyStore, value, bIsSelected, bHasFocus, iRow, iCol);
// Entry column - display an icon representing the type and tool tip text
if (iCol == 0)
{
ImageIcon icon;
if (KeyStoreTableModel.KEY_PAIR_ENTRY.equals(value))
{ | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/KeyStoreTableCellRend.java
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import java.text.DateFormat;
import java.util.Date;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
/*
* KeyStoreTableTypeCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2008-2017 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the cells of the keystore table of FPortecle.
*/
class KeyStoreTableCellRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered cell for the supplied value and column.
*
* @param jtKeyStore The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtKeyStore, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
JLabel cell =
(JLabel) super.getTableCellRendererComponent(jtKeyStore, value, bIsSelected, bHasFocus, iRow, iCol);
// Entry column - display an icon representing the type and tool tip text
if (iCol == 0)
{
ImageIcon icon;
if (KeyStoreTableModel.KEY_PAIR_ENTRY.equals(value))
{ | icon = new ImageIcon(getClass().getResource(RB.getString("KeyStoreTableCellRend.KeyPairEntry.image"))); |
scop/portecle | src/main/net/sf/portecle/gui/jar/DJarInfo.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/PortecleJDialog.java
// public class PortecleJDialog
// extends JDialog
// {
// /** Key from input map to action map for the cancel button */
// private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
//
// public PortecleJDialog(Window parent, boolean modal)
// {
// super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// public PortecleJDialog(Window parent, String title, boolean modal)
// {
// super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// /**
// * Initialize the dialog.
// */
// protected void initDialog()
// {
// addWindowListener(new WindowAdapter()
// {
// @Override
// public void windowClosing(WindowEvent evt)
// {
// closeDialog();
// }
// });
//
// setResizable(false);
//
// pack();
// }
//
// /**
// * Get OK button.
// *
// * @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
// * @return
// */
// protected JButton getOkButton(boolean escPresses)
// {
// Action okAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// okPressed();
// }
// };
//
// JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text"));
//
// jbOK.addActionListener(okAction);
//
// if (escPresses)
// {
// jbOK.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbOK.getActionMap().put(ESC_KEY, okAction);
// }
//
// return jbOK;
// }
//
// /**
// * Get cancel button.
// *
// * @return
// */
// protected JButton getCancelButton()
// {
// Action cancelAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// cancelPressed();
// }
// };
//
// JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text"));
//
// jbCancel.addActionListener(cancelAction);
//
// jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbCancel.getActionMap().put(ESC_KEY, cancelAction);
//
// return jbCancel;
// }
//
// /**
// * OK button pressed or otherwise activated.
// */
// protected void okPressed()
// {
// closeDialog();
// }
//
// /**
// * Cancel button pressed or otherwise activated.
// */
// protected void cancelPressed()
// {
// closeDialog();
// }
//
// /**
// * Closes the dialog.
// */
// protected void closeDialog()
// {
// setVisible(false);
// dispose();
// }
// }
| import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Window;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableColumn;
import net.sf.portecle.PortecleJDialog; | /*
* DJarInfo.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.jar;
/**
* Modal dialog that displays information about the JAR files on the class path.
*/
public class DJarInfo
extends PortecleJDialog
{
/**
* Creates new DJarInfo dialog.
*
* @param parent Parent window
* @throws IOException Problem occurred getting JAR information
*/
public DJarInfo(Window parent)
throws IOException
{ | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/PortecleJDialog.java
// public class PortecleJDialog
// extends JDialog
// {
// /** Key from input map to action map for the cancel button */
// private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
//
// public PortecleJDialog(Window parent, boolean modal)
// {
// super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// public PortecleJDialog(Window parent, String title, boolean modal)
// {
// super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// /**
// * Initialize the dialog.
// */
// protected void initDialog()
// {
// addWindowListener(new WindowAdapter()
// {
// @Override
// public void windowClosing(WindowEvent evt)
// {
// closeDialog();
// }
// });
//
// setResizable(false);
//
// pack();
// }
//
// /**
// * Get OK button.
// *
// * @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
// * @return
// */
// protected JButton getOkButton(boolean escPresses)
// {
// Action okAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// okPressed();
// }
// };
//
// JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text"));
//
// jbOK.addActionListener(okAction);
//
// if (escPresses)
// {
// jbOK.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbOK.getActionMap().put(ESC_KEY, okAction);
// }
//
// return jbOK;
// }
//
// /**
// * Get cancel button.
// *
// * @return
// */
// protected JButton getCancelButton()
// {
// Action cancelAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// cancelPressed();
// }
// };
//
// JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text"));
//
// jbCancel.addActionListener(cancelAction);
//
// jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbCancel.getActionMap().put(ESC_KEY, cancelAction);
//
// return jbCancel;
// }
//
// /**
// * OK button pressed or otherwise activated.
// */
// protected void okPressed()
// {
// closeDialog();
// }
//
// /**
// * Cancel button pressed or otherwise activated.
// */
// protected void cancelPressed()
// {
// closeDialog();
// }
//
// /**
// * Closes the dialog.
// */
// protected void closeDialog()
// {
// setVisible(false);
// dispose();
// }
// }
// Path: src/main/net/sf/portecle/gui/jar/DJarInfo.java
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Window;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableColumn;
import net.sf.portecle.PortecleJDialog;
/*
* DJarInfo.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.jar;
/**
* Modal dialog that displays information about the JAR files on the class path.
*/
public class DJarInfo
extends PortecleJDialog
{
/**
* Creates new DJarInfo dialog.
*
* @param parent Parent window
* @throws IOException Problem occurred getting JAR information
*/
public DJarInfo(Window parent)
throws IOException
{ | super(parent, RB.getString("DJarInfo.Title"), true); |
scop/portecle | src/main/net/sf/portecle/gui/SwingHelper.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final Logger LOG = Logger.getLogger(FPortecle.class.getName(), RB_BASENAME);
| import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.text.JTextComponent;
import static net.sf.portecle.FPortecle.LOG;
import java.awt.Component;
import java.awt.Window;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import javax.swing.JComboBox;
import javax.swing.JComponent; | /*
* SwingHelper.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2007-2014 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui;
/**
* Swing helper.
*/
public final class SwingHelper
{
/** Not needed. */
private SwingHelper()
{
// Ignored
}
/**
* Makes the given Window visible and waits for it to return.
*
* @param window The window
*/
public static void showAndWait(final Window window)
{
if (SwingUtilities.isEventDispatchThread())
{
window.setVisible(true);
}
else
{
try
{
SwingUtilities.invokeAndWait(new Runnable()
{
@Override
public void run()
{
window.setVisible(true);
}
});
}
catch (InterruptedException | InvocationTargetException e)
{ | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final Logger LOG = Logger.getLogger(FPortecle.class.getName(), RB_BASENAME);
// Path: src/main/net/sf/portecle/gui/SwingHelper.java
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.text.JTextComponent;
import static net.sf.portecle.FPortecle.LOG;
import java.awt.Component;
import java.awt.Window;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import javax.swing.JComboBox;
import javax.swing.JComponent;
/*
* SwingHelper.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2007-2014 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui;
/**
* Swing helper.
*/
public final class SwingHelper
{
/** Not needed. */
private SwingHelper()
{
// Ignored
}
/**
* Makes the given Window visible and waits for it to return.
*
* @param window The window
*/
public static void showAndWait(final Window window)
{
if (SwingUtilities.isEventDispatchThread())
{
window.setVisible(true);
}
else
{
try
{
SwingUtilities.invokeAndWait(new Runnable()
{
@Override
public void run()
{
window.setVisible(true);
}
});
}
catch (InterruptedException | InvocationTargetException e)
{ | LOG.log(Level.WARNING, "Error setting window visible", e); // TODO? |
scop/portecle | src/main/net/sf/portecle/ReportTreeCellRend.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import javax.swing.tree.TreeNode;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer; | /*
* ReportTreeCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the cells of the DKeyStoreReport tree.
*/
class ReportTreeCellRend
extends DefaultTreeCellRenderer
{
/**
* Returns the rendered cell for the supplied value.
*
* @param jtrReport The JTree
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param bIsExpanded True if cell is expanded
* @param bLeaf True if cell is a leaf
* @param iRow The row of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTreeCellRendererComponent(JTree jtrReport, Object value, boolean bIsSelected,
boolean bIsExpanded, boolean bLeaf, int iRow, boolean bHasFocus)
{
JLabel cell = (JLabel) super.getTreeCellRendererComponent(jtrReport, value, bIsSelected, bIsExpanded, bLeaf,
iRow, bHasFocus);
cell.setText(value.toString());
ImageIcon icon = null;
// Sanity check of value
if (value instanceof DefaultMutableTreeNode)
{
// Set the cell's icon and tool tip text - depends on nodes depth and index
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
int iLevel = node.getLevel();
TreeNode parent = node.getParent();
int iIndex = 0;
if (parent != null)
{
iIndex = parent.getIndex(node);
}
if (iLevel == 0)
{ | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/ReportTreeCellRend.java
import javax.swing.tree.TreeNode;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
/*
* ReportTreeCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the cells of the DKeyStoreReport tree.
*/
class ReportTreeCellRend
extends DefaultTreeCellRenderer
{
/**
* Returns the rendered cell for the supplied value.
*
* @param jtrReport The JTree
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param bIsExpanded True if cell is expanded
* @param bLeaf True if cell is a leaf
* @param iRow The row of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTreeCellRendererComponent(JTree jtrReport, Object value, boolean bIsSelected,
boolean bIsExpanded, boolean bLeaf, int iRow, boolean bHasFocus)
{
JLabel cell = (JLabel) super.getTreeCellRendererComponent(jtrReport, value, bIsSelected, bIsExpanded, bLeaf,
iRow, bHasFocus);
cell.setText(value.toString());
ImageIcon icon = null;
// Sanity check of value
if (value instanceof DefaultMutableTreeNode)
{
// Set the cell's icon and tool tip text - depends on nodes depth and index
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
int iLevel = node.getLevel();
TreeNode parent = node.getParent();
int iIndex = 0;
if (parent != null)
{
iIndex = parent.getIndex(node);
}
if (iLevel == 0)
{ | icon = new ImageIcon(getClass().getResource(RB.getString("ReportTreeCellRend.Root.image"))); |
scop/portecle | src/main/net/sf/portecle/gui/crypto/ProviderTreeCellRend.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import javax.swing.tree.TreeNode;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer; | /*
* ProviderTreeCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.crypto;
/**
* Custom cell renderer for the cells of the DProviderInfo tree.
*/
class ProviderTreeCellRend
extends DefaultTreeCellRenderer
{
/**
* Returns the rendered cell for the supplied value.
*
* @param jtrProvider The JTree
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param bIsExpanded True if cell is expanded
* @param bLeaf True if cell is a leaf
* @param iRow The row of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTreeCellRendererComponent(JTree jtrProvider, Object value, boolean bIsSelected,
boolean bIsExpanded, boolean bLeaf, int iRow, boolean bHasFocus)
{
JLabel cell = (JLabel) super.getTreeCellRendererComponent(jtrProvider, value, bIsSelected, bIsExpanded, bLeaf,
iRow, bHasFocus);
cell.setText(value.toString());
// Sanity check of value
if (value instanceof DefaultMutableTreeNode)
{
// Get the correct icon for the node and set any tool tip text
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
ImageIcon icon;
if (node.getLevel() == 0)
{
// Root node | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/gui/crypto/ProviderTreeCellRend.java
import javax.swing.tree.TreeNode;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
/*
* ProviderTreeCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.crypto;
/**
* Custom cell renderer for the cells of the DProviderInfo tree.
*/
class ProviderTreeCellRend
extends DefaultTreeCellRenderer
{
/**
* Returns the rendered cell for the supplied value.
*
* @param jtrProvider The JTree
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param bIsExpanded True if cell is expanded
* @param bLeaf True if cell is a leaf
* @param iRow The row of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTreeCellRendererComponent(JTree jtrProvider, Object value, boolean bIsSelected,
boolean bIsExpanded, boolean bLeaf, int iRow, boolean bHasFocus)
{
JLabel cell = (JLabel) super.getTreeCellRendererComponent(jtrProvider, value, bIsSelected, bIsExpanded, bLeaf,
iRow, bHasFocus);
cell.setText(value.toString());
// Sanity check of value
if (value instanceof DefaultMutableTreeNode)
{
// Get the correct icon for the node and set any tool tip text
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
ImageIcon icon;
if (node.getLevel() == 0)
{
// Root node | icon = new ImageIcon(getClass().getResource(RB.getString("ProviderTreeCellRend.Root.image"))); |
scop/portecle | src/main/net/sf/portecle/gui/password/DChangePassword.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/PortecleJDialog.java
// public class PortecleJDialog
// extends JDialog
// {
// /** Key from input map to action map for the cancel button */
// private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
//
// public PortecleJDialog(Window parent, boolean modal)
// {
// super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// public PortecleJDialog(Window parent, String title, boolean modal)
// {
// super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// /**
// * Initialize the dialog.
// */
// protected void initDialog()
// {
// addWindowListener(new WindowAdapter()
// {
// @Override
// public void windowClosing(WindowEvent evt)
// {
// closeDialog();
// }
// });
//
// setResizable(false);
//
// pack();
// }
//
// /**
// * Get OK button.
// *
// * @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
// * @return
// */
// protected JButton getOkButton(boolean escPresses)
// {
// Action okAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// okPressed();
// }
// };
//
// JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text"));
//
// jbOK.addActionListener(okAction);
//
// if (escPresses)
// {
// jbOK.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbOK.getActionMap().put(ESC_KEY, okAction);
// }
//
// return jbOK;
// }
//
// /**
// * Get cancel button.
// *
// * @return
// */
// protected JButton getCancelButton()
// {
// Action cancelAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// cancelPressed();
// }
// };
//
// JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text"));
//
// jbCancel.addActionListener(cancelAction);
//
// jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbCancel.getActionMap().put(ESC_KEY, cancelAction);
//
// return jbCancel;
// }
//
// /**
// * OK button pressed or otherwise activated.
// */
// protected void okPressed()
// {
// closeDialog();
// }
//
// /**
// * Cancel button pressed or otherwise activated.
// */
// protected void cancelPressed()
// {
// closeDialog();
// }
//
// /**
// * Closes the dialog.
// */
// protected void closeDialog()
// {
// setVisible(false);
// dispose();
// }
// }
| import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.PortecleJDialog;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Window;
import javax.swing.JButton; | /*
* DChangePassword.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2006-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.password;
/**
* Modal dialog used for entering and confirming a password and checking it against an old password which may or may not
* have been supplied to the dialog.
*/
public class DChangePassword
extends PortecleJDialog
{
/** Old password entry password field */
private JPasswordField m_jpfOld;
/** First password entry password field */
private JPasswordField m_jpfFirst;
/** Password confirmation entry password field */
private JPasswordField m_jpfConfirm;
/** Stores new password entered */
private char[] m_cNewPassword;
/** Stores old password entered/supplied */
private char[] m_cOldPassword;
/**
* Creates new DChangePassword dialog.
*
* @param parent Parent window
* @param sTitle Is dialog modal?
* @param cOldPassword The password to be changed
*/
public DChangePassword(Window parent, String sTitle, char[] cOldPassword)
{ | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/PortecleJDialog.java
// public class PortecleJDialog
// extends JDialog
// {
// /** Key from input map to action map for the cancel button */
// private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
//
// public PortecleJDialog(Window parent, boolean modal)
// {
// super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// public PortecleJDialog(Window parent, String title, boolean modal)
// {
// super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// /**
// * Initialize the dialog.
// */
// protected void initDialog()
// {
// addWindowListener(new WindowAdapter()
// {
// @Override
// public void windowClosing(WindowEvent evt)
// {
// closeDialog();
// }
// });
//
// setResizable(false);
//
// pack();
// }
//
// /**
// * Get OK button.
// *
// * @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
// * @return
// */
// protected JButton getOkButton(boolean escPresses)
// {
// Action okAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// okPressed();
// }
// };
//
// JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text"));
//
// jbOK.addActionListener(okAction);
//
// if (escPresses)
// {
// jbOK.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbOK.getActionMap().put(ESC_KEY, okAction);
// }
//
// return jbOK;
// }
//
// /**
// * Get cancel button.
// *
// * @return
// */
// protected JButton getCancelButton()
// {
// Action cancelAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// cancelPressed();
// }
// };
//
// JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text"));
//
// jbCancel.addActionListener(cancelAction);
//
// jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbCancel.getActionMap().put(ESC_KEY, cancelAction);
//
// return jbCancel;
// }
//
// /**
// * OK button pressed or otherwise activated.
// */
// protected void okPressed()
// {
// closeDialog();
// }
//
// /**
// * Cancel button pressed or otherwise activated.
// */
// protected void cancelPressed()
// {
// closeDialog();
// }
//
// /**
// * Closes the dialog.
// */
// protected void closeDialog()
// {
// setVisible(false);
// dispose();
// }
// }
// Path: src/main/net/sf/portecle/gui/password/DChangePassword.java
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.PortecleJDialog;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Window;
import javax.swing.JButton;
/*
* DChangePassword.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2006-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.password;
/**
* Modal dialog used for entering and confirming a password and checking it against an old password which may or may not
* have been supplied to the dialog.
*/
public class DChangePassword
extends PortecleJDialog
{
/** Old password entry password field */
private JPasswordField m_jpfOld;
/** First password entry password field */
private JPasswordField m_jpfFirst;
/** Password confirmation entry password field */
private JPasswordField m_jpfConfirm;
/** Stores new password entered */
private char[] m_cNewPassword;
/** Stores old password entered/supplied */
private char[] m_cOldPassword;
/**
* Creates new DChangePassword dialog.
*
* @param parent Parent window
* @param sTitle Is dialog modal?
* @param cOldPassword The password to be changed
*/
public DChangePassword(Window parent, String sTitle, char[] cOldPassword)
{ | super(parent, (sTitle == null) ? RB.getString("DChangePassword.Title") : sTitle, true); |
scop/portecle | src/main/net/sf/portecle/PortecleJDialog.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.KeyStroke;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Dialog;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; | /*
* PortecleDialog.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2009 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Base class for Portecle's dialogs.
*/
public class PortecleJDialog
extends JDialog
{
/** Key from input map to action map for the cancel button */
private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
public PortecleJDialog(Window parent, boolean modal)
{
super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
}
public PortecleJDialog(Window parent, String title, boolean modal)
{
super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
}
/**
* Initialize the dialog.
*/
protected void initDialog()
{
addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent evt)
{
closeDialog();
}
});
setResizable(false);
pack();
}
/**
* Get OK button.
*
* @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
* @return
*/
protected JButton getOkButton(boolean escPresses)
{
Action okAction = new AbstractAction()
{
@Override
public void actionPerformed(ActionEvent evt)
{
okPressed();
}
};
| // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/PortecleJDialog.java
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.KeyStroke;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Dialog;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/*
* PortecleDialog.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2009 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Base class for Portecle's dialogs.
*/
public class PortecleJDialog
extends JDialog
{
/** Key from input map to action map for the cancel button */
private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
public PortecleJDialog(Window parent, boolean modal)
{
super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
}
public PortecleJDialog(Window parent, String title, boolean modal)
{
super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
}
/**
* Initialize the dialog.
*/
protected void initDialog()
{
addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent evt)
{
closeDialog();
}
});
setResizable(false);
pack();
}
/**
* Get OK button.
*
* @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
* @return
*/
protected JButton getOkButton(boolean escPresses)
{
Action okAction = new AbstractAction()
{
@Override
public void actionPerformed(ActionEvent evt)
{
okPressed();
}
};
| JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text")); |
scop/portecle | src/main/net/sf/portecle/gui/DesktopUtil.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import javax.swing.JOptionPane;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import java.awt.Desktop;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat; | /*
* DesktopUtil.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui;
/**
* Desktop utilities.
*/
public final class DesktopUtil
{
/** Desktop */
private static final Desktop DESKTOP = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
/** Not needed. */
private DesktopUtil()
{
// Nothing to do
}
/**
* Open URI in system default browser.
*
* @param parentComponent
* @param uri URI to open
* @see Desktop#browse(URI)
*/
public static void browse(Component parentComponent, URI uri)
{
if (DESKTOP != null)
{
try
{
DESKTOP.browse(uri);
return;
}
catch (Exception e)
{
// Ignored
}
}
// Could not launch - tell the user the address
JOptionPane.showMessageDialog(parentComponent, | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/gui/DesktopUtil.java
import javax.swing.JOptionPane;
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import java.awt.Desktop;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
/*
* DesktopUtil.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui;
/**
* Desktop utilities.
*/
public final class DesktopUtil
{
/** Desktop */
private static final Desktop DESKTOP = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
/** Not needed. */
private DesktopUtil()
{
// Nothing to do
}
/**
* Open URI in system default browser.
*
* @param parentComponent
* @param uri URI to open
* @see Desktop#browse(URI)
*/
public static void browse(Component parentComponent, URI uri)
{
if (DESKTOP != null)
{
try
{
DESKTOP.browse(uri);
return;
}
catch (Exception e)
{
// Ignored
}
}
// Could not launch - tell the user the address
JOptionPane.showMessageDialog(parentComponent, | MessageFormat.format(RB.getString("FPortecle.NoLaunchBrowser.message"), uri), |
scop/portecle | src/main/net/sf/portecle/crypto/KeyStoreUtil.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import static net.sf.portecle.FPortecle.RB;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.openssl.PEMDecryptorProvider;
import org.bouncycastle.openssl.PEMEncryptedKeyPair;
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.PasswordFinder;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder; | catch (KeyStoreException e)
{
AVAILABLE_TYPES.put(keyStoreType, Boolean.FALSE);
throw e;
}
}
AVAILABLE_TYPES.put(keyStoreType, Boolean.TRUE);
return keyStore;
}
/**
* Create a new, empty keystore.
*
* @param keyStoreType The keystore type to create
* @return The keystore
* @throws CryptoException Problem encountered creating the keystore
* @throws IOException An I/O error occurred
*/
public static KeyStore createKeyStore(KeyStoreType keyStoreType)
throws CryptoException, IOException
{
KeyStore keyStore;
try
{
keyStore = getKeyStoreImpl(keyStoreType);
keyStore.load(null, null);
}
catch (GeneralSecurityException ex)
{
throw new CryptoException( | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/crypto/KeyStoreUtil.java
import static net.sf.portecle.FPortecle.RB;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.openssl.PEMDecryptorProvider;
import org.bouncycastle.openssl.PEMEncryptedKeyPair;
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.PasswordFinder;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
catch (KeyStoreException e)
{
AVAILABLE_TYPES.put(keyStoreType, Boolean.FALSE);
throw e;
}
}
AVAILABLE_TYPES.put(keyStoreType, Boolean.TRUE);
return keyStore;
}
/**
* Create a new, empty keystore.
*
* @param keyStoreType The keystore type to create
* @return The keystore
* @throws CryptoException Problem encountered creating the keystore
* @throws IOException An I/O error occurred
*/
public static KeyStore createKeyStore(KeyStoreType keyStoreType)
throws CryptoException, IOException
{
KeyStore keyStore;
try
{
keyStore = getKeyStoreImpl(keyStoreType);
keyStore.load(null, null);
}
catch (GeneralSecurityException ex)
{
throw new CryptoException( | MessageFormat.format(RB.getString("NoCreateKeystore.exception.message"), keyStoreType), ex); |
scop/portecle | src/main/net/sf/portecle/ExtensionsTableCellRend.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
| import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer; | /*
* ExtensionsTableCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the cells of the Extensions table of DViewExtensions.
*/
class ExtensionsTableCellRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered cell for the supplied entry type and column.
*
* @param jtExtensions The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtExtensions, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
JLabel cell =
(JLabel) super.getTableCellRendererComponent(jtExtensions, value, bIsSelected, bHasFocus, iRow, iCol);
// Critical column - display an icon representing criticality and tool tip text
if (iCol == 0)
{
ImageIcon icon;
if (value != null && (Boolean) value)
{
icon = new ImageIcon( | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
// Path: src/main/net/sf/portecle/ExtensionsTableCellRend.java
import static net.sf.portecle.FPortecle.RB;
import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
/*
* ExtensionsTableCellRend.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Custom cell renderer for the cells of the Extensions table of DViewExtensions.
*/
class ExtensionsTableCellRend
extends DefaultTableCellRenderer
{
/**
* Returns the rendered cell for the supplied entry type and column.
*
* @param jtExtensions The JTable
* @param value The value to assign to the cell
* @param bIsSelected True if cell is selected
* @param iRow The row of the cell to render
* @param iCol The column of the cell to render
* @param bHasFocus If true, render cell appropriately
* @return The rendered cell
*/
@Override
public Component getTableCellRendererComponent(JTable jtExtensions, Object value, boolean bIsSelected,
boolean bHasFocus, int iRow, int iCol)
{
JLabel cell =
(JLabel) super.getTableCellRendererComponent(jtExtensions, value, bIsSelected, bHasFocus, iRow, iCol);
// Critical column - display an icon representing criticality and tool tip text
if (iCol == 0)
{
ImageIcon icon;
if (value != null && (Boolean) value)
{
icon = new ImageIcon( | getClass().getResource(RB.getString("ExtensionsTableCellRend.CriticalExtension.image"))); |
scop/portecle | src/main/net/sf/portecle/DChoosePkcs11Provider.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/crypto/ProviderUtil.java
// public final class ProviderUtil
// {
// /**
// * Private to prevent construction.
// */
// private ProviderUtil()
// {
// // Nothing to do
// }
//
// /**
// * Get the PKCS #11 <code>Provider</code>s available on the system.
// *
// * @return the (possibly empty) collection of available PKCS #11 <code>Provider</code>s, sorted by name
// */
// public static Collection<Provider> getPkcs11Providers()
// {
// TreeMap<String, Provider> p11s = new TreeMap<>();
// for (Provider prov : Security.getProviders())
// {
// String pName = prov.getName();
// // Is it a PKCS #11 provider?
// /*
// * TODO: is there a better way to find out? Could try instanceof sun.security.pkcs11.SunPKCS11 but that
// * would require the class to be available?
// */
// if (pName.startsWith("SunPKCS11-"))
// {
// p11s.put(pName, prov);
// }
// }
// return p11s.values();
// }
// }
| import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.crypto.ProviderUtil;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import java.security.Provider;
import java.security.Security;
import java.text.MessageFormat;
import java.util.Collection; | /*
* DChoosePkcs11Provider.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog used for choosing a PKCS #11 provider.
*
* @author Ville Skyttä
*/
/* package private */class DChoosePkcs11Provider
extends PortecleJDialog
{
/** Provider drop-down box */
private JComboBox<String> m_jcbProvider;
/** Stores the provider chosen by the user */
private String m_sProvider;
/**
* Creates new DChoosePkcs11Provider dialog.
*
* @param parent The parent window
* @param sTitle The dialog's title
* @param sOldProvider The provider to display initially
*/
public DChoosePkcs11Provider(Window parent, String sTitle, String sOldProvider)
{
super(parent, sTitle, true);
initComponents(sOldProvider);
}
/**
* Get the provider chosen by the user.
*
* @return The provider, or null if none was entered
*/
public String getProvider()
{
return m_sProvider;
}
/**
* Initialize the dialog's GUI components.
*
* @param sOldProvider The provider to display initially
*/
private void initComponents(String sOldProvider)
{
getContentPane().setLayout(new BorderLayout());
| // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/crypto/ProviderUtil.java
// public final class ProviderUtil
// {
// /**
// * Private to prevent construction.
// */
// private ProviderUtil()
// {
// // Nothing to do
// }
//
// /**
// * Get the PKCS #11 <code>Provider</code>s available on the system.
// *
// * @return the (possibly empty) collection of available PKCS #11 <code>Provider</code>s, sorted by name
// */
// public static Collection<Provider> getPkcs11Providers()
// {
// TreeMap<String, Provider> p11s = new TreeMap<>();
// for (Provider prov : Security.getProviders())
// {
// String pName = prov.getName();
// // Is it a PKCS #11 provider?
// /*
// * TODO: is there a better way to find out? Could try instanceof sun.security.pkcs11.SunPKCS11 but that
// * would require the class to be available?
// */
// if (pName.startsWith("SunPKCS11-"))
// {
// p11s.put(pName, prov);
// }
// }
// return p11s.values();
// }
// }
// Path: src/main/net/sf/portecle/DChoosePkcs11Provider.java
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.crypto.ProviderUtil;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import java.security.Provider;
import java.security.Security;
import java.text.MessageFormat;
import java.util.Collection;
/*
* DChoosePkcs11Provider.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog used for choosing a PKCS #11 provider.
*
* @author Ville Skyttä
*/
/* package private */class DChoosePkcs11Provider
extends PortecleJDialog
{
/** Provider drop-down box */
private JComboBox<String> m_jcbProvider;
/** Stores the provider chosen by the user */
private String m_sProvider;
/**
* Creates new DChoosePkcs11Provider dialog.
*
* @param parent The parent window
* @param sTitle The dialog's title
* @param sOldProvider The provider to display initially
*/
public DChoosePkcs11Provider(Window parent, String sTitle, String sOldProvider)
{
super(parent, sTitle, true);
initComponents(sOldProvider);
}
/**
* Get the provider chosen by the user.
*
* @return The provider, or null if none was entered
*/
public String getProvider()
{
return m_sProvider;
}
/**
* Initialize the dialog's GUI components.
*
* @param sOldProvider The provider to display initially
*/
private void initComponents(String sOldProvider)
{
getContentPane().setLayout(new BorderLayout());
| JLabel jlProvider = new JLabel(RB.getString("DChoosePkcs11Provider.jlProvider.text")); |
scop/portecle | src/main/net/sf/portecle/DChoosePkcs11Provider.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/crypto/ProviderUtil.java
// public final class ProviderUtil
// {
// /**
// * Private to prevent construction.
// */
// private ProviderUtil()
// {
// // Nothing to do
// }
//
// /**
// * Get the PKCS #11 <code>Provider</code>s available on the system.
// *
// * @return the (possibly empty) collection of available PKCS #11 <code>Provider</code>s, sorted by name
// */
// public static Collection<Provider> getPkcs11Providers()
// {
// TreeMap<String, Provider> p11s = new TreeMap<>();
// for (Provider prov : Security.getProviders())
// {
// String pName = prov.getName();
// // Is it a PKCS #11 provider?
// /*
// * TODO: is there a better way to find out? Could try instanceof sun.security.pkcs11.SunPKCS11 but that
// * would require the class to be available?
// */
// if (pName.startsWith("SunPKCS11-"))
// {
// p11s.put(pName, prov);
// }
// }
// return p11s.values();
// }
// }
| import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.crypto.ProviderUtil;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import java.security.Provider;
import java.security.Security;
import java.text.MessageFormat;
import java.util.Collection; | /*
* DChoosePkcs11Provider.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog used for choosing a PKCS #11 provider.
*
* @author Ville Skyttä
*/
/* package private */class DChoosePkcs11Provider
extends PortecleJDialog
{
/** Provider drop-down box */
private JComboBox<String> m_jcbProvider;
/** Stores the provider chosen by the user */
private String m_sProvider;
/**
* Creates new DChoosePkcs11Provider dialog.
*
* @param parent The parent window
* @param sTitle The dialog's title
* @param sOldProvider The provider to display initially
*/
public DChoosePkcs11Provider(Window parent, String sTitle, String sOldProvider)
{
super(parent, sTitle, true);
initComponents(sOldProvider);
}
/**
* Get the provider chosen by the user.
*
* @return The provider, or null if none was entered
*/
public String getProvider()
{
return m_sProvider;
}
/**
* Initialize the dialog's GUI components.
*
* @param sOldProvider The provider to display initially
*/
private void initComponents(String sOldProvider)
{
getContentPane().setLayout(new BorderLayout());
JLabel jlProvider = new JLabel(RB.getString("DChoosePkcs11Provider.jlProvider.text"));
m_jcbProvider = new JComboBox<>();
m_jcbProvider.setToolTipText(RB.getString("DChoosePkcs11Provider.m_jcbProvider.tooltip"));
jlProvider.setLabelFor(m_jcbProvider);
| // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/crypto/ProviderUtil.java
// public final class ProviderUtil
// {
// /**
// * Private to prevent construction.
// */
// private ProviderUtil()
// {
// // Nothing to do
// }
//
// /**
// * Get the PKCS #11 <code>Provider</code>s available on the system.
// *
// * @return the (possibly empty) collection of available PKCS #11 <code>Provider</code>s, sorted by name
// */
// public static Collection<Provider> getPkcs11Providers()
// {
// TreeMap<String, Provider> p11s = new TreeMap<>();
// for (Provider prov : Security.getProviders())
// {
// String pName = prov.getName();
// // Is it a PKCS #11 provider?
// /*
// * TODO: is there a better way to find out? Could try instanceof sun.security.pkcs11.SunPKCS11 but that
// * would require the class to be available?
// */
// if (pName.startsWith("SunPKCS11-"))
// {
// p11s.put(pName, prov);
// }
// }
// return p11s.values();
// }
// }
// Path: src/main/net/sf/portecle/DChoosePkcs11Provider.java
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import net.sf.portecle.crypto.ProviderUtil;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import java.security.Provider;
import java.security.Security;
import java.text.MessageFormat;
import java.util.Collection;
/*
* DChoosePkcs11Provider.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle;
/**
* Modal dialog used for choosing a PKCS #11 provider.
*
* @author Ville Skyttä
*/
/* package private */class DChoosePkcs11Provider
extends PortecleJDialog
{
/** Provider drop-down box */
private JComboBox<String> m_jcbProvider;
/** Stores the provider chosen by the user */
private String m_sProvider;
/**
* Creates new DChoosePkcs11Provider dialog.
*
* @param parent The parent window
* @param sTitle The dialog's title
* @param sOldProvider The provider to display initially
*/
public DChoosePkcs11Provider(Window parent, String sTitle, String sOldProvider)
{
super(parent, sTitle, true);
initComponents(sOldProvider);
}
/**
* Get the provider chosen by the user.
*
* @return The provider, or null if none was entered
*/
public String getProvider()
{
return m_sProvider;
}
/**
* Initialize the dialog's GUI components.
*
* @param sOldProvider The provider to display initially
*/
private void initComponents(String sOldProvider)
{
getContentPane().setLayout(new BorderLayout());
JLabel jlProvider = new JLabel(RB.getString("DChoosePkcs11Provider.jlProvider.text"));
m_jcbProvider = new JComboBox<>();
m_jcbProvider.setToolTipText(RB.getString("DChoosePkcs11Provider.m_jcbProvider.tooltip"));
jlProvider.setLabelFor(m_jcbProvider);
| Collection<Provider> p11s = ProviderUtil.getPkcs11Providers(); |
scop/portecle | src/main/net/sf/portecle/gui/password/DGetPassword.java | // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/PortecleJDialog.java
// public class PortecleJDialog
// extends JDialog
// {
// /** Key from input map to action map for the cancel button */
// private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
//
// public PortecleJDialog(Window parent, boolean modal)
// {
// super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// public PortecleJDialog(Window parent, String title, boolean modal)
// {
// super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// /**
// * Initialize the dialog.
// */
// protected void initDialog()
// {
// addWindowListener(new WindowAdapter()
// {
// @Override
// public void windowClosing(WindowEvent evt)
// {
// closeDialog();
// }
// });
//
// setResizable(false);
//
// pack();
// }
//
// /**
// * Get OK button.
// *
// * @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
// * @return
// */
// protected JButton getOkButton(boolean escPresses)
// {
// Action okAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// okPressed();
// }
// };
//
// JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text"));
//
// jbOK.addActionListener(okAction);
//
// if (escPresses)
// {
// jbOK.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbOK.getActionMap().put(ESC_KEY, okAction);
// }
//
// return jbOK;
// }
//
// /**
// * Get cancel button.
// *
// * @return
// */
// protected JButton getCancelButton()
// {
// Action cancelAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// cancelPressed();
// }
// };
//
// JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text"));
//
// jbCancel.addActionListener(cancelAction);
//
// jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbCancel.getActionMap().put(ESC_KEY, cancelAction);
//
// return jbCancel;
// }
//
// /**
// * OK button pressed or otherwise activated.
// */
// protected void okPressed()
// {
// closeDialog();
// }
//
// /**
// * Cancel button pressed or otherwise activated.
// */
// protected void cancelPressed()
// {
// closeDialog();
// }
//
// /**
// * Closes the dialog.
// */
// protected void closeDialog()
// {
// setVisible(false);
// dispose();
// }
// }
| import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import org.bouncycastle.openssl.PasswordFinder;
import net.sf.portecle.PortecleJDialog;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JLabel; | /*
* DGetPassword.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2006-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.password;
/**
* Modal dialog used for entering a masked password.
*/
public class DGetPassword
extends PortecleJDialog
implements PasswordFinder
{
/** Password entry password field */
private JPasswordField m_jpfPassword;
/** Stores password entered */
private char[] m_cPassword;
/**
* Creates new DGetPassword dialog.
*
* @param parent Parent frame
* @param sTitle The dialog's title
*/
public DGetPassword(Window parent, String sTitle)
{
super(parent, sTitle, true);
initComponents();
}
/**
* Get the password set in the dialog.
*
* @return The password or null if none was set
*/
@Override
public char[] getPassword()
{
return (m_cPassword == null) ? null : m_cPassword.clone();
}
/**
* Initialize the dialog's GUI components.
*/
private void initComponents()
{
getContentPane().setLayout(new BorderLayout());
| // Path: src/main/net/sf/portecle/FPortecle.java
// public static final ResourceBundle RB = ResourceBundle.getBundle(RB_BASENAME);
//
// Path: src/main/net/sf/portecle/PortecleJDialog.java
// public class PortecleJDialog
// extends JDialog
// {
// /** Key from input map to action map for the cancel button */
// private static final String ESC_KEY = PortecleJDialog.class.getName() + ".ESC_KEY";
//
// public PortecleJDialog(Window parent, boolean modal)
// {
// super(parent, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// public PortecleJDialog(Window parent, String title, boolean modal)
// {
// super(parent, title, modal ? Dialog.DEFAULT_MODALITY_TYPE : Dialog.ModalityType.MODELESS);
// }
//
// /**
// * Initialize the dialog.
// */
// protected void initDialog()
// {
// addWindowListener(new WindowAdapter()
// {
// @Override
// public void windowClosing(WindowEvent evt)
// {
// closeDialog();
// }
// });
//
// setResizable(false);
//
// pack();
// }
//
// /**
// * Get OK button.
// *
// * @param escPresses whether hitting Esc should press the button (usually only for dialogs without a cancel button)
// * @return
// */
// protected JButton getOkButton(boolean escPresses)
// {
// Action okAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// okPressed();
// }
// };
//
// JButton jbOK = new JButton(RB.getString("PortecleJDialog.jbOk.text"));
//
// jbOK.addActionListener(okAction);
//
// if (escPresses)
// {
// jbOK.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbOK.getActionMap().put(ESC_KEY, okAction);
// }
//
// return jbOK;
// }
//
// /**
// * Get cancel button.
// *
// * @return
// */
// protected JButton getCancelButton()
// {
// Action cancelAction = new AbstractAction()
// {
// @Override
// public void actionPerformed(ActionEvent evt)
// {
// cancelPressed();
// }
// };
//
// JButton jbCancel = new JButton(RB.getString("PortecleJDialog.jbCancel.text"));
//
// jbCancel.addActionListener(cancelAction);
//
// jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
// ESC_KEY);
// jbCancel.getActionMap().put(ESC_KEY, cancelAction);
//
// return jbCancel;
// }
//
// /**
// * OK button pressed or otherwise activated.
// */
// protected void okPressed()
// {
// closeDialog();
// }
//
// /**
// * Cancel button pressed or otherwise activated.
// */
// protected void cancelPressed()
// {
// closeDialog();
// }
//
// /**
// * Closes the dialog.
// */
// protected void closeDialog()
// {
// setVisible(false);
// dispose();
// }
// }
// Path: src/main/net/sf/portecle/gui/password/DGetPassword.java
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.border.EmptyBorder;
import org.bouncycastle.openssl.PasswordFinder;
import net.sf.portecle.PortecleJDialog;
import static net.sf.portecle.FPortecle.RB;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JLabel;
/*
* DGetPassword.java
* This file is part of Portecle, a multipurpose keystore and certificate tool.
*
* Copyright © 2004 Wayne Grant, waynedgrant@hotmail.com
* 2006-2008 Ville Skyttä, ville.skytta@iki.fi
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package net.sf.portecle.gui.password;
/**
* Modal dialog used for entering a masked password.
*/
public class DGetPassword
extends PortecleJDialog
implements PasswordFinder
{
/** Password entry password field */
private JPasswordField m_jpfPassword;
/** Stores password entered */
private char[] m_cPassword;
/**
* Creates new DGetPassword dialog.
*
* @param parent Parent frame
* @param sTitle The dialog's title
*/
public DGetPassword(Window parent, String sTitle)
{
super(parent, sTitle, true);
initComponents();
}
/**
* Get the password set in the dialog.
*
* @return The password or null if none was set
*/
@Override
public char[] getPassword()
{
return (m_cPassword == null) ? null : m_cPassword.clone();
}
/**
* Initialize the dialog's GUI components.
*/
private void initComponents()
{
getContentPane().setLayout(new BorderLayout());
| JLabel jlPassword = new JLabel(RB.getString("DGetPassword.jlPassword.text")); |
aikar/TaskChain | core/src/main/java/co/aikar/taskchain/SharedTaskChain.java | // Path: core/src/main/java/co/aikar/taskchain/TaskChainTasks.java
// public interface Task<R, A> {
// /**
// * @see TaskChain#getCurrentChain()
// */
// default TaskChain<?> getCurrentChain() {
// return TaskChain.getCurrentChain();
// }
//
// R run(A input);
// }
| import java.util.function.Consumer;
import co.aikar.taskchain.TaskChainTasks.Task;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.BiConsumer; | /*
* Copyright (c) 2016-2017 Daniel Ennis (Aikar) - MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package co.aikar.taskchain;
class SharedTaskChain<R> extends TaskChain<R> {
private final String name;
private final Map<String, Queue<SharedTaskChain>> sharedChains;
private Queue<SharedTaskChain> queue;
private volatile boolean isPending;
private volatile boolean canExecute = true;
SharedTaskChain(String name, TaskChainFactory factory) {
super(factory);
this.sharedChains = factory.getSharedChains();
this.name = name;
synchronized (this.sharedChains) {
this.queue = sharedChains.get(this.name);
if (this.queue == null) {
this.queue = new ConcurrentLinkedQueue<>();
this.sharedChains.put(this.name, this.queue);
}
this.queue.add(this);
}
}
@Override | // Path: core/src/main/java/co/aikar/taskchain/TaskChainTasks.java
// public interface Task<R, A> {
// /**
// * @see TaskChain#getCurrentChain()
// */
// default TaskChain<?> getCurrentChain() {
// return TaskChain.getCurrentChain();
// }
//
// R run(A input);
// }
// Path: core/src/main/java/co/aikar/taskchain/SharedTaskChain.java
import java.util.function.Consumer;
import co.aikar.taskchain.TaskChainTasks.Task;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.BiConsumer;
/*
* Copyright (c) 2016-2017 Daniel Ennis (Aikar) - MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package co.aikar.taskchain;
class SharedTaskChain<R> extends TaskChain<R> {
private final String name;
private final Map<String, Queue<SharedTaskChain>> sharedChains;
private Queue<SharedTaskChain> queue;
private volatile boolean isPending;
private volatile boolean canExecute = true;
SharedTaskChain(String name, TaskChainFactory factory) {
super(factory);
this.sharedChains = factory.getSharedChains();
this.name = name;
synchronized (this.sharedChains) {
this.queue = sharedChains.get(this.name);
if (this.queue == null) {
this.queue = new ConcurrentLinkedQueue<>();
this.sharedChains.put(this.name, this.queue);
}
this.queue.add(this);
}
}
@Override | public void execute(Consumer<Boolean> done, BiConsumer<Exception, Task<?, ?>> errorHandler) { |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/parser/WorldPlayersParser.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/WorldPlayersGroup.java
// public class WorldPlayersGroup implements MessageGroup {
//
// private final World world;
//
// public WorldPlayersGroup(String world) {
// this(Bukkit.getWorld(world));
// }
//
// public WorldPlayersGroup(World world) {
// Validate.notNull(world, "World cannot be null");
// this.world = world;
// }
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return world.getPlayers();
// }
// }
| import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
import com.sainttx.auctions.api.messages.WorldPlayersGroup;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class WorldPlayersParser implements MessageGroupParser {
private Pattern pattern = Pattern.compile("world:(.+)", Pattern.CASE_INSENSITIVE);
@Override | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/WorldPlayersGroup.java
// public class WorldPlayersGroup implements MessageGroup {
//
// private final World world;
//
// public WorldPlayersGroup(String world) {
// this(Bukkit.getWorld(world));
// }
//
// public WorldPlayersGroup(World world) {
// Validate.notNull(world, "World cannot be null");
// this.world = world;
// }
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return world.getPlayers();
// }
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/parser/WorldPlayersParser.java
import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
import com.sainttx.auctions.api.messages.WorldPlayersGroup;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class WorldPlayersParser implements MessageGroupParser {
private Pattern pattern = Pattern.compile("world:(.+)", Pattern.CASE_INSENSITIVE);
@Override | public MessageGroup parse(String text) { |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/parser/WorldPlayersParser.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/WorldPlayersGroup.java
// public class WorldPlayersGroup implements MessageGroup {
//
// private final World world;
//
// public WorldPlayersGroup(String world) {
// this(Bukkit.getWorld(world));
// }
//
// public WorldPlayersGroup(World world) {
// Validate.notNull(world, "World cannot be null");
// this.world = world;
// }
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return world.getPlayers();
// }
// }
| import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
import com.sainttx.auctions.api.messages.WorldPlayersGroup;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class WorldPlayersParser implements MessageGroupParser {
private Pattern pattern = Pattern.compile("world:(.+)", Pattern.CASE_INSENSITIVE);
@Override
public MessageGroup parse(String text) {
Matcher matcher = pattern.matcher(text);
String world = matcher.group(1); | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/WorldPlayersGroup.java
// public class WorldPlayersGroup implements MessageGroup {
//
// private final World world;
//
// public WorldPlayersGroup(String world) {
// this(Bukkit.getWorld(world));
// }
//
// public WorldPlayersGroup(World world) {
// Validate.notNull(world, "World cannot be null");
// this.world = world;
// }
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return world.getPlayers();
// }
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/parser/WorldPlayersParser.java
import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
import com.sainttx.auctions.api.messages.WorldPlayersGroup;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class WorldPlayersParser implements MessageGroupParser {
private Pattern pattern = Pattern.compile("world:(.+)", Pattern.CASE_INSENSITIVE);
@Override
public MessageGroup parse(String text) {
Matcher matcher = pattern.matcher(text);
String world = matcher.group(1); | return new WorldPlayersGroup(world); |
sainttx/Auctions | Auctions-API/src/main/java/com/sainttx/auctions/api/reward/ItemReward.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/AuctionPlugin.java
// public interface AuctionPlugin extends Plugin {
//
// /**
// * Returns the AuctionManager instance
// *
// * @return the manager instance
// */
// AuctionManager getManager();
//
// /**
// * Returns the Vault economy provider
// *
// * @return the vault economy provider
// */
// Economy getEconomy();
//
// /**
// * Returns the {@link MessageFactory} instance
// *
// * @return the message factory
// */
// MessageFactory getMessageFactory();
//
// /**
// * Returns the {@link Settings} for the plugin.
// *
// * @return the settings
// */
// Settings getSettings();
//
// /**
// * Gets an items name
// *
// * @param item the item
// * @return the display name of the item
// */
// String getItemName(ItemStack item);
//
// /**
// * Saves a players auctioned reward to file if the plugin was unable
// * to return it
// *
// * @param uuid The ID of a player
// * @param reward The reward that was auctioned
// */
// void saveOfflinePlayer(UUID uuid, Reward reward);
//
// /**
// * Gets a stored reward for a UUID. Returns null if there is no reward for the id.
// *
// * @param uuid the uuid
// * @return the stored reward
// */
// Reward getOfflineReward(UUID uuid);
//
// /**
// * Removes a reward that is stored for a UUID
// *
// * @param uuid the uuid
// */
// void removeOfflineReward(UUID uuid);
//
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Message.java
// public interface Message {
//
// /**
// * Returns the path inside the configuration configuration path of the message.
// *
// * @return the path.
// */
// String getMessage();
//
// /**
// * Returns whether or not this message is considered "spammy". Spammy messages
// * are able to be ignored by players using the /auction spam command.
// *
// * @return whether this message is considered spammy or not.
// */
// boolean isSpammy();
//
// /**
// * Returns whether or not this message can be ignored
// *
// * @return whether this message is ignorable or not.
// */
// boolean isIgnorable();
// }
| import com.sainttx.auctions.api.AuctionPlugin;
import com.sainttx.auctions.api.Message;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.Map; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.reward;
/**
* An implementation of {@link Reward} that gives players an item
*/
public class ItemReward implements Reward {
private AuctionPlugin plugin;
private ItemStack item; | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/AuctionPlugin.java
// public interface AuctionPlugin extends Plugin {
//
// /**
// * Returns the AuctionManager instance
// *
// * @return the manager instance
// */
// AuctionManager getManager();
//
// /**
// * Returns the Vault economy provider
// *
// * @return the vault economy provider
// */
// Economy getEconomy();
//
// /**
// * Returns the {@link MessageFactory} instance
// *
// * @return the message factory
// */
// MessageFactory getMessageFactory();
//
// /**
// * Returns the {@link Settings} for the plugin.
// *
// * @return the settings
// */
// Settings getSettings();
//
// /**
// * Gets an items name
// *
// * @param item the item
// * @return the display name of the item
// */
// String getItemName(ItemStack item);
//
// /**
// * Saves a players auctioned reward to file if the plugin was unable
// * to return it
// *
// * @param uuid The ID of a player
// * @param reward The reward that was auctioned
// */
// void saveOfflinePlayer(UUID uuid, Reward reward);
//
// /**
// * Gets a stored reward for a UUID. Returns null if there is no reward for the id.
// *
// * @param uuid the uuid
// * @return the stored reward
// */
// Reward getOfflineReward(UUID uuid);
//
// /**
// * Removes a reward that is stored for a UUID
// *
// * @param uuid the uuid
// */
// void removeOfflineReward(UUID uuid);
//
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Message.java
// public interface Message {
//
// /**
// * Returns the path inside the configuration configuration path of the message.
// *
// * @return the path.
// */
// String getMessage();
//
// /**
// * Returns whether or not this message is considered "spammy". Spammy messages
// * are able to be ignored by players using the /auction spam command.
// *
// * @return whether this message is considered spammy or not.
// */
// boolean isSpammy();
//
// /**
// * Returns whether or not this message can be ignored
// *
// * @return whether this message is ignorable or not.
// */
// boolean isIgnorable();
// }
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/reward/ItemReward.java
import com.sainttx.auctions.api.AuctionPlugin;
import com.sainttx.auctions.api.Message;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.Map;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.reward;
/**
* An implementation of {@link Reward} that gives players an item
*/
public class ItemReward implements Reward {
private AuctionPlugin plugin;
private ItemStack item; | private Message notEnoughRoom = new Message() { // TODO: Default for isSpammy |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/Auction.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/reward/Reward.java
// public interface Reward extends ConfigurationSerializable {
//
// /**
// * Gives the reward to the player
// *
// * @param player the player
// */
// void giveItem(Player player);
//
// /**
// * Returns the name or description of this reward for auction message formatting
// */
// String getName();
//
// /**
// * Returns the amount or multiplier of the reward
// *
// * @return the 'amount' present in the reward
// */
// int getAmount();
// }
| import java.util.UUID;
import com.sainttx.auctions.api.reward.Reward; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions;
public class Auction implements com.sainttx.auctions.api.Auction {
private UUID owner;
private UUID bidder;
private String ownerName;
private String bidderName; | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/reward/Reward.java
// public interface Reward extends ConfigurationSerializable {
//
// /**
// * Gives the reward to the player
// *
// * @param player the player
// */
// void giveItem(Player player);
//
// /**
// * Returns the name or description of this reward for auction message formatting
// */
// String getName();
//
// /**
// * Returns the amount or multiplier of the reward
// *
// * @return the 'amount' present in the reward
// */
// int getAmount();
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/Auction.java
import java.util.UUID;
import com.sainttx.auctions.api.reward.Reward;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions;
public class Auction implements com.sainttx.auctions.api.Auction {
private UUID owner;
private UUID bidder;
private String ownerName;
private String bidderName; | private Reward reward; |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/command/module/AuctionsModule.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
| import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.sainttx.auctions.api.Auction;
import com.sk89q.intake.parametric.AbstractModule; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.command.module;
public class AuctionsModule extends AbstractModule {
@Override
protected void configure() {
bind(CommandSender.class).toProvider(new CommandSenderProvider());
bind(Player.class).toProvider(new PlayerProvider()); | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/command/module/AuctionsModule.java
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.sainttx.auctions.api.Auction;
import com.sk89q.intake.parametric.AbstractModule;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.command.module;
public class AuctionsModule extends AbstractModule {
@Override
protected void configure() {
bind(CommandSender.class).toProvider(new CommandSenderProvider());
bind(Player.class).toProvider(new PlayerProvider()); | bind(Auction.class).toProvider(new CurrentAuctionProvider()); |
sainttx/Auctions | Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionPreBidEvent.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
| import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import com.sainttx.auctions.api.Auction;
import org.bukkit.entity.Player; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionPreBidEvent extends AuctionEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player who;
private final double amount;
private boolean cancelled;
/**
* Called when a player attempts to bid on an auction with a command
*
* @param auction the affected auction
* @param who the bidding player
* @param amount the amount that the player is bidding
*/ | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionPreBidEvent.java
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import com.sainttx.auctions.api.Auction;
import org.bukkit.entity.Player;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionPreBidEvent extends AuctionEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player who;
private final double amount;
private boolean cancelled;
/**
* Called when a player attempts to bid on an auction with a command
*
* @param auction the affected auction
* @param who the bidding player
* @param amount the amount that the player is bidding
*/ | public AuctionPreBidEvent(final Auction auction, Player who, double amount) { |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/parser/HerochatGroupParser.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-Herochat/src/main/java/com/sainttx/auctions/recipient/HerochatChannelGroup.java
// public class HerochatChannelGroup implements MessageGroup {
//
// private Channel channel;
//
// public HerochatChannelGroup(String channel) {
// Validate.notNull(channel, "Channel cannot be null");
// Channel ch = Herochat.getChannelManager().getChannel(channel);
// Validate.notNull(ch, "Invalid channel provided");
// this.channel = ch;
// }
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return channel.getMembers().stream().map(Chatter::getPlayer).collect(Collectors.toList());
// }
// }
| import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
import com.sainttx.auctions.recipient.HerochatChannelGroup;
import org.bukkit.Bukkit;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class HerochatGroupParser implements MessageGroupParser {
private Pattern pattern = Pattern.compile("herochat:(.+)", Pattern.CASE_INSENSITIVE);
@Override | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-Herochat/src/main/java/com/sainttx/auctions/recipient/HerochatChannelGroup.java
// public class HerochatChannelGroup implements MessageGroup {
//
// private Channel channel;
//
// public HerochatChannelGroup(String channel) {
// Validate.notNull(channel, "Channel cannot be null");
// Channel ch = Herochat.getChannelManager().getChannel(channel);
// Validate.notNull(ch, "Invalid channel provided");
// this.channel = ch;
// }
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return channel.getMembers().stream().map(Chatter::getPlayer).collect(Collectors.toList());
// }
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/parser/HerochatGroupParser.java
import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
import com.sainttx.auctions.recipient.HerochatChannelGroup;
import org.bukkit.Bukkit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class HerochatGroupParser implements MessageGroupParser {
private Pattern pattern = Pattern.compile("herochat:(.+)", Pattern.CASE_INSENSITIVE);
@Override | public MessageGroup parse(String text) { |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/parser/HerochatGroupParser.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-Herochat/src/main/java/com/sainttx/auctions/recipient/HerochatChannelGroup.java
// public class HerochatChannelGroup implements MessageGroup {
//
// private Channel channel;
//
// public HerochatChannelGroup(String channel) {
// Validate.notNull(channel, "Channel cannot be null");
// Channel ch = Herochat.getChannelManager().getChannel(channel);
// Validate.notNull(ch, "Invalid channel provided");
// this.channel = ch;
// }
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return channel.getMembers().stream().map(Chatter::getPlayer).collect(Collectors.toList());
// }
// }
| import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
import com.sainttx.auctions.recipient.HerochatChannelGroup;
import org.bukkit.Bukkit;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class HerochatGroupParser implements MessageGroupParser {
private Pattern pattern = Pattern.compile("herochat:(.+)", Pattern.CASE_INSENSITIVE);
@Override
public MessageGroup parse(String text) {
Matcher matcher = pattern.matcher(text);
String channel = matcher.group(1); | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-Herochat/src/main/java/com/sainttx/auctions/recipient/HerochatChannelGroup.java
// public class HerochatChannelGroup implements MessageGroup {
//
// private Channel channel;
//
// public HerochatChannelGroup(String channel) {
// Validate.notNull(channel, "Channel cannot be null");
// Channel ch = Herochat.getChannelManager().getChannel(channel);
// Validate.notNull(ch, "Invalid channel provided");
// this.channel = ch;
// }
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return channel.getMembers().stream().map(Chatter::getPlayer).collect(Collectors.toList());
// }
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/parser/HerochatGroupParser.java
import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
import com.sainttx.auctions.recipient.HerochatChannelGroup;
import org.bukkit.Bukkit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class HerochatGroupParser implements MessageGroupParser {
private Pattern pattern = Pattern.compile("herochat:(.+)", Pattern.CASE_INSENSITIVE);
@Override
public MessageGroup parse(String text) {
Matcher matcher = pattern.matcher(text);
String channel = matcher.group(1); | return new HerochatChannelGroup(channel); |
sainttx/Auctions | Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionAddTimeEvent.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
| import org.bukkit.event.HandlerList;
import com.sainttx.auctions.api.Auction;
import org.bukkit.event.Cancellable; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionAddTimeEvent extends AuctionEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private int secondsToAdd;
/**
* Created when an anti snipe module is attempting to add time to an auction
*
* @param auction the affected auction
* @param secondsToAdd the number of seconds to add
*/ | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionAddTimeEvent.java
import org.bukkit.event.HandlerList;
import com.sainttx.auctions.api.Auction;
import org.bukkit.event.Cancellable;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionAddTimeEvent extends AuctionEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private int secondsToAdd;
/**
* Created when an anti snipe module is attempting to add time to an auction
*
* @param auction the affected auction
* @param secondsToAdd the number of seconds to add
*/ | public AuctionAddTimeEvent(final Auction auction, int secondsToAdd) { |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/parser/OnlinePlayersParser.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/OnlinePlayersGroup.java
// public class OnlinePlayersGroup implements MessageGroup {
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return Bukkit.getOnlinePlayers();
// }
// }
| import com.sainttx.auctions.api.messages.OnlinePlayersGroup;
import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class OnlinePlayersParser implements MessageGroupParser {
@Override | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/OnlinePlayersGroup.java
// public class OnlinePlayersGroup implements MessageGroup {
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return Bukkit.getOnlinePlayers();
// }
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/parser/OnlinePlayersParser.java
import com.sainttx.auctions.api.messages.OnlinePlayersGroup;
import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class OnlinePlayersParser implements MessageGroupParser {
@Override | public MessageGroup parse(String text) { |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/parser/OnlinePlayersParser.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/OnlinePlayersGroup.java
// public class OnlinePlayersGroup implements MessageGroup {
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return Bukkit.getOnlinePlayers();
// }
// }
| import com.sainttx.auctions.api.messages.OnlinePlayersGroup;
import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class OnlinePlayersParser implements MessageGroupParser {
@Override
public MessageGroup parse(String text) { | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroup.java
// public interface MessageGroup {
//
// /**
// * Returns all recipients inside the recipient group
// *
// * @return any players that are in the valid channel to receive the message
// */
// Collection<? extends CommandSender> getRecipients();
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/MessageGroupParser.java
// public interface MessageGroupParser {
//
// /**
// * Parses a message group from a string of text.
// *
// * @param text the text
// * @return the group
// */
// MessageGroup parse(String text);
//
// /**
// * Returns <tt>true</tt> if a string can be parsed by this parser.
// *
// * @param text the text
// * @return <tt>true</tt> if condition is met
// */
// boolean isValid(String text);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/messages/OnlinePlayersGroup.java
// public class OnlinePlayersGroup implements MessageGroup {
//
// @Override
// public Collection<? extends CommandSender> getRecipients() {
// return Bukkit.getOnlinePlayers();
// }
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/parser/OnlinePlayersParser.java
import com.sainttx.auctions.api.messages.OnlinePlayersGroup;
import com.sainttx.auctions.api.messages.MessageGroup;
import com.sainttx.auctions.api.messages.MessageGroupParser;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.parser;
public class OnlinePlayersParser implements MessageGroupParser {
@Override
public MessageGroup parse(String text) { | return new OnlinePlayersGroup(); |
sainttx/Auctions | Auctions-API/src/main/java/com/sainttx/auctions/api/AuctionPlugin.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/reward/Reward.java
// public interface Reward extends ConfigurationSerializable {
//
// /**
// * Gives the reward to the player
// *
// * @param player the player
// */
// void giveItem(Player player);
//
// /**
// * Returns the name or description of this reward for auction message formatting
// */
// String getName();
//
// /**
// * Returns the amount or multiplier of the reward
// *
// * @return the 'amount' present in the reward
// */
// int getAmount();
// }
| import com.sainttx.auctions.api.reward.Reward;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.util.UUID; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api;
public interface AuctionPlugin extends Plugin {
/**
* Returns the AuctionManager instance
*
* @return the manager instance
*/
AuctionManager getManager();
/**
* Returns the Vault economy provider
*
* @return the vault economy provider
*/
Economy getEconomy();
/**
* Returns the {@link MessageFactory} instance
*
* @return the message factory
*/
MessageFactory getMessageFactory();
/**
* Returns the {@link Settings} for the plugin.
*
* @return the settings
*/
Settings getSettings();
/**
* Gets an items name
*
* @param item the item
* @return the display name of the item
*/
String getItemName(ItemStack item);
/**
* Saves a players auctioned reward to file if the plugin was unable
* to return it
*
* @param uuid The ID of a player
* @param reward The reward that was auctioned
*/ | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/reward/Reward.java
// public interface Reward extends ConfigurationSerializable {
//
// /**
// * Gives the reward to the player
// *
// * @param player the player
// */
// void giveItem(Player player);
//
// /**
// * Returns the name or description of this reward for auction message formatting
// */
// String getName();
//
// /**
// * Returns the amount or multiplier of the reward
// *
// * @return the 'amount' present in the reward
// */
// int getAmount();
// }
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/AuctionPlugin.java
import com.sainttx.auctions.api.reward.Reward;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.util.UUID;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api;
public interface AuctionPlugin extends Plugin {
/**
* Returns the AuctionManager instance
*
* @return the manager instance
*/
AuctionManager getManager();
/**
* Returns the Vault economy provider
*
* @return the vault economy provider
*/
Economy getEconomy();
/**
* Returns the {@link MessageFactory} instance
*
* @return the message factory
*/
MessageFactory getMessageFactory();
/**
* Returns the {@link Settings} for the plugin.
*
* @return the settings
*/
Settings getSettings();
/**
* Gets an items name
*
* @param item the item
* @return the display name of the item
*/
String getItemName(ItemStack item);
/**
* Saves a players auctioned reward to file if the plugin was unable
* to return it
*
* @param uuid The ID of a player
* @param reward The reward that was auctioned
*/ | void saveOfflinePlayer(UUID uuid, Reward reward); |
sainttx/Auctions | Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/reward/Reward.java
// public interface Reward extends ConfigurationSerializable {
//
// /**
// * Gives the reward to the player
// *
// * @param player the player
// */
// void giveItem(Player player);
//
// /**
// * Returns the name or description of this reward for auction message formatting
// */
// String getName();
//
// /**
// * Returns the amount or multiplier of the reward
// *
// * @return the 'amount' present in the reward
// */
// int getAmount();
// }
| import java.util.UUID;
import com.sainttx.auctions.api.reward.Reward; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api;
/**
* Represents an Auction that players can bid on
*/
public interface Auction {
/**
* The return value of {@link #getBid()} when no bids have been placed.
*/
double NO_BID = -1;
/**
* Gets the owner of this auction
*
* @return the auction creator
*/
UUID getOwner();
/**
* Gets the name of the owner of this auction
*
* @return the auction creators name
*/
String getOwnerName();
/**
* Gets the {@link UUID} of the current top bidder for this auction
*
* @return the current {@link UUID} of the winner
*/
UUID getBidder();
/**
* Gets the name of the current top bidder
*
* @return the top bidders name
*/
String getBidderName();
/**
* Sets the current top bidder.
*
* @param id the {@link UUID} of the bidder
* @param name the name of the bidder
*/
void setBidder(UUID id, String name);
/**
* Gets the reward that is being auctioned
*
* @return this auctions reward
*/ | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/reward/Reward.java
// public interface Reward extends ConfigurationSerializable {
//
// /**
// * Gives the reward to the player
// *
// * @param player the player
// */
// void giveItem(Player player);
//
// /**
// * Returns the name or description of this reward for auction message formatting
// */
// String getName();
//
// /**
// * Returns the amount or multiplier of the reward
// *
// * @return the 'amount' present in the reward
// */
// int getAmount();
// }
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
import java.util.UUID;
import com.sainttx.auctions.api.reward.Reward;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api;
/**
* Represents an Auction that players can bid on
*/
public interface Auction {
/**
* The return value of {@link #getBid()} when no bids have been placed.
*/
double NO_BID = -1;
/**
* Gets the owner of this auction
*
* @return the auction creator
*/
UUID getOwner();
/**
* Gets the name of the owner of this auction
*
* @return the auction creators name
*/
String getOwnerName();
/**
* Gets the {@link UUID} of the current top bidder for this auction
*
* @return the current {@link UUID} of the winner
*/
UUID getBidder();
/**
* Gets the name of the current top bidder
*
* @return the top bidders name
*/
String getBidderName();
/**
* Sets the current top bidder.
*
* @param id the {@link UUID} of the bidder
* @param name the name of the bidder
*/
void setBidder(UUID id, String name);
/**
* Gets the reward that is being auctioned
*
* @return this auctions reward
*/ | Reward getReward(); |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/MessagePath.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/AuctionPlugin.java
// public interface AuctionPlugin extends Plugin {
//
// /**
// * Returns the AuctionManager instance
// *
// * @return the manager instance
// */
// AuctionManager getManager();
//
// /**
// * Returns the Vault economy provider
// *
// * @return the vault economy provider
// */
// Economy getEconomy();
//
// /**
// * Returns the {@link MessageFactory} instance
// *
// * @return the message factory
// */
// MessageFactory getMessageFactory();
//
// /**
// * Returns the {@link Settings} for the plugin.
// *
// * @return the settings
// */
// Settings getSettings();
//
// /**
// * Gets an items name
// *
// * @param item the item
// * @return the display name of the item
// */
// String getItemName(ItemStack item);
//
// /**
// * Saves a players auctioned reward to file if the plugin was unable
// * to return it
// *
// * @param uuid The ID of a player
// * @param reward The reward that was auctioned
// */
// void saveOfflinePlayer(UUID uuid, Reward reward);
//
// /**
// * Gets a stored reward for a UUID. Returns null if there is no reward for the id.
// *
// * @param uuid the uuid
// * @return the stored reward
// */
// Reward getOfflineReward(UUID uuid);
//
// /**
// * Removes a reward that is stored for a UUID
// *
// * @param uuid the uuid
// */
// void removeOfflineReward(UUID uuid);
//
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Message.java
// public interface Message {
//
// /**
// * Returns the path inside the configuration configuration path of the message.
// *
// * @return the path.
// */
// String getMessage();
//
// /**
// * Returns whether or not this message is considered "spammy". Spammy messages
// * are able to be ignored by players using the /auction spam command.
// *
// * @return whether this message is considered spammy or not.
// */
// boolean isSpammy();
//
// /**
// * Returns whether or not this message can be ignored
// *
// * @return whether this message is ignorable or not.
// */
// boolean isIgnorable();
// }
| import org.bukkit.plugin.java.JavaPlugin;
import com.sainttx.auctions.api.AuctionPlugin;
import com.sainttx.auctions.api.Message; | ERROR_NO_AUCTION("messages.error.noCurrentAuction"),
ERROR_NOT_ENOUGH_ITEM("messages.error.notEnoughOfItem"),
ERROR_OTHER_AUCTION("messages.error.notYourAuction"),
ERROR_STARTPRICE_HIGH("messages.error.startPriceTooHigh"),
ERROR_STARTPRICE_LOW("messages.error.startPriceTooLow"),
// General messages
GENERAL_AUCTION_IMPOUNDED("messages.auctionImpounded"), // TODO: Should be auction formattable, [player] placeholder wont work
GENERAL_PLACED_IN_QUEUE("messages.auctionPlacedInQueue"),
GENERAL_DISABLED("messages.auctionsDisabled"),
GENERAL_ENABLED("messages.auctionsEnabled"),
GENERAL_BID_PERSONAL("messages.bid"), // TODO: Auction formattable, [bid] placeholder changed if needed
GENERAL_ENABLE_SPAM("messages.noLongerHidingSpam"),
GENERAL_DISABLE_SPAM("messages.nowHidingSpam"),
GENERAL_ENABLE_MESSAGES("messages.noLongerIgnoring"),
GENERAL_DISABLE_MESSAGES("messages.nowIgnoring"),
GENERAL_NOT_ENOUGH_ROOM("messages.notEnoughRoom"),
GENERAL_ITEM_RETURN("messages.ownerItemReturn"),
GENERAL_PLUGIN_RELOAD("messages.pluginReloaded"),
GENERAL_QUEUE_HEADER("messages.queueInfoHeader"),
GENERAL_SAVED_ITEM_RETURN("messages.savedItemReturn");
private final String path;
MessagePath(String path) {
this.path = path;
}
@Override
public String getMessage() { | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/AuctionPlugin.java
// public interface AuctionPlugin extends Plugin {
//
// /**
// * Returns the AuctionManager instance
// *
// * @return the manager instance
// */
// AuctionManager getManager();
//
// /**
// * Returns the Vault economy provider
// *
// * @return the vault economy provider
// */
// Economy getEconomy();
//
// /**
// * Returns the {@link MessageFactory} instance
// *
// * @return the message factory
// */
// MessageFactory getMessageFactory();
//
// /**
// * Returns the {@link Settings} for the plugin.
// *
// * @return the settings
// */
// Settings getSettings();
//
// /**
// * Gets an items name
// *
// * @param item the item
// * @return the display name of the item
// */
// String getItemName(ItemStack item);
//
// /**
// * Saves a players auctioned reward to file if the plugin was unable
// * to return it
// *
// * @param uuid The ID of a player
// * @param reward The reward that was auctioned
// */
// void saveOfflinePlayer(UUID uuid, Reward reward);
//
// /**
// * Gets a stored reward for a UUID. Returns null if there is no reward for the id.
// *
// * @param uuid the uuid
// * @return the stored reward
// */
// Reward getOfflineReward(UUID uuid);
//
// /**
// * Removes a reward that is stored for a UUID
// *
// * @param uuid the uuid
// */
// void removeOfflineReward(UUID uuid);
//
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Message.java
// public interface Message {
//
// /**
// * Returns the path inside the configuration configuration path of the message.
// *
// * @return the path.
// */
// String getMessage();
//
// /**
// * Returns whether or not this message is considered "spammy". Spammy messages
// * are able to be ignored by players using the /auction spam command.
// *
// * @return whether this message is considered spammy or not.
// */
// boolean isSpammy();
//
// /**
// * Returns whether or not this message can be ignored
// *
// * @return whether this message is ignorable or not.
// */
// boolean isIgnorable();
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/MessagePath.java
import org.bukkit.plugin.java.JavaPlugin;
import com.sainttx.auctions.api.AuctionPlugin;
import com.sainttx.auctions.api.Message;
ERROR_NO_AUCTION("messages.error.noCurrentAuction"),
ERROR_NOT_ENOUGH_ITEM("messages.error.notEnoughOfItem"),
ERROR_OTHER_AUCTION("messages.error.notYourAuction"),
ERROR_STARTPRICE_HIGH("messages.error.startPriceTooHigh"),
ERROR_STARTPRICE_LOW("messages.error.startPriceTooLow"),
// General messages
GENERAL_AUCTION_IMPOUNDED("messages.auctionImpounded"), // TODO: Should be auction formattable, [player] placeholder wont work
GENERAL_PLACED_IN_QUEUE("messages.auctionPlacedInQueue"),
GENERAL_DISABLED("messages.auctionsDisabled"),
GENERAL_ENABLED("messages.auctionsEnabled"),
GENERAL_BID_PERSONAL("messages.bid"), // TODO: Auction formattable, [bid] placeholder changed if needed
GENERAL_ENABLE_SPAM("messages.noLongerHidingSpam"),
GENERAL_DISABLE_SPAM("messages.nowHidingSpam"),
GENERAL_ENABLE_MESSAGES("messages.noLongerIgnoring"),
GENERAL_DISABLE_MESSAGES("messages.nowIgnoring"),
GENERAL_NOT_ENOUGH_ROOM("messages.notEnoughRoom"),
GENERAL_ITEM_RETURN("messages.ownerItemReturn"),
GENERAL_PLUGIN_RELOAD("messages.pluginReloaded"),
GENERAL_QUEUE_HEADER("messages.queueInfoHeader"),
GENERAL_SAVED_ITEM_RETURN("messages.savedItemReturn");
private final String path;
MessagePath(String path) {
this.path = path;
}
@Override
public String getMessage() { | AuctionPlugin plugin = JavaPlugin.getPlugin(AuctionPluginImpl.class); |
sainttx/Auctions | Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionCreateEvent.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
| import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import com.sainttx.auctions.api.Auction;
import org.bukkit.entity.Player; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionCreateEvent extends AuctionEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player who;
private boolean cancelled;
/**
* Called when a player creates an Auction with a command
*
* @param auction the created auction
* @param who the player who created the auction
*/ | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionCreateEvent.java
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import com.sainttx.auctions.api.Auction;
import org.bukkit.entity.Player;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionCreateEvent extends AuctionEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player who;
private boolean cancelled;
/**
* Called when a player creates an Auction with a command
*
* @param auction the created auction
* @param who the player who created the auction
*/ | public AuctionCreateEvent(final Auction auction, Player who) { |
sainttx/Auctions | Auctions/src/main/java/com/sainttx/auctions/command/module/CurrentAuctionProvider.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/AuctionPlugin.java
// public interface AuctionPlugin extends Plugin {
//
// /**
// * Returns the AuctionManager instance
// *
// * @return the manager instance
// */
// AuctionManager getManager();
//
// /**
// * Returns the Vault economy provider
// *
// * @return the vault economy provider
// */
// Economy getEconomy();
//
// /**
// * Returns the {@link MessageFactory} instance
// *
// * @return the message factory
// */
// MessageFactory getMessageFactory();
//
// /**
// * Returns the {@link Settings} for the plugin.
// *
// * @return the settings
// */
// Settings getSettings();
//
// /**
// * Gets an items name
// *
// * @param item the item
// * @return the display name of the item
// */
// String getItemName(ItemStack item);
//
// /**
// * Saves a players auctioned reward to file if the plugin was unable
// * to return it
// *
// * @param uuid The ID of a player
// * @param reward The reward that was auctioned
// */
// void saveOfflinePlayer(UUID uuid, Reward reward);
//
// /**
// * Gets a stored reward for a UUID. Returns null if there is no reward for the id.
// *
// * @param uuid the uuid
// * @return the stored reward
// */
// Reward getOfflineReward(UUID uuid);
//
// /**
// * Removes a reward that is stored for a UUID
// *
// * @param uuid the uuid
// */
// void removeOfflineReward(UUID uuid);
//
// }
| import com.sainttx.auctions.api.Auction;
import com.sainttx.auctions.api.AuctionPlugin;
import com.sk89q.intake.argument.ArgumentException;
import com.sk89q.intake.argument.CommandArgs;
import com.sk89q.intake.argument.MissingArgumentException;
import com.sk89q.intake.parametric.Provider;
import com.sk89q.intake.parametric.ProvisionException;
import java.lang.annotation.Annotation;
import java.util.List; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.command.module;
public class CurrentAuctionProvider implements Provider<Auction> {
@Override
public boolean isProvided() {
return false;
}
@Override
public Auction get(CommandArgs arguments, List<? extends Annotation> modifiers) throws ArgumentException, ProvisionException { | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
//
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/AuctionPlugin.java
// public interface AuctionPlugin extends Plugin {
//
// /**
// * Returns the AuctionManager instance
// *
// * @return the manager instance
// */
// AuctionManager getManager();
//
// /**
// * Returns the Vault economy provider
// *
// * @return the vault economy provider
// */
// Economy getEconomy();
//
// /**
// * Returns the {@link MessageFactory} instance
// *
// * @return the message factory
// */
// MessageFactory getMessageFactory();
//
// /**
// * Returns the {@link Settings} for the plugin.
// *
// * @return the settings
// */
// Settings getSettings();
//
// /**
// * Gets an items name
// *
// * @param item the item
// * @return the display name of the item
// */
// String getItemName(ItemStack item);
//
// /**
// * Saves a players auctioned reward to file if the plugin was unable
// * to return it
// *
// * @param uuid The ID of a player
// * @param reward The reward that was auctioned
// */
// void saveOfflinePlayer(UUID uuid, Reward reward);
//
// /**
// * Gets a stored reward for a UUID. Returns null if there is no reward for the id.
// *
// * @param uuid the uuid
// * @return the stored reward
// */
// Reward getOfflineReward(UUID uuid);
//
// /**
// * Removes a reward that is stored for a UUID
// *
// * @param uuid the uuid
// */
// void removeOfflineReward(UUID uuid);
//
// }
// Path: Auctions/src/main/java/com/sainttx/auctions/command/module/CurrentAuctionProvider.java
import com.sainttx.auctions.api.Auction;
import com.sainttx.auctions.api.AuctionPlugin;
import com.sk89q.intake.argument.ArgumentException;
import com.sk89q.intake.argument.CommandArgs;
import com.sk89q.intake.argument.MissingArgumentException;
import com.sk89q.intake.parametric.Provider;
import com.sk89q.intake.parametric.ProvisionException;
import java.lang.annotation.Annotation;
import java.util.List;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.command.module;
public class CurrentAuctionProvider implements Provider<Auction> {
@Override
public boolean isProvided() {
return false;
}
@Override
public Auction get(CommandArgs arguments, List<? extends Annotation> modifiers) throws ArgumentException, ProvisionException { | AuctionPlugin plugin = arguments.getNamespace().get(AuctionPlugin.class); |
sainttx/Auctions | Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionStartEvent.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
| import com.sainttx.auctions.api.Auction;
import org.bukkit.event.HandlerList; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionStartEvent extends AuctionEvent {
private static final HandlerList handlers = new HandlerList();
/**
* Called when an auction starts
*
* @param auction the affected auction
*/ | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionStartEvent.java
import com.sainttx.auctions.api.Auction;
import org.bukkit.event.HandlerList;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionStartEvent extends AuctionEvent {
private static final HandlerList handlers = new HandlerList();
/**
* Called when an auction starts
*
* @param auction the affected auction
*/ | public AuctionStartEvent(final Auction auction) { |
sainttx/Auctions | Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionEndEvent.java | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
| import com.sainttx.auctions.api.Auction;
import org.bukkit.event.HandlerList; | /*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionEndEvent extends AuctionEvent {
private static final HandlerList handlers = new HandlerList();
/**
* Called when an auction ends
*
* @param auction the auction that ends
*/ | // Path: Auctions-API/src/main/java/com/sainttx/auctions/api/Auction.java
// public interface Auction {
//
// /**
// * The return value of {@link #getBid()} when no bids have been placed.
// */
// double NO_BID = -1;
//
// /**
// * Gets the owner of this auction
// *
// * @return the auction creator
// */
// UUID getOwner();
//
// /**
// * Gets the name of the owner of this auction
// *
// * @return the auction creators name
// */
// String getOwnerName();
//
// /**
// * Gets the {@link UUID} of the current top bidder for this auction
// *
// * @return the current {@link UUID} of the winner
// */
// UUID getBidder();
//
// /**
// * Gets the name of the current top bidder
// *
// * @return the top bidders name
// */
// String getBidderName();
//
// /**
// * Sets the current top bidder.
// *
// * @param id the {@link UUID} of the bidder
// * @param name the name of the bidder
// */
// void setBidder(UUID id, String name);
//
// /**
// * Gets the reward that is being auctioned
// *
// * @return this auctions reward
// */
// Reward getReward();
//
// /**
// * Gets the starting price of this auction
// *
// * @return the starting price
// */
// double getStartPrice();
//
// /**
// * Gets the lowest amount that can be bid on this auction
// *
// * @return the bid increment of this auction
// */
// double getBidIncrement();
//
// /**
// * Returns the auctions autowin. Returns -1 if autowin was not set.
// *
// * @return how much money is required to automatically win the auction
// */
// double getAutowin();
//
// /**
// * Returns the current bid on this Auction. This method will return {@link #NO_BID}
// * when no bid has been placed yet.
// *
// * @return the current bid by a user
// */
// double getBid();
//
// /**
// * Sets the bid in this auction. This bid must exceed the current value
// * provided by {@link #getBid()} + {@link #getBidIncrement()}.
// *
// * @param bid the new bid
// */
// void setBid(double bid);
// }
// Path: Auctions-API/src/main/java/com/sainttx/auctions/api/event/AuctionEndEvent.java
import com.sainttx.auctions.api.Auction;
import org.bukkit.event.HandlerList;
/*
* Copyright (C) SainttX <http://sainttx.com>
* Copyright (C) contributors
*
* This file is part of Auctions.
*
* Auctions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Auctions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Auctions. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sainttx.auctions.api.event;
/**
* Created by Matthew on 9/7/2015.
*/
public class AuctionEndEvent extends AuctionEvent {
private static final HandlerList handlers = new HandlerList();
/**
* Called when an auction ends
*
* @param auction the auction that ends
*/ | public AuctionEndEvent(final Auction auction) { |
GoogleCloudPlatform/tomcat-runtime | tomcat-gcp-lib/src/test/java/com/google/cloud/runtimes/tomcat/session/DatastoreSessionTest.java | // Path: tomcat-gcp-lib/src/main/java/com/google/cloud/runtimes/tomcat/session/DatastoreSession.java
// @VisibleForTesting
// class SessionMetadata {
// public static final String CREATION_TIME = "creationTime";
// public static final String LAST_ACCESSED_TIME = "lastAccessedTime";
// public static final String MAX_INACTIVE_INTERVAL = "maxInactiveInterval";
// public static final String IS_NEW = "isNew";
// public static final String IS_VALID = "isValid";
// public static final String THIS_ACCESSED_TIME = "thisAccessedTime";
// public static final String EXPIRATION_TIME = "expirationTime";
// public static final String ATTRIBUTE_VALUE_NAME = "value";
// }
| import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import com.google.cloud.datastore.BaseEntity;
import com.google.cloud.datastore.Blob;
import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.Key;
import com.google.cloud.datastore.KeyFactory;
import com.google.cloud.runtimes.tomcat.session.DatastoreSession.SessionMetadata;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.catalina.Context;
import org.apache.catalina.Manager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations; | package com.google.cloud.runtimes.tomcat.session;
public class DatastoreSessionTest {
@Mock
private Manager sessionManager;
@Mock
private Context managerContext;
@Mock
private Key sessionKey;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(sessionManager.getContext()).thenReturn(managerContext);
}
@Test
public void testMetadataDeserialization() throws Exception {
Entity metadata = Entity.newBuilder(sessionKey) | // Path: tomcat-gcp-lib/src/main/java/com/google/cloud/runtimes/tomcat/session/DatastoreSession.java
// @VisibleForTesting
// class SessionMetadata {
// public static final String CREATION_TIME = "creationTime";
// public static final String LAST_ACCESSED_TIME = "lastAccessedTime";
// public static final String MAX_INACTIVE_INTERVAL = "maxInactiveInterval";
// public static final String IS_NEW = "isNew";
// public static final String IS_VALID = "isValid";
// public static final String THIS_ACCESSED_TIME = "thisAccessedTime";
// public static final String EXPIRATION_TIME = "expirationTime";
// public static final String ATTRIBUTE_VALUE_NAME = "value";
// }
// Path: tomcat-gcp-lib/src/test/java/com/google/cloud/runtimes/tomcat/session/DatastoreSessionTest.java
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import com.google.cloud.datastore.BaseEntity;
import com.google.cloud.datastore.Blob;
import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.Key;
import com.google.cloud.datastore.KeyFactory;
import com.google.cloud.runtimes.tomcat.session.DatastoreSession.SessionMetadata;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.catalina.Context;
import org.apache.catalina.Manager;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
package com.google.cloud.runtimes.tomcat.session;
public class DatastoreSessionTest {
@Mock
private Manager sessionManager;
@Mock
private Context managerContext;
@Mock
private Key sessionKey;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(sessionManager.getContext()).thenReturn(managerContext);
}
@Test
public void testMetadataDeserialization() throws Exception {
Entity metadata = Entity.newBuilder(sessionKey) | .set(SessionMetadata.MAX_INACTIVE_INTERVAL, 0) |
GoogleCloudPlatform/tomcat-runtime | tomcat-gcp-lib/src/main/java/com/google/cloud/runtimes/tomcat/session/DatastoreStore.java | // Path: tomcat-gcp-lib/src/main/java/com/google/cloud/runtimes/tomcat/session/DatastoreSession.java
// @VisibleForTesting
// class SessionMetadata {
// public static final String CREATION_TIME = "creationTime";
// public static final String LAST_ACCESSED_TIME = "lastAccessedTime";
// public static final String MAX_INACTIVE_INTERVAL = "maxInactiveInterval";
// public static final String IS_NEW = "isNew";
// public static final String IS_VALID = "isValid";
// public static final String THIS_ACCESSED_TIME = "thisAccessedTime";
// public static final String EXPIRATION_TIME = "expirationTime";
// public static final String ATTRIBUTE_VALUE_NAME = "value";
// }
| import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.DatastoreOptions;
import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.FullEntity;
import com.google.cloud.datastore.Key;
import com.google.cloud.datastore.KeyFactory;
import com.google.cloud.datastore.PathElement;
import com.google.cloud.datastore.Query;
import com.google.cloud.datastore.QueryResults;
import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
import com.google.cloud.runtimes.tomcat.session.DatastoreSession.SessionMetadata;
import com.google.cloud.trace.Trace;
import com.google.cloud.trace.Tracer;
import com.google.cloud.trace.core.TraceContext;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Streams;
import java.io.IOException;
import java.time.Clock;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Session;
import org.apache.catalina.session.StoreBase;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory; | datastore.put(entities.toArray(new FullEntity[0]));
datastore.delete(datastoreSession.getSuppressedAttributes().stream()
.map(attributeKeyFactory::newKey)
.toArray(Key[]::new));
endSpan(datastoreSaveContext);
}
/**
* Serialize a session to a list of Entities that can be stored to the Datastore.
* @param session The session to serialize.
* @return A list of one or more entities containing the session and its attributes.
* @throws IOException If the session cannot be serialized.
*/
@VisibleForTesting
List<Entity> serializeSession(DatastoreSession session, Key sessionKey,
KeyFactory attributeKeyFactory) throws IOException {
TraceContext serializationContext = startSpan("Serialization of the session");
List<Entity> entities = session.saveToEntities(sessionKey, attributeKeyFactory);
endSpan(serializationContext);
return entities;
}
/**
* Remove expired sessions from the datastore.
*/
@Override
public void processExpires() {
log.debug("Processing expired sessions");
Query<Key> query = Query.newKeyQueryBuilder().setKind(sessionKind) | // Path: tomcat-gcp-lib/src/main/java/com/google/cloud/runtimes/tomcat/session/DatastoreSession.java
// @VisibleForTesting
// class SessionMetadata {
// public static final String CREATION_TIME = "creationTime";
// public static final String LAST_ACCESSED_TIME = "lastAccessedTime";
// public static final String MAX_INACTIVE_INTERVAL = "maxInactiveInterval";
// public static final String IS_NEW = "isNew";
// public static final String IS_VALID = "isValid";
// public static final String THIS_ACCESSED_TIME = "thisAccessedTime";
// public static final String EXPIRATION_TIME = "expirationTime";
// public static final String ATTRIBUTE_VALUE_NAME = "value";
// }
// Path: tomcat-gcp-lib/src/main/java/com/google/cloud/runtimes/tomcat/session/DatastoreStore.java
import com.google.cloud.datastore.Datastore;
import com.google.cloud.datastore.DatastoreOptions;
import com.google.cloud.datastore.Entity;
import com.google.cloud.datastore.FullEntity;
import com.google.cloud.datastore.Key;
import com.google.cloud.datastore.KeyFactory;
import com.google.cloud.datastore.PathElement;
import com.google.cloud.datastore.Query;
import com.google.cloud.datastore.QueryResults;
import com.google.cloud.datastore.StructuredQuery.PropertyFilter;
import com.google.cloud.runtimes.tomcat.session.DatastoreSession.SessionMetadata;
import com.google.cloud.trace.Trace;
import com.google.cloud.trace.Tracer;
import com.google.cloud.trace.core.TraceContext;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Streams;
import java.io.IOException;
import java.time.Clock;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Session;
import org.apache.catalina.session.StoreBase;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
datastore.put(entities.toArray(new FullEntity[0]));
datastore.delete(datastoreSession.getSuppressedAttributes().stream()
.map(attributeKeyFactory::newKey)
.toArray(Key[]::new));
endSpan(datastoreSaveContext);
}
/**
* Serialize a session to a list of Entities that can be stored to the Datastore.
* @param session The session to serialize.
* @return A list of one or more entities containing the session and its attributes.
* @throws IOException If the session cannot be serialized.
*/
@VisibleForTesting
List<Entity> serializeSession(DatastoreSession session, Key sessionKey,
KeyFactory attributeKeyFactory) throws IOException {
TraceContext serializationContext = startSpan("Serialization of the session");
List<Entity> entities = session.saveToEntities(sessionKey, attributeKeyFactory);
endSpan(serializationContext);
return entities;
}
/**
* Remove expired sessions from the datastore.
*/
@Override
public void processExpires() {
log.debug("Processing expired sessions");
Query<Key> query = Query.newKeyQueryBuilder().setKind(sessionKind) | .setFilter(PropertyFilter.le(SessionMetadata.EXPIRATION_TIME, |
dhale/jtk | core/src/test/java/edu/mines/jtk/mosaic/TranscalerTest.java | // Path: core/src/test/java/edu/mines/jtk/mosaic/ProjectorTest.java
// private static void assertVeryClose (Projector expected, Projector actual) {
// boolean success = true;
// success &= Math.abs(expected.u0()-actual.u0()) <= eps;
// success &= Math.abs(expected.u1()-actual.u1()) <= eps;
// success &= Math.abs(expected.v0()-actual.v0()) <= eps;
// success &= Math.abs(expected.v1()-actual.v1()) <= eps;
// if (!success)
// fail("Expected: <"+expected+"> but was:<"+actual+">");
// }
| import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;
import static edu.mines.jtk.mosaic.ProjectorTest.assertVeryClose;
| /****************************************************************************
Copyright 2016, Colorado School of Mines and others.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
****************************************************************************/
package edu.mines.jtk.mosaic;
public class TranscalerTest extends TestCase {
public static void main(String[] args) {
TestSuite suite = new TestSuite(TranscalerTest.class);
TestResult result = junit.textui.TestRunner.run(suite);
// Check result and exit with nonzero status if any failed.
if (!result.wasSuccessful())
fail("Tests failed.");
}
public void testBasicTranscale () {
Transcaler tr = new Transcaler(0.0, 0.0, 1.0, 1.0, 0, 0, 100, 100);
| // Path: core/src/test/java/edu/mines/jtk/mosaic/ProjectorTest.java
// private static void assertVeryClose (Projector expected, Projector actual) {
// boolean success = true;
// success &= Math.abs(expected.u0()-actual.u0()) <= eps;
// success &= Math.abs(expected.u1()-actual.u1()) <= eps;
// success &= Math.abs(expected.v0()-actual.v0()) <= eps;
// success &= Math.abs(expected.v1()-actual.v1()) <= eps;
// if (!success)
// fail("Expected: <"+expected+"> but was:<"+actual+">");
// }
// Path: core/src/test/java/edu/mines/jtk/mosaic/TranscalerTest.java
import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;
import static edu.mines.jtk.mosaic.ProjectorTest.assertVeryClose;
/****************************************************************************
Copyright 2016, Colorado School of Mines and others.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
****************************************************************************/
package edu.mines.jtk.mosaic;
public class TranscalerTest extends TestCase {
public static void main(String[] args) {
TestSuite suite = new TestSuite(TranscalerTest.class);
TestResult result = junit.textui.TestRunner.run(suite);
// Check result and exit with nonzero status if any failed.
if (!result.wasSuccessful())
fail("Tests failed.");
}
public void testBasicTranscale () {
Transcaler tr = new Transcaler(0.0, 0.0, 1.0, 1.0, 0, 0, 100, 100);
| assertVeryClose(0.0, tr.x(0));
|
atolcd/alfresco-audit-share | audit-share-platform/src/main/java/com/atolcd/alfresco/web/scripts/shareStats/UpdateAuditPost.java | // Path: audit-share-platform/src/main/java/com/atolcd/alfresco/AuditAppEnum.java
// public enum AuditAppEnum {
// blog, calendar, dashboard, discussions, document, links, members, wiki
// }
//
// Path: audit-share-platform/src/main/java/com/atolcd/alfresco/helper/SearchHelper.java
// public class SearchHelper implements InitializingBean {
//
// private static SearchService searchService;
//
// public void setSearchService(SearchService searchService) {
// SearchHelper.searchService = searchService;
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// Assert.notNull(searchService);
// }
//
// /**
// * Execute Lucene query and return the first result (NodeRef). Return null
// * if there is no result
// *
// * @param query
// * String Lucene query
// * @return NodeRef
// */
// static public NodeRef getFirstFromQuery(String query) {
// NodeRef nodeRef = null;
// SearchParameters sp = new SearchParameters();
// sp.addStore(new StoreRef("workspace://SpacesStore"));
// sp.setLanguage(SearchService.LANGUAGE_LUCENE);
// sp.setQuery(query);
// ResultSet results = null;
//
// try {
// results = searchService.query(sp);
// if (results.length() > 0) {
// ResultSetRow row = results.getRow(0);
// nodeRef = row.getNodeRef();
// }
// } finally {
// if (results != null) {
// results.close();
// }
// }
// return nodeRef;
// }
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.site.SiteService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.util.Assert;
import com.atolcd.alfresco.AuditAppEnum;
import com.atolcd.alfresco.AuditEntry;
import com.atolcd.alfresco.helper.SearchHelper; |
public void updateAuditObjet(List<AuditEntry> auditEntries) {
for (AuditEntry auditEntry : auditEntries) {
NodeRef container = siteService.getContainer(auditEntry.getAuditSite(), auditEntry.getAuditAppName());
if (container != null) {
NodeRef child = getAuditNodeRef(container, auditEntry);
if (child != null) {
auditEntry.setAuditObject(child.toString());
sqlSessionTemplate.update(UPDATE_AUDIT_OBJECT, auditEntry);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Audits successfully updated.");
}
}
/**
* Retrieves NodeRef of the node audited from his container. When creating
* an item, it is not possible to extract his NodeRef directly.
*
* @param container
* NodeRef of the node container
* @param auditEntry
* AuditEntry object
* @return NodeRef
*/
public NodeRef getAuditNodeRef(NodeRef container, AuditEntry auditEntry) {
NodeRef nodeRef = null;
NodeRef child; | // Path: audit-share-platform/src/main/java/com/atolcd/alfresco/AuditAppEnum.java
// public enum AuditAppEnum {
// blog, calendar, dashboard, discussions, document, links, members, wiki
// }
//
// Path: audit-share-platform/src/main/java/com/atolcd/alfresco/helper/SearchHelper.java
// public class SearchHelper implements InitializingBean {
//
// private static SearchService searchService;
//
// public void setSearchService(SearchService searchService) {
// SearchHelper.searchService = searchService;
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// Assert.notNull(searchService);
// }
//
// /**
// * Execute Lucene query and return the first result (NodeRef). Return null
// * if there is no result
// *
// * @param query
// * String Lucene query
// * @return NodeRef
// */
// static public NodeRef getFirstFromQuery(String query) {
// NodeRef nodeRef = null;
// SearchParameters sp = new SearchParameters();
// sp.addStore(new StoreRef("workspace://SpacesStore"));
// sp.setLanguage(SearchService.LANGUAGE_LUCENE);
// sp.setQuery(query);
// ResultSet results = null;
//
// try {
// results = searchService.query(sp);
// if (results.length() > 0) {
// ResultSetRow row = results.getRow(0);
// nodeRef = row.getNodeRef();
// }
// } finally {
// if (results != null) {
// results.close();
// }
// }
// return nodeRef;
// }
// }
// Path: audit-share-platform/src/main/java/com/atolcd/alfresco/web/scripts/shareStats/UpdateAuditPost.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.site.SiteService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.util.Assert;
import com.atolcd.alfresco.AuditAppEnum;
import com.atolcd.alfresco.AuditEntry;
import com.atolcd.alfresco.helper.SearchHelper;
public void updateAuditObjet(List<AuditEntry> auditEntries) {
for (AuditEntry auditEntry : auditEntries) {
NodeRef container = siteService.getContainer(auditEntry.getAuditSite(), auditEntry.getAuditAppName());
if (container != null) {
NodeRef child = getAuditNodeRef(container, auditEntry);
if (child != null) {
auditEntry.setAuditObject(child.toString());
sqlSessionTemplate.update(UPDATE_AUDIT_OBJECT, auditEntry);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Audits successfully updated.");
}
}
/**
* Retrieves NodeRef of the node audited from his container. When creating
* an item, it is not possible to extract his NodeRef directly.
*
* @param container
* NodeRef of the node container
* @param auditEntry
* AuditEntry object
* @return NodeRef
*/
public NodeRef getAuditNodeRef(NodeRef container, AuditEntry auditEntry) {
NodeRef nodeRef = null;
NodeRef child; | switch (AuditAppEnum.valueOf(auditEntry.getAuditAppName())) { |
atolcd/alfresco-audit-share | audit-share-platform/src/main/java/com/atolcd/alfresco/web/scripts/shareStats/UpdateAuditPost.java | // Path: audit-share-platform/src/main/java/com/atolcd/alfresco/AuditAppEnum.java
// public enum AuditAppEnum {
// blog, calendar, dashboard, discussions, document, links, members, wiki
// }
//
// Path: audit-share-platform/src/main/java/com/atolcd/alfresco/helper/SearchHelper.java
// public class SearchHelper implements InitializingBean {
//
// private static SearchService searchService;
//
// public void setSearchService(SearchService searchService) {
// SearchHelper.searchService = searchService;
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// Assert.notNull(searchService);
// }
//
// /**
// * Execute Lucene query and return the first result (NodeRef). Return null
// * if there is no result
// *
// * @param query
// * String Lucene query
// * @return NodeRef
// */
// static public NodeRef getFirstFromQuery(String query) {
// NodeRef nodeRef = null;
// SearchParameters sp = new SearchParameters();
// sp.addStore(new StoreRef("workspace://SpacesStore"));
// sp.setLanguage(SearchService.LANGUAGE_LUCENE);
// sp.setQuery(query);
// ResultSet results = null;
//
// try {
// results = searchService.query(sp);
// if (results.length() > 0) {
// ResultSetRow row = results.getRow(0);
// nodeRef = row.getNodeRef();
// }
// } finally {
// if (results != null) {
// results.close();
// }
// }
// return nodeRef;
// }
// }
| import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.site.SiteService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.util.Assert;
import com.atolcd.alfresco.AuditAppEnum;
import com.atolcd.alfresco.AuditEntry;
import com.atolcd.alfresco.helper.SearchHelper; | if (child != null) {
auditEntry.setAuditObject(child.toString());
sqlSessionTemplate.update(UPDATE_AUDIT_OBJECT, auditEntry);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Audits successfully updated.");
}
}
/**
* Retrieves NodeRef of the node audited from his container. When creating
* an item, it is not possible to extract his NodeRef directly.
*
* @param container
* NodeRef of the node container
* @param auditEntry
* AuditEntry object
* @return NodeRef
*/
public NodeRef getAuditNodeRef(NodeRef container, AuditEntry auditEntry) {
NodeRef nodeRef = null;
NodeRef child;
switch (AuditAppEnum.valueOf(auditEntry.getAuditAppName())) {
case wiki:
nodeRef = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, auditEntry.getAuditObject());
break;
case blog:
case discussions: | // Path: audit-share-platform/src/main/java/com/atolcd/alfresco/AuditAppEnum.java
// public enum AuditAppEnum {
// blog, calendar, dashboard, discussions, document, links, members, wiki
// }
//
// Path: audit-share-platform/src/main/java/com/atolcd/alfresco/helper/SearchHelper.java
// public class SearchHelper implements InitializingBean {
//
// private static SearchService searchService;
//
// public void setSearchService(SearchService searchService) {
// SearchHelper.searchService = searchService;
// }
//
// @Override
// public void afterPropertiesSet() throws Exception {
// Assert.notNull(searchService);
// }
//
// /**
// * Execute Lucene query and return the first result (NodeRef). Return null
// * if there is no result
// *
// * @param query
// * String Lucene query
// * @return NodeRef
// */
// static public NodeRef getFirstFromQuery(String query) {
// NodeRef nodeRef = null;
// SearchParameters sp = new SearchParameters();
// sp.addStore(new StoreRef("workspace://SpacesStore"));
// sp.setLanguage(SearchService.LANGUAGE_LUCENE);
// sp.setQuery(query);
// ResultSet results = null;
//
// try {
// results = searchService.query(sp);
// if (results.length() > 0) {
// ResultSetRow row = results.getRow(0);
// nodeRef = row.getNodeRef();
// }
// } finally {
// if (results != null) {
// results.close();
// }
// }
// return nodeRef;
// }
// }
// Path: audit-share-platform/src/main/java/com/atolcd/alfresco/web/scripts/shareStats/UpdateAuditPost.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.site.SiteService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.util.Assert;
import com.atolcd.alfresco.AuditAppEnum;
import com.atolcd.alfresco.AuditEntry;
import com.atolcd.alfresco.helper.SearchHelper;
if (child != null) {
auditEntry.setAuditObject(child.toString());
sqlSessionTemplate.update(UPDATE_AUDIT_OBJECT, auditEntry);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Audits successfully updated.");
}
}
/**
* Retrieves NodeRef of the node audited from his container. When creating
* an item, it is not possible to extract his NodeRef directly.
*
* @param container
* NodeRef of the node container
* @param auditEntry
* AuditEntry object
* @return NodeRef
*/
public NodeRef getAuditNodeRef(NodeRef container, AuditEntry auditEntry) {
NodeRef nodeRef = null;
NodeRef child;
switch (AuditAppEnum.valueOf(auditEntry.getAuditAppName())) {
case wiki:
nodeRef = nodeService.getChildByName(container, ContentModel.ASSOC_CONTAINS, auditEntry.getAuditObject());
break;
case blog:
case discussions: | child = SearchHelper.getFirstFromQuery("+PARENT:\"" + container.toString() + "\" +@cm\\:title:\"" + auditEntry.getAuditObject() + "\""); |
atolcd/alfresco-audit-share | audit-share-share/src/main/java/com/atolcd/alfresco/ProxyAuditFilter.java | // Path: audit-share-share/src/main/java/com/atolcd/alfresco/helper/AuditHelper.java
// public class AuditHelper {
// /**
// * Extract the action that triggered the activity
// *
// * @param json
// * @return String Type
// * @throws JSONException
// */
// public static String extractActionFromActivity(JSONObject json) throws JSONException {
// String type = null;
// if (json.has("type")) {
// String[] tokens = json.getString("type").split("\\.");
// if (tokens.length > 0) {
// type = tokens[tokens.length - 1];
// }
// }
// return type;
// }
//
// /**
// * Extract the module concerned by the activity
// *
// * @param json
// * @return String Module
// * @throws JSONException
// */
// public static String extractModFromActivity(JSONObject json) throws JSONException {
// String mod = null;
// if (json.has("appTool")) {
// String tool = json.getString("appTool");
// if ("datalists".equals(tool)) {
// mod = AuditFilterConstants.MOD_DATA;
// } else if ("documentlibrary".equals(tool)) {
// mod = AuditFilterConstants.MOD_DOCUMENT;
// }
// }
// return mod;
// }
// }
| import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.context.ApplicationContext;
import org.springframework.extensions.surf.FrameworkUtil;
import org.springframework.extensions.surf.RequestContext;
import org.springframework.extensions.surf.RequestContextUtil;
import org.springframework.extensions.surf.exception.ConnectorServiceException;
import org.springframework.extensions.surf.exception.RequestContextException;
import org.springframework.extensions.surf.exception.ResourceLoaderException;
import org.springframework.extensions.surf.exception.UserFactoryException;
import org.springframework.extensions.surf.site.AuthenticationUtil;
import org.springframework.extensions.surf.support.AlfrescoUserFactory;
import org.springframework.extensions.surf.support.ThreadLocalRequestContext;
import org.springframework.extensions.surf.util.I18NUtil;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.connector.Connector;
import org.springframework.extensions.webscripts.connector.ConnectorContext;
import org.springframework.extensions.webscripts.connector.HttpMethod;
import org.springframework.extensions.webscripts.connector.Response;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.atolcd.alfresco.helper.AuditHelper; | Integer fileCount = activityFeed.getInt("fileCount");
if (fileCount != null && fileCount > 0) {
auditSample.put(AUDIT_APP_NAME, MOD_DOCUMENT);
auditSample.put(AUDIT_SITE, activityFeed.getString("site"));
auditSample.put(AUDIT_ACTION_NAME, "file-" + activityType.split("-")[1]);
auditSample.put(AUDIT_APP_NAME, MOD_DOCUMENT);
for (int i = 0; i < fileCount; i++) {
remoteCall(request, auditSample);
}
}
}
}
}
} else if (requestURI.startsWith(URI_NODE_UPDATE) && requestURI.endsWith(FORMPROCESSOR)) {
JSONObject updatedData = new JSONObject(requestWrapper.getStringContent());
// Online edit used the same form (plus the cm_content
// metadata)
if (!updatedData.has("prop_cm_content")) {
auditSample.put(AUDIT_APP_NAME, MOD_DOCUMENT);
auditSample.put(AUDIT_OBJECT, getNodeRefFromUrl(requestURI, 1));
auditSample.put(AUDIT_ACTION_NAME, "update");
auditSample.put(AUDIT_SITE, TEMP_SITE);
remoteCall(request, auditSample);
}
} else if (requestURI.endsWith("/activity/create")) {
String jsonPost = requestWrapper.getStringContent();
if (jsonPost != null && !jsonPost.isEmpty()) {
JSONObject json = new JSONObject(jsonPost); | // Path: audit-share-share/src/main/java/com/atolcd/alfresco/helper/AuditHelper.java
// public class AuditHelper {
// /**
// * Extract the action that triggered the activity
// *
// * @param json
// * @return String Type
// * @throws JSONException
// */
// public static String extractActionFromActivity(JSONObject json) throws JSONException {
// String type = null;
// if (json.has("type")) {
// String[] tokens = json.getString("type").split("\\.");
// if (tokens.length > 0) {
// type = tokens[tokens.length - 1];
// }
// }
// return type;
// }
//
// /**
// * Extract the module concerned by the activity
// *
// * @param json
// * @return String Module
// * @throws JSONException
// */
// public static String extractModFromActivity(JSONObject json) throws JSONException {
// String mod = null;
// if (json.has("appTool")) {
// String tool = json.getString("appTool");
// if ("datalists".equals(tool)) {
// mod = AuditFilterConstants.MOD_DATA;
// } else if ("documentlibrary".equals(tool)) {
// mod = AuditFilterConstants.MOD_DOCUMENT;
// }
// }
// return mod;
// }
// }
// Path: audit-share-share/src/main/java/com/atolcd/alfresco/ProxyAuditFilter.java
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.context.ApplicationContext;
import org.springframework.extensions.surf.FrameworkUtil;
import org.springframework.extensions.surf.RequestContext;
import org.springframework.extensions.surf.RequestContextUtil;
import org.springframework.extensions.surf.exception.ConnectorServiceException;
import org.springframework.extensions.surf.exception.RequestContextException;
import org.springframework.extensions.surf.exception.ResourceLoaderException;
import org.springframework.extensions.surf.exception.UserFactoryException;
import org.springframework.extensions.surf.site.AuthenticationUtil;
import org.springframework.extensions.surf.support.AlfrescoUserFactory;
import org.springframework.extensions.surf.support.ThreadLocalRequestContext;
import org.springframework.extensions.surf.util.I18NUtil;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.connector.Connector;
import org.springframework.extensions.webscripts.connector.ConnectorContext;
import org.springframework.extensions.webscripts.connector.HttpMethod;
import org.springframework.extensions.webscripts.connector.Response;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.atolcd.alfresco.helper.AuditHelper;
Integer fileCount = activityFeed.getInt("fileCount");
if (fileCount != null && fileCount > 0) {
auditSample.put(AUDIT_APP_NAME, MOD_DOCUMENT);
auditSample.put(AUDIT_SITE, activityFeed.getString("site"));
auditSample.put(AUDIT_ACTION_NAME, "file-" + activityType.split("-")[1]);
auditSample.put(AUDIT_APP_NAME, MOD_DOCUMENT);
for (int i = 0; i < fileCount; i++) {
remoteCall(request, auditSample);
}
}
}
}
}
} else if (requestURI.startsWith(URI_NODE_UPDATE) && requestURI.endsWith(FORMPROCESSOR)) {
JSONObject updatedData = new JSONObject(requestWrapper.getStringContent());
// Online edit used the same form (plus the cm_content
// metadata)
if (!updatedData.has("prop_cm_content")) {
auditSample.put(AUDIT_APP_NAME, MOD_DOCUMENT);
auditSample.put(AUDIT_OBJECT, getNodeRefFromUrl(requestURI, 1));
auditSample.put(AUDIT_ACTION_NAME, "update");
auditSample.put(AUDIT_SITE, TEMP_SITE);
remoteCall(request, auditSample);
}
} else if (requestURI.endsWith("/activity/create")) {
String jsonPost = requestWrapper.getStringContent();
if (jsonPost != null && !jsonPost.isEmpty()) {
JSONObject json = new JSONObject(jsonPost); | String mod = AuditHelper.extractModFromActivity(json); |
atolcd/alfresco-audit-share | audit-share-platform/src/main/java/com/atolcd/alfresco/web/scripts/shareStats/InsertAuditPost.java | // Path: audit-share-platform/src/main/java/com/atolcd/alfresco/AtolVolumetryEntry.java
// public class AtolVolumetryEntry {
// private long id = 0;
// private String siteId = "";
// private long siteSize = 0;
// private int folderCount = 0;
// private int fileCount = 0;
// private long atTime = 0;
//
// public AtolVolumetryEntry() {
// }
//
// public AtolVolumetryEntry(String siteId, long siteSize, int folderCount, int fileCount, long atTime) {
// this.siteId = siteId;
// this.siteSize = siteSize;
// this.folderCount = folderCount;
// this.fileCount = fileCount;
// this.atTime = atTime;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getSiteId() {
// return siteId;
// }
//
// public void setSiteId(String siteId) {
// this.siteId = siteId;
// }
//
// public long getSiteSize() {
// return siteSize;
// }
//
// public void setSiteSize(long siteSize) {
// this.siteSize = siteSize;
// }
//
// public int getFolderCount() {
// return folderCount;
// }
//
// public void setFolderCount(int folderCount) {
// this.folderCount = folderCount;
// }
//
// public int getFileCount() {
// return fileCount;
// }
//
// public void setFileCount(int fileCount) {
// this.fileCount = fileCount;
// }
//
// public long getAtTime() {
// return atTime;
// }
//
// public void setAtTime(long atTime) {
// this.atTime = atTime;
// }
// }
| import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.MalformedNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.util.Assert;
import com.atolcd.alfresco.AtolVolumetryEntry;
import com.atolcd.alfresco.AuditEntry; | logger.trace(e);
}
}
// Default value: cm:content
return ContentModel.TYPE_CONTENT.toPrefixString(this.namespaceService);
}
public void getSiteFromObject(AuditEntry auditSample) {
// Even if we are into the repository, we try to find the site of the
// document
if (auditSample.getAuditSite().equals(SITE_TO_FIND)) {
SiteInfo siteInfo = null;
try {
NodeRef nodeRef = new NodeRef(auditSample.getAuditObject());
siteInfo = siteService.getSite(nodeRef);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
}
if (siteInfo != null) {
auditSample.setAuditSite(siteInfo.getShortName());
} else {
auditSample.setAuditSite(SITE_REPOSITORY);
}
}
}
| // Path: audit-share-platform/src/main/java/com/atolcd/alfresco/AtolVolumetryEntry.java
// public class AtolVolumetryEntry {
// private long id = 0;
// private String siteId = "";
// private long siteSize = 0;
// private int folderCount = 0;
// private int fileCount = 0;
// private long atTime = 0;
//
// public AtolVolumetryEntry() {
// }
//
// public AtolVolumetryEntry(String siteId, long siteSize, int folderCount, int fileCount, long atTime) {
// this.siteId = siteId;
// this.siteSize = siteSize;
// this.folderCount = folderCount;
// this.fileCount = fileCount;
// this.atTime = atTime;
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public String getSiteId() {
// return siteId;
// }
//
// public void setSiteId(String siteId) {
// this.siteId = siteId;
// }
//
// public long getSiteSize() {
// return siteSize;
// }
//
// public void setSiteSize(long siteSize) {
// this.siteSize = siteSize;
// }
//
// public int getFolderCount() {
// return folderCount;
// }
//
// public void setFolderCount(int folderCount) {
// this.folderCount = folderCount;
// }
//
// public int getFileCount() {
// return fileCount;
// }
//
// public void setFileCount(int fileCount) {
// this.fileCount = fileCount;
// }
//
// public long getAtTime() {
// return atTime;
// }
//
// public void setAtTime(long atTime) {
// this.atTime = atTime;
// }
// }
// Path: audit-share-platform/src/main/java/com/atolcd/alfresco/web/scripts/shareStats/InsertAuditPost.java
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.MalformedNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.util.Assert;
import com.atolcd.alfresco.AtolVolumetryEntry;
import com.atolcd.alfresco.AuditEntry;
logger.trace(e);
}
}
// Default value: cm:content
return ContentModel.TYPE_CONTENT.toPrefixString(this.namespaceService);
}
public void getSiteFromObject(AuditEntry auditSample) {
// Even if we are into the repository, we try to find the site of the
// document
if (auditSample.getAuditSite().equals(SITE_TO_FIND)) {
SiteInfo siteInfo = null;
try {
NodeRef nodeRef = new NodeRef(auditSample.getAuditObject());
siteInfo = siteService.getSite(nodeRef);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
}
if (siteInfo != null) {
auditSample.setAuditSite(siteInfo.getShortName());
} else {
auditSample.setAuditSite(SITE_REPOSITORY);
}
}
}
| public void insertVolumetry(AtolVolumetryEntry atolVolumetryEntry) { |
atolcd/alfresco-audit-share | audit-share-platform/src/main/java/com/atolcd/auditshare/repo/service/AuditShareReferentielServiceImpl.java | // Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/Group.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "id", "libelle" })
// @XmlRootElement(name = "group")
// public class Group implements Serializable {
//
// private static final long serialVersionUID = 3626364911766188408L;
// @XmlElement(required = true)
// protected String id;
// @XmlElement(required = true)
// protected String libelle;
//
// /**
// * Gets the value of the id property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getId() {
// return id;
// }
//
// /**
// * Sets the value of the id property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setId(String value) {
// this.id = value;
// }
//
// /**
// * Gets the value of the libelle property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getLibelle() {
// return libelle;
// }
//
// /**
// * Sets the value of the libelle property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setLibelle(String value) {
// this.libelle = value;
// }
//
// }
//
// Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/ReferentielGroups.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "Groups" })
// @XmlRootElement(name = "referentiel-groups")
// public class ReferentielGroups implements Serializable {
//
// private static final long serialVersionUID = 1205873923209186977L;
// @XmlElement(name = "group")
// private List<Group> Groups;
//
// /**
// * Gets the value of the Groups property.
// *
// * <p>
// * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list
// * will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the Groups property.
// *
// * <p>
// * For example, to add a new item, do as follows:
// *
// * <pre>
// * getGroups().add(newItem);
// * </pre>
// *
// *
// * <p>
// * Objects of the following type(s) are allowed in the list {@link Group }
// *
// *
// */
// public List<Group> getGroups() {
// if (Groups == null) {
// Groups = new ArrayList<Group>();
// }
// return this.Groups;
// }
//
// }
| import com.atolcd.auditshare.repo.xml.Group;
import com.atolcd.auditshare.repo.xml.ReferentielGroups;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.log4j.Logger; | /*
* Copyright (C) 2018 Atol Conseils et Développements.
* http://www.atolcd.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atolcd.auditshare.repo.service;
public class AuditShareReferentielServiceImpl implements AuditShareReferentielService {
public static final Logger logger = Logger.getLogger(AuditShareReferentielServiceImpl.class.getName());
private NodeService nodeService;
private ContentService contentService;
public ContentService getContentService() {
return contentService;
}
public void setContentService(ContentService contentService) {
this.contentService = contentService;
}
public NodeService getNodeService() {
return nodeService;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
| // Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/Group.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "id", "libelle" })
// @XmlRootElement(name = "group")
// public class Group implements Serializable {
//
// private static final long serialVersionUID = 3626364911766188408L;
// @XmlElement(required = true)
// protected String id;
// @XmlElement(required = true)
// protected String libelle;
//
// /**
// * Gets the value of the id property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getId() {
// return id;
// }
//
// /**
// * Sets the value of the id property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setId(String value) {
// this.id = value;
// }
//
// /**
// * Gets the value of the libelle property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getLibelle() {
// return libelle;
// }
//
// /**
// * Sets the value of the libelle property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setLibelle(String value) {
// this.libelle = value;
// }
//
// }
//
// Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/ReferentielGroups.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "Groups" })
// @XmlRootElement(name = "referentiel-groups")
// public class ReferentielGroups implements Serializable {
//
// private static final long serialVersionUID = 1205873923209186977L;
// @XmlElement(name = "group")
// private List<Group> Groups;
//
// /**
// * Gets the value of the Groups property.
// *
// * <p>
// * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list
// * will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the Groups property.
// *
// * <p>
// * For example, to add a new item, do as follows:
// *
// * <pre>
// * getGroups().add(newItem);
// * </pre>
// *
// *
// * <p>
// * Objects of the following type(s) are allowed in the list {@link Group }
// *
// *
// */
// public List<Group> getGroups() {
// if (Groups == null) {
// Groups = new ArrayList<Group>();
// }
// return this.Groups;
// }
//
// }
// Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/service/AuditShareReferentielServiceImpl.java
import com.atolcd.auditshare.repo.xml.Group;
import com.atolcd.auditshare.repo.xml.ReferentielGroups;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.log4j.Logger;
/*
* Copyright (C) 2018 Atol Conseils et Développements.
* http://www.atolcd.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atolcd.auditshare.repo.service;
public class AuditShareReferentielServiceImpl implements AuditShareReferentielService {
public static final Logger logger = Logger.getLogger(AuditShareReferentielServiceImpl.class.getName());
private NodeService nodeService;
private ContentService contentService;
public ContentService getContentService() {
return contentService;
}
public void setContentService(ContentService contentService) {
this.contentService = contentService;
}
public NodeService getNodeService() {
return nodeService;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
| public List<Group> parseRefentielForNodeUUID(String id) { |
atolcd/alfresco-audit-share | audit-share-platform/src/main/java/com/atolcd/auditshare/repo/service/AuditShareReferentielServiceImpl.java | // Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/Group.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "id", "libelle" })
// @XmlRootElement(name = "group")
// public class Group implements Serializable {
//
// private static final long serialVersionUID = 3626364911766188408L;
// @XmlElement(required = true)
// protected String id;
// @XmlElement(required = true)
// protected String libelle;
//
// /**
// * Gets the value of the id property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getId() {
// return id;
// }
//
// /**
// * Sets the value of the id property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setId(String value) {
// this.id = value;
// }
//
// /**
// * Gets the value of the libelle property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getLibelle() {
// return libelle;
// }
//
// /**
// * Sets the value of the libelle property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setLibelle(String value) {
// this.libelle = value;
// }
//
// }
//
// Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/ReferentielGroups.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "Groups" })
// @XmlRootElement(name = "referentiel-groups")
// public class ReferentielGroups implements Serializable {
//
// private static final long serialVersionUID = 1205873923209186977L;
// @XmlElement(name = "group")
// private List<Group> Groups;
//
// /**
// * Gets the value of the Groups property.
// *
// * <p>
// * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list
// * will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the Groups property.
// *
// * <p>
// * For example, to add a new item, do as follows:
// *
// * <pre>
// * getGroups().add(newItem);
// * </pre>
// *
// *
// * <p>
// * Objects of the following type(s) are allowed in the list {@link Group }
// *
// *
// */
// public List<Group> getGroups() {
// if (Groups == null) {
// Groups = new ArrayList<Group>();
// }
// return this.Groups;
// }
//
// }
| import com.atolcd.auditshare.repo.xml.Group;
import com.atolcd.auditshare.repo.xml.ReferentielGroups;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.log4j.Logger; | }
public List<Group> parseRefentielForNodeUUID(String id) {
InputStream xmlStream = null;
try {
// Verification de l'existance du node
NodeRef xmlRefNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id);
if (nodeService.exists(xmlRefNodeRef)) {
xmlStream = contentService.getReader(xmlRefNodeRef, ContentModel.PROP_CONTENT).getContentInputStream();
// Initialisation du référentiel des groupes
return parseReferentielGroups(xmlStream);
} else {
logger.error("NodeRef non trouvé pour l'id passé en paramètre : " + id);
}
} catch (Exception e) {
logger.error("Impossible de parser le référentiel ", e);
} finally {
try {
if (xmlStream != null) {
xmlStream.close();
}
} catch (Exception e) {
logger.error("Impossible de fermer le flux de données ", e);
}
}
return Collections.emptyList();
}
public List<Group> parseReferentielGroups(InputStream file) { | // Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/Group.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "id", "libelle" })
// @XmlRootElement(name = "group")
// public class Group implements Serializable {
//
// private static final long serialVersionUID = 3626364911766188408L;
// @XmlElement(required = true)
// protected String id;
// @XmlElement(required = true)
// protected String libelle;
//
// /**
// * Gets the value of the id property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getId() {
// return id;
// }
//
// /**
// * Sets the value of the id property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setId(String value) {
// this.id = value;
// }
//
// /**
// * Gets the value of the libelle property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getLibelle() {
// return libelle;
// }
//
// /**
// * Sets the value of the libelle property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setLibelle(String value) {
// this.libelle = value;
// }
//
// }
//
// Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/ReferentielGroups.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "Groups" })
// @XmlRootElement(name = "referentiel-groups")
// public class ReferentielGroups implements Serializable {
//
// private static final long serialVersionUID = 1205873923209186977L;
// @XmlElement(name = "group")
// private List<Group> Groups;
//
// /**
// * Gets the value of the Groups property.
// *
// * <p>
// * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list
// * will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the Groups property.
// *
// * <p>
// * For example, to add a new item, do as follows:
// *
// * <pre>
// * getGroups().add(newItem);
// * </pre>
// *
// *
// * <p>
// * Objects of the following type(s) are allowed in the list {@link Group }
// *
// *
// */
// public List<Group> getGroups() {
// if (Groups == null) {
// Groups = new ArrayList<Group>();
// }
// return this.Groups;
// }
//
// }
// Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/service/AuditShareReferentielServiceImpl.java
import com.atolcd.auditshare.repo.xml.Group;
import com.atolcd.auditshare.repo.xml.ReferentielGroups;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.log4j.Logger;
}
public List<Group> parseRefentielForNodeUUID(String id) {
InputStream xmlStream = null;
try {
// Verification de l'existance du node
NodeRef xmlRefNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id);
if (nodeService.exists(xmlRefNodeRef)) {
xmlStream = contentService.getReader(xmlRefNodeRef, ContentModel.PROP_CONTENT).getContentInputStream();
// Initialisation du référentiel des groupes
return parseReferentielGroups(xmlStream);
} else {
logger.error("NodeRef non trouvé pour l'id passé en paramètre : " + id);
}
} catch (Exception e) {
logger.error("Impossible de parser le référentiel ", e);
} finally {
try {
if (xmlStream != null) {
xmlStream.close();
}
} catch (Exception e) {
logger.error("Impossible de fermer le flux de données ", e);
}
}
return Collections.emptyList();
}
public List<Group> parseReferentielGroups(InputStream file) { | ReferentielGroups referentiel = new ReferentielGroups(); |
atolcd/alfresco-audit-share | audit-share-platform/src/main/java/com/atolcd/auditshare/repo/service/AuditShareReferentielService.java | // Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/Group.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "id", "libelle" })
// @XmlRootElement(name = "group")
// public class Group implements Serializable {
//
// private static final long serialVersionUID = 3626364911766188408L;
// @XmlElement(required = true)
// protected String id;
// @XmlElement(required = true)
// protected String libelle;
//
// /**
// * Gets the value of the id property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getId() {
// return id;
// }
//
// /**
// * Sets the value of the id property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setId(String value) {
// this.id = value;
// }
//
// /**
// * Gets the value of the libelle property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getLibelle() {
// return libelle;
// }
//
// /**
// * Sets the value of the libelle property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setLibelle(String value) {
// this.libelle = value;
// }
//
// }
| import java.io.InputStream;
import java.util.List;
import com.atolcd.auditshare.repo.xml.Group; | /*
* Copyright (C) 2018 Atol Conseils et Développements.
* http://www.atolcd.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atolcd.auditshare.repo.service;
public interface AuditShareReferentielService {
public static String auditShareReferentielNodeUUID = "auditshare-user-connections-groups";
| // Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/xml/Group.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "", propOrder = { "id", "libelle" })
// @XmlRootElement(name = "group")
// public class Group implements Serializable {
//
// private static final long serialVersionUID = 3626364911766188408L;
// @XmlElement(required = true)
// protected String id;
// @XmlElement(required = true)
// protected String libelle;
//
// /**
// * Gets the value of the id property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getId() {
// return id;
// }
//
// /**
// * Sets the value of the id property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setId(String value) {
// this.id = value;
// }
//
// /**
// * Gets the value of the libelle property.
// *
// * @return possible object is {@link String }
// *
// */
// public String getLibelle() {
// return libelle;
// }
//
// /**
// * Sets the value of the libelle property.
// *
// * @param value allowed object is {@link String }
// *
// */
// public void setLibelle(String value) {
// this.libelle = value;
// }
//
// }
// Path: audit-share-platform/src/main/java/com/atolcd/auditshare/repo/service/AuditShareReferentielService.java
import java.io.InputStream;
import java.util.List;
import com.atolcd.auditshare.repo.xml.Group;
/*
* Copyright (C) 2018 Atol Conseils et Développements.
* http://www.atolcd.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atolcd.auditshare.repo.service;
public interface AuditShareReferentielService {
public static String auditShareReferentielNodeUUID = "auditshare-user-connections-groups";
| public List<Group> parseReferentielGroups(InputStream file); |
atolcd/alfresco-audit-share | audit-share-share/src/main/java/com/atolcd/alfresco/helper/AuditHelper.java | // Path: audit-share-share/src/main/java/com/atolcd/alfresco/AuditFilterConstants.java
// public class AuditFilterConstants {
// // Constants used by"hashmaps" and "parameters"
// public static final String AUDIT_ID = "id";
// public static final String AUDIT_USER_ID = "auditUserId";
// public static final String AUDIT_APP_NAME = "auditAppName";
// public static final String AUDIT_SITE = "auditSite";
// public static final String AUDIT_ACTION_NAME = "auditActionName";
// public static final String AUDIT_OBJECT = "auditObject";
// public static final String AUDIT_TIME = "auditTime";
//
// // Audited modules
// public static final String MOD_WIKI = "wiki";
// public static final String MOD_BLOG = "blog";
// public static final String MOD_LINKS = "links";
// public static final String MOD_DISCUSSIONS = "discussions";
// public static final String MOD_CALENDAR = "calendar";
// public static final String MOD_DATA = "data";
// public static final String MOD_MEMBERS = "members";
// public static final String MOD_DOCUMENT = "document";
//
// public static final String SITE_REPOSITORY = "_repository";
// }
| import org.json.JSONException;
import org.json.JSONObject;
import com.atolcd.alfresco.AuditFilterConstants; | /*
* Copyright (C) 2018 Atol Conseils et Développements.
* http://www.atolcd.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atolcd.alfresco.helper;
public class AuditHelper {
/**
* Extract the action that triggered the activity
*
* @param json
* @return String Type
* @throws JSONException
*/
public static String extractActionFromActivity(JSONObject json) throws JSONException {
String type = null;
if (json.has("type")) {
String[] tokens = json.getString("type").split("\\.");
if (tokens.length > 0) {
type = tokens[tokens.length - 1];
}
}
return type;
}
/**
* Extract the module concerned by the activity
*
* @param json
* @return String Module
* @throws JSONException
*/
public static String extractModFromActivity(JSONObject json) throws JSONException {
String mod = null;
if (json.has("appTool")) {
String tool = json.getString("appTool");
if ("datalists".equals(tool)) { | // Path: audit-share-share/src/main/java/com/atolcd/alfresco/AuditFilterConstants.java
// public class AuditFilterConstants {
// // Constants used by"hashmaps" and "parameters"
// public static final String AUDIT_ID = "id";
// public static final String AUDIT_USER_ID = "auditUserId";
// public static final String AUDIT_APP_NAME = "auditAppName";
// public static final String AUDIT_SITE = "auditSite";
// public static final String AUDIT_ACTION_NAME = "auditActionName";
// public static final String AUDIT_OBJECT = "auditObject";
// public static final String AUDIT_TIME = "auditTime";
//
// // Audited modules
// public static final String MOD_WIKI = "wiki";
// public static final String MOD_BLOG = "blog";
// public static final String MOD_LINKS = "links";
// public static final String MOD_DISCUSSIONS = "discussions";
// public static final String MOD_CALENDAR = "calendar";
// public static final String MOD_DATA = "data";
// public static final String MOD_MEMBERS = "members";
// public static final String MOD_DOCUMENT = "document";
//
// public static final String SITE_REPOSITORY = "_repository";
// }
// Path: audit-share-share/src/main/java/com/atolcd/alfresco/helper/AuditHelper.java
import org.json.JSONException;
import org.json.JSONObject;
import com.atolcd.alfresco.AuditFilterConstants;
/*
* Copyright (C) 2018 Atol Conseils et Développements.
* http://www.atolcd.com/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atolcd.alfresco.helper;
public class AuditHelper {
/**
* Extract the action that triggered the activity
*
* @param json
* @return String Type
* @throws JSONException
*/
public static String extractActionFromActivity(JSONObject json) throws JSONException {
String type = null;
if (json.has("type")) {
String[] tokens = json.getString("type").split("\\.");
if (tokens.length > 0) {
type = tokens[tokens.length - 1];
}
}
return type;
}
/**
* Extract the module concerned by the activity
*
* @param json
* @return String Module
* @throws JSONException
*/
public static String extractModFromActivity(JSONObject json) throws JSONException {
String mod = null;
if (json.has("appTool")) {
String tool = json.getString("appTool");
if ("datalists".equals(tool)) { | mod = AuditFilterConstants.MOD_DATA; |
Q42/Jue | jue/src/nl/q42/jue/StateUpdate.java | // Path: jue/src/nl/q42/jue/State.java
// public enum AlertMode {
// /**
// * Light is not performing alert effect
// */
// NONE,
//
// /**
// * Light is performing one breathe cycle
// */
// SELECT,
//
// /**
// * Light is performing breathe cycles for 30 seconds (unless cancelled)
// */
// LSELECT
// }
//
// Path: jue/src/nl/q42/jue/State.java
// public enum Effect {
// /**
// * No effect
// */
// NONE,
//
// /**
// * Cycle through all hues with current saturation and brightness
// */
// COLORLOOP
// }
| import java.util.ArrayList;
import nl.q42.jue.State.AlertMode;
import nl.q42.jue.State.Effect; | if (xy.length != 2) {
throw new IllegalArgumentException("Invalid coordinate array given");
} else if (xy[0] < 0.0f || xy[0] > 1.0f || xy[1] < 0.0f || xy[1] > 1.0f) {
throw new IllegalArgumentException("X and/or Y coordinate(s) out of bounds");
}
commands.add(new Command("xy", xy));
return this;
}
/**
* Switch to CT color mode and set color temperature in mired.
* @param colorTemperature color temperature [153..500]
* @return this object for chaining calls
*/
public StateUpdate setColorTemperature(int colorTemperature) {
if (colorTemperature < 153 || colorTemperature > 500) {
throw new IllegalArgumentException("Color temperature out of range");
}
commands.add(new Command("ct", colorTemperature));
return this;
}
/**
* Set the alert mode.
* @see AlertMode
* @param mode alert mode
* @return this object for chaining calls
*/ | // Path: jue/src/nl/q42/jue/State.java
// public enum AlertMode {
// /**
// * Light is not performing alert effect
// */
// NONE,
//
// /**
// * Light is performing one breathe cycle
// */
// SELECT,
//
// /**
// * Light is performing breathe cycles for 30 seconds (unless cancelled)
// */
// LSELECT
// }
//
// Path: jue/src/nl/q42/jue/State.java
// public enum Effect {
// /**
// * No effect
// */
// NONE,
//
// /**
// * Cycle through all hues with current saturation and brightness
// */
// COLORLOOP
// }
// Path: jue/src/nl/q42/jue/StateUpdate.java
import java.util.ArrayList;
import nl.q42.jue.State.AlertMode;
import nl.q42.jue.State.Effect;
if (xy.length != 2) {
throw new IllegalArgumentException("Invalid coordinate array given");
} else if (xy[0] < 0.0f || xy[0] > 1.0f || xy[1] < 0.0f || xy[1] > 1.0f) {
throw new IllegalArgumentException("X and/or Y coordinate(s) out of bounds");
}
commands.add(new Command("xy", xy));
return this;
}
/**
* Switch to CT color mode and set color temperature in mired.
* @param colorTemperature color temperature [153..500]
* @return this object for chaining calls
*/
public StateUpdate setColorTemperature(int colorTemperature) {
if (colorTemperature < 153 || colorTemperature > 500) {
throw new IllegalArgumentException("Color temperature out of range");
}
commands.add(new Command("ct", colorTemperature));
return this;
}
/**
* Set the alert mode.
* @see AlertMode
* @param mode alert mode
* @return this object for chaining calls
*/ | public StateUpdate setAlert(AlertMode mode) { |
Q42/Jue | jue/src/nl/q42/jue/StateUpdate.java | // Path: jue/src/nl/q42/jue/State.java
// public enum AlertMode {
// /**
// * Light is not performing alert effect
// */
// NONE,
//
// /**
// * Light is performing one breathe cycle
// */
// SELECT,
//
// /**
// * Light is performing breathe cycles for 30 seconds (unless cancelled)
// */
// LSELECT
// }
//
// Path: jue/src/nl/q42/jue/State.java
// public enum Effect {
// /**
// * No effect
// */
// NONE,
//
// /**
// * Cycle through all hues with current saturation and brightness
// */
// COLORLOOP
// }
| import java.util.ArrayList;
import nl.q42.jue.State.AlertMode;
import nl.q42.jue.State.Effect; | * Switch to CT color mode and set color temperature in mired.
* @param colorTemperature color temperature [153..500]
* @return this object for chaining calls
*/
public StateUpdate setColorTemperature(int colorTemperature) {
if (colorTemperature < 153 || colorTemperature > 500) {
throw new IllegalArgumentException("Color temperature out of range");
}
commands.add(new Command("ct", colorTemperature));
return this;
}
/**
* Set the alert mode.
* @see AlertMode
* @param mode alert mode
* @return this object for chaining calls
*/
public StateUpdate setAlert(AlertMode mode) {
commands.add(new Command("alert", mode.toString().toLowerCase()));
return this;
}
/**
* Set the current effect.
* @see Effect
* @param effect effect
* @return this object for chaining calls
*/ | // Path: jue/src/nl/q42/jue/State.java
// public enum AlertMode {
// /**
// * Light is not performing alert effect
// */
// NONE,
//
// /**
// * Light is performing one breathe cycle
// */
// SELECT,
//
// /**
// * Light is performing breathe cycles for 30 seconds (unless cancelled)
// */
// LSELECT
// }
//
// Path: jue/src/nl/q42/jue/State.java
// public enum Effect {
// /**
// * No effect
// */
// NONE,
//
// /**
// * Cycle through all hues with current saturation and brightness
// */
// COLORLOOP
// }
// Path: jue/src/nl/q42/jue/StateUpdate.java
import java.util.ArrayList;
import nl.q42.jue.State.AlertMode;
import nl.q42.jue.State.Effect;
* Switch to CT color mode and set color temperature in mired.
* @param colorTemperature color temperature [153..500]
* @return this object for chaining calls
*/
public StateUpdate setColorTemperature(int colorTemperature) {
if (colorTemperature < 153 || colorTemperature > 500) {
throw new IllegalArgumentException("Color temperature out of range");
}
commands.add(new Command("ct", colorTemperature));
return this;
}
/**
* Set the alert mode.
* @see AlertMode
* @param mode alert mode
* @return this object for chaining calls
*/
public StateUpdate setAlert(AlertMode mode) {
commands.add(new Command("alert", mode.toString().toLowerCase()));
return this;
}
/**
* Set the current effect.
* @see Effect
* @param effect effect
* @return this object for chaining calls
*/ | public StateUpdate setEffect(Effect effect) { |
Q42/Jue | jue/src/nl/q42/jue/HueBridge.java | // Path: jue/src/nl/q42/jue/HttpClient.java
// public static class Result {
// private String body;
// private int responseCode;
//
// public Result(String body, int responseCode) {
// this.body = body;
// this.responseCode = responseCode;
// }
//
// public String getBody() {
// return body;
// }
//
// public int getResponseCode() {
// return responseCode;
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/ApiException.java
// @SuppressWarnings("serial")
// public class ApiException extends Exception {
// public ApiException() {}
//
// public ApiException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/DeviceOffException.java
// @SuppressWarnings("serial")
// public class DeviceOffException extends ApiException {
// public DeviceOffException() {}
//
// public DeviceOffException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/EntityNotAvailableException.java
// @SuppressWarnings("serial")
// public class EntityNotAvailableException extends ApiException {
// public EntityNotAvailableException() {}
//
// public EntityNotAvailableException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/GroupTableFullException.java
// @SuppressWarnings("serial")
// public class GroupTableFullException extends ApiException {
// public GroupTableFullException() {}
//
// public GroupTableFullException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/InvalidCommandException.java
// @SuppressWarnings("serial")
// public class InvalidCommandException extends ApiException {
// public InvalidCommandException() {}
//
// public InvalidCommandException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/LinkButtonException.java
// @SuppressWarnings("serial")
// public class LinkButtonException extends ApiException {
// public LinkButtonException() {}
//
// public LinkButtonException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/UnauthorizedException.java
// @SuppressWarnings("serial")
// public class UnauthorizedException extends ApiException {
// public UnauthorizedException() {}
//
// public UnauthorizedException(String message) {
// super(message);
// }
// }
| import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import nl.q42.jue.HttpClient.Result;
import nl.q42.jue.exceptions.ApiException;
import nl.q42.jue.exceptions.DeviceOffException;
import nl.q42.jue.exceptions.EntityNotAvailableException;
import nl.q42.jue.exceptions.GroupTableFullException;
import nl.q42.jue.exceptions.InvalidCommandException;
import nl.q42.jue.exceptions.LinkButtonException;
import nl.q42.jue.exceptions.UnauthorizedException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser; | package nl.q42.jue;
/**
* Representation of a connection with a Hue bridge.
*/
public class HueBridge {
private final static String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
private String ip;
private String username;
private Gson gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
private HttpClient http = new HttpClient();
/**
* Connect with a bridge as a new user.
* @param ip ip address of bridge
*/
public HueBridge(String ip) {
this.ip = ip;
}
/**
* Connect with a bridge as an existing user.
*
* The username is verified by requesting the list of lights.
* Use the ip only constructor and authenticate() function if
* you don't want to connect right now.
* @param ip ip address of bridge
* @param username username to authenticate with
*/ | // Path: jue/src/nl/q42/jue/HttpClient.java
// public static class Result {
// private String body;
// private int responseCode;
//
// public Result(String body, int responseCode) {
// this.body = body;
// this.responseCode = responseCode;
// }
//
// public String getBody() {
// return body;
// }
//
// public int getResponseCode() {
// return responseCode;
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/ApiException.java
// @SuppressWarnings("serial")
// public class ApiException extends Exception {
// public ApiException() {}
//
// public ApiException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/DeviceOffException.java
// @SuppressWarnings("serial")
// public class DeviceOffException extends ApiException {
// public DeviceOffException() {}
//
// public DeviceOffException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/EntityNotAvailableException.java
// @SuppressWarnings("serial")
// public class EntityNotAvailableException extends ApiException {
// public EntityNotAvailableException() {}
//
// public EntityNotAvailableException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/GroupTableFullException.java
// @SuppressWarnings("serial")
// public class GroupTableFullException extends ApiException {
// public GroupTableFullException() {}
//
// public GroupTableFullException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/InvalidCommandException.java
// @SuppressWarnings("serial")
// public class InvalidCommandException extends ApiException {
// public InvalidCommandException() {}
//
// public InvalidCommandException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/LinkButtonException.java
// @SuppressWarnings("serial")
// public class LinkButtonException extends ApiException {
// public LinkButtonException() {}
//
// public LinkButtonException(String message) {
// super(message);
// }
// }
//
// Path: jue/src/nl/q42/jue/exceptions/UnauthorizedException.java
// @SuppressWarnings("serial")
// public class UnauthorizedException extends ApiException {
// public UnauthorizedException() {}
//
// public UnauthorizedException(String message) {
// super(message);
// }
// }
// Path: jue/src/nl/q42/jue/HueBridge.java
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import nl.q42.jue.HttpClient.Result;
import nl.q42.jue.exceptions.ApiException;
import nl.q42.jue.exceptions.DeviceOffException;
import nl.q42.jue.exceptions.EntityNotAvailableException;
import nl.q42.jue.exceptions.GroupTableFullException;
import nl.q42.jue.exceptions.InvalidCommandException;
import nl.q42.jue.exceptions.LinkButtonException;
import nl.q42.jue.exceptions.UnauthorizedException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
package nl.q42.jue;
/**
* Representation of a connection with a Hue bridge.
*/
public class HueBridge {
private final static String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
private String ip;
private String username;
private Gson gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
private HttpClient http = new HttpClient();
/**
* Connect with a bridge as a new user.
* @param ip ip address of bridge
*/
public HueBridge(String ip) {
this.ip = ip;
}
/**
* Connect with a bridge as an existing user.
*
* The username is verified by requesting the list of lights.
* Use the ip only constructor and authenticate() function if
* you don't want to connect right now.
* @param ip ip address of bridge
* @param username username to authenticate with
*/ | public HueBridge(String ip, String username) throws IOException, ApiException { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.