hexsha stringlengths 40 40 | size int64 3 1.05M | ext stringclasses 1 value | lang stringclasses 1 value | max_stars_repo_path stringlengths 5 1.02k | max_stars_repo_name stringlengths 4 126 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses list | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 5 1.02k | max_issues_repo_name stringlengths 4 114 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses list | max_issues_count float64 1 92.2k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 5 1.02k | max_forks_repo_name stringlengths 4 136 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses list | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | avg_line_length float64 2.55 99.9 | max_line_length int64 3 1k | alphanum_fraction float64 0.25 1 | index int64 0 1M | content stringlengths 3 1.05M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3e07d9719ebb7a22dfc86bb4fd74d08c9ac2eb58 | 291 | java | Java | src/main/java/org/elastos/hive/vault/scripting/FileUploadExecutable.java | elastos/Elastos.Hive.Java.SDK | 15c6ef9d65fa12bba1ced59b83ca75e9818ef9a2 | [
"MIT"
] | 5 | 2019-05-16T09:24:16.000Z | 2021-04-15T14:51:41.000Z | src/main/java/org/elastos/hive/vault/scripting/FileUploadExecutable.java | elastos/Elastos.NET.Hive.Android.SDK | e89d8a65449a7f81aa1616251c7f3e2f13febd98 | [
"MIT"
] | 8 | 2019-06-13T09:12:34.000Z | 2021-03-12T08:32:13.000Z | src/main/java/org/elastos/hive/vault/scripting/FileUploadExecutable.java | elastos/Elastos.NET.Hive.Android.SDK | e89d8a65449a7f81aa1616251c7f3e2f13febd98 | [
"MIT"
] | 17 | 2019-06-13T03:21:55.000Z | 2021-06-21T02:17:04.000Z | 24.25 | 54 | 0.704467 | 3,318 | package org.elastos.hive.vault.scripting;
/**
* The executable to upload the file content.
*/
public class FileUploadExecutable extends Executable {
public FileUploadExecutable(String name) {
super(name, Type.FILE_UPLOAD, null);
super.setBody(new FileBody());
}
}
|
3e07d9b361ae14b5ed522b200791745ae3f760fd | 1,421 | java | Java | app/src/main/java/com/voicecloningmobileapp/SlideAdapter.java | VladAIacob/VoiceCloningMobileApp | ffd4035253e444c295b622defa1d2e4869284a0c | [
"MIT"
] | null | null | null | app/src/main/java/com/voicecloningmobileapp/SlideAdapter.java | VladAIacob/VoiceCloningMobileApp | ffd4035253e444c295b622defa1d2e4869284a0c | [
"MIT"
] | null | null | null | app/src/main/java/com/voicecloningmobileapp/SlideAdapter.java | VladAIacob/VoiceCloningMobileApp | ffd4035253e444c295b622defa1d2e4869284a0c | [
"MIT"
] | null | null | null | 24.929825 | 95 | 0.710063 | 3,319 | package com.voicecloningmobileapp;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;
public class SlideAdapter extends PagerAdapter
{
private Context context;
LayoutInflater inflater;
public int[] images;
public SlideAdapter(Context context)
{
this.context = context;
}
@Override
public int getCount()
{
return images.length;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object)
{
return view == (LinearLayout)object;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position)
{
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.slideshow_layout, container, false);
ImageView image = (ImageView) view.findViewById(R.id.imageView);
image.setImageResource(images[position]);
container.addView(view);
return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object)
{
container.removeView((LinearLayout)object);
}
}
|
3e07dab871f08a99833c3c766e52dba56661c69b | 2,254 | java | Java | tests/activities/interactivespaces.test.activity.routable.RouteScale.Master/src/main/java/interactivespace/test/activity/routable/RouteScale/Master/RouteMasterTest.java | OmArMouNir/interactive-spaces | e260a991a4c1d5696e58427589d5ca3e7268b678 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2016-06-16T22:48:20.000Z | 2016-06-16T22:48:20.000Z | tests/activities/interactivespaces.test.activity.routable.RouteScale.Master/src/main/java/interactivespace/test/activity/routable/RouteScale/Master/RouteMasterTest.java | wlstks7/interactive-spaces | e260a991a4c1d5696e58427589d5ca3e7268b678 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | tests/activities/interactivespaces.test.activity.routable.RouteScale.Master/src/main/java/interactivespace/test/activity/routable/RouteScale/Master/RouteMasterTest.java | wlstks7/interactive-spaces | e260a991a4c1d5696e58427589d5ca3e7268b678 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | 30.459459 | 100 | 0.718722 | 3,320 | package interactivespace.test.activity.routable.RouteScale.Master;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import interactivespaces.activity.impl.ros.BaseRoutableRosActivity;
/**
* A simple Interactive Spaces Java-based activity.
*/
public class RouteMasterTest extends BaseRoutableRosActivity {
private Map<String, Object> data;
@Override
public void onActivitySetup() {
getLog().info("Activity interactivespace.test.activity.routable.RouteScale.Master setup");
}
@Override
public void onActivityStartup() {
data = Maps.newHashMap();
int dataSize = getConfiguration().getPropertyInteger("space.activity.dataSize", 1000);
for (int i = 0; i < dataSize; i++) {
data.put(String.valueOf(i), "test");
}
getLog().info("Activity interactivespace.test.activity.routable.RouteScale.Master startup");
}
@Override
public void onActivityActivate() {
getLog().info("Activity interactivespace.test.activity.routable.RouteScale.Master activate");
int delay = getConfiguration().getPropertyInteger("space.activity.dataRate", 1000);
getLog().info(delay);
getManagedCommands().scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
sendOnRoutes();
}
}, 1000, delay, TimeUnit.MILLISECONDS);
// On activiation, we will schedule a command to send on all our routes
}
private void sendOnRoutes() {
getLog().info("sending data on routes");
int numRoutes = getConfiguration().getPropertyInteger("space.activity.numRoutes", 19);
for (int i = 0; i < numRoutes; i++) {
getLog().info("sending on " + String.valueOf(i+1));
sendOutputJson("out" + String.valueOf(i+1), data);
}
getLog().info("done sending on routes");
}
@Override
public void onActivityDeactivate() {
getLog().info("Activity interactivespace.test.activity.routable.RouteScale.Master deactivate");
}
@Override
public void onActivityShutdown() {
getLog().info("Activity interactivespace.test.activity.routable.RouteScale.Master shutdown");
}
@Override
public void onActivityCleanup() {
getLog().info("Activity interactivespace.test.activity.routable.RouteScale.Master cleanup");
}
}
|
3e07dbb467aaa84fbf4dfe5cde7237dd4a4d5215 | 4,443 | java | Java | corpus/class/eclipse.pde.ui/1418.java | masud-technope/ACER-Replication-Package-ASE2017 | cb7318a729eb1403004d451a164c851af2d81f7a | [
"MIT"
] | 15 | 2018-07-10T09:38:31.000Z | 2021-11-29T08:28:07.000Z | corpus/class/eclipse.pde.ui/1418.java | masud-technope/ACER-Replication-Package-ASE2017 | cb7318a729eb1403004d451a164c851af2d81f7a | [
"MIT"
] | 3 | 2018-11-16T02:58:59.000Z | 2021-01-20T16:03:51.000Z | corpus/class/eclipse.pde.ui/1418.java | masud-technope/ACER-Replication-Package-ASE2017 | cb7318a729eb1403004d451a164c851af2d81f7a | [
"MIT"
] | 6 | 2018-06-27T20:19:00.000Z | 2022-02-19T02:29:53.000Z | 32.669118 | 82 | 0.687373 | 3,321 | /*******************************************************************************
* Copyright (c) 2009, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.pde.api.tools.internal.provisional.search;
import org.eclipse.pde.api.tools.internal.provisional.builder.IReference;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiMember;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiScope;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
/**
* A default search requestor to use for API tools
*
* @since 1.0.0
*/
public interface IApiSearchRequestor {
/**
* Search mask that will cause the engine to consider API references when
* searching
*
* @see #includesApi()
*/
public static final int INCLUDE_API = 0x0001;
/**
* Search mask that will cause the engine to consider internal references
* when searching
*
* @see #includesInternal()
*/
public static final int INCLUDE_INTERNAL = 0x0002;
/**
* Search mask that will cause the engine to consider illegal API use when
* searching
*/
public static final int INCLUDE_ILLEGAL_USE = 0x0004;
/**
* Returns the {@link IApiScope} to be searched
*
* @return the {@link IApiScope} to be searched
*/
public IApiScope getScope();
/**
* Returns whether this requestor cares about the given
* {@link IApiComponent} or not. This allows the requestor to direct the
* {@link ApiSearchEngine} to ignore certain components.
*
* @param component the component to examine
* @return true if this requestor cares about the given
* {@link IApiComponent}, false otherwise.
*/
public boolean acceptComponent(IApiComponent component);
/**
* Returns whether this requestor cares about the given
* {@link IApiTypeContainer} or not. This allows the requestor to direct the
* {@link ApiSearchEngine} to ignore certain type containers while searching
* a component
*
* @param container
* @return true if this requestor cares about the given
* {@link IApiTypeContainer} false otherwise.
*/
public boolean acceptContainer(IApiTypeContainer container);
/**
* Returns whether this requestor cares about the given {@link IApiMember}
* or not. This allows the requestor to direct the {@link ApiSearchEngine}
* to ignore certain members.
*
* @param member the member to examine
* @return true if this requestor cares about the given {@link IApiMember},
* false otherwise
*/
public boolean acceptMember(IApiMember member);
/**
* Returns whether the given {@link IReference} should be accepted by this
* requestor.
*
* @param reference
* @return true if the reference should be accepted, false otherwise
*/
public boolean acceptReference(IReference reference);
/**
* Returns the or'd listing of {@link IReference} kinds to look for.
*
* @see org.eclipse.pde.api.tools.internal.provisional.builder.ReferenceModifiers
* for a complete listing of reference kinds
*
* @return the listing of {@link IReference} kinds to consider during the
* search this requestor is used for.
*/
public int getReferenceKinds();
/**
* Returns true if the current search mask includes considering references
* to API elements.
*
* @return true if references to API elements should be considered, false
* otherwise
*/
public boolean includesAPI();
/**
* Returns true if the current search mask includes considering references
* to internal elements.
*
* @return true if reference to internal elements should be considered,
* false otherwise
*/
public boolean includesInternal();
/**
* Returns true if the current search mask includes considering illegal API
* use.
*
* @return true if references to illegal API use should be considered, false
* otherwise
*/
public boolean includesIllegalUse();
}
|
3e07dbbacf06e4472b4f40948435018850f5cad8 | 4,071 | java | Java | mica-mqtt-spring-boot-starter/src/main/java/net/dreamlu/iot/mqtt/spring/server/MqttServerTemplate.java | lets-mica/mica-mq | 0070cc38ced9e4ef2ab95c7e015bafc1e49c748e | [
"Apache-2.0"
] | 81 | 2020-09-14T02:42:11.000Z | 2022-03-30T14:51:47.000Z | mica-mqtt-spring-boot-starter/src/main/java/net/dreamlu/iot/mqtt/spring/server/MqttServerTemplate.java | lets-mica/mica-mq | 0070cc38ced9e4ef2ab95c7e015bafc1e49c748e | [
"Apache-2.0"
] | null | null | null | mica-mqtt-spring-boot-starter/src/main/java/net/dreamlu/iot/mqtt/spring/server/MqttServerTemplate.java | lets-mica/mica-mq | 0070cc38ced9e4ef2ab95c7e015bafc1e49c748e | [
"Apache-2.0"
] | 14 | 2020-09-17T02:35:24.000Z | 2022-03-28T08:56:18.000Z | 23.941176 | 129 | 0.696069 | 3,322 | /*
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (kenaa@example.com & dreamlu.net).
*
* 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.dreamlu.iot.mqtt.spring.server;
import lombok.RequiredArgsConstructor;
import net.dreamlu.iot.mqtt.codec.MqttQoS;
import net.dreamlu.iot.mqtt.core.server.MqttServer;
import org.tio.core.ChannelContext;
import java.nio.ByteBuffer;
/**
* mqtt Server 模板
*
* @author wsq(冷月宫主)
*/
@RequiredArgsConstructor
public class MqttServerTemplate {
private final MqttServer mqttServer;
/**
* 发布消息
*
* @param clientId clientId
* @param topic topic
* @param payload 消息体
* @return 是否发送成功
*/
public boolean publish(String clientId, String topic, ByteBuffer payload) {
return mqttServer.publish(clientId, topic, payload);
}
/**
* 发布消息
*
* @param clientId clientId
* @param topic topic
* @param payload 消息体
* @param qos MqttQoS
* @return 是否发送成功
*/
public boolean publish(String clientId, String topic, ByteBuffer payload, MqttQoS qos) {
return mqttServer.publish(clientId, topic, payload, qos);
}
/**
* 发布消息
*
* @param clientId clientId
* @param topic topic
* @param payload 消息体
* @param retain 是否在服务器上保留消息
* @return 是否发送成功
*/
public boolean publish(String clientId, String topic, ByteBuffer payload, boolean retain) {
return mqttServer.publish(clientId, topic, payload, retain);
}
/**
* 发布消息
*
* @param clientId clientId
* @param topic topic
* @param payload 消息体
* @param qos MqttQoS
* @param retain 是否在服务器上保留消息
* @return 是否发送成功
*/
public boolean publish(String clientId, String topic, ByteBuffer payload, MqttQoS qos, boolean retain) {
return mqttServer.publish(clientId, topic, payload, qos, retain);
}
/**
* 发布消息
*
* @param context ChannelContext
* @param clientId clientId
* @param topic topic
* @param payload 消息体
* @param qos MqttQoS
* @param retain 是否在服务器上保留消息
* @return 是否发送成功
*/
public boolean publish(ChannelContext context, String clientId, String topic, ByteBuffer payload, MqttQoS qos, boolean retain) {
return mqttServer.publish(context, clientId, topic, payload, qos, retain);
}
/**
* 发布消息给所以的在线设备
*
* @param topic topic
* @param payload 消息体
* @return 是否发送成功
*/
public boolean publishAll(String topic, ByteBuffer payload) {
return mqttServer.publishAll(topic, payload);
}
/**
* 发布消息
*
* @param topic topic
* @param payload 消息体
* @param qos MqttQoS
* @return 是否发送成功
*/
public boolean publishAll(String topic, ByteBuffer payload, MqttQoS qos) {
return mqttServer.publishAll(topic, payload, qos);
}
/**
* 发布消息给所以的在线设备
*
* @param topic topic
* @param payload 消息体
* @param retain 是否在服务器上保留消息
* @return 是否发送成功
*/
public boolean publishAll(String topic, ByteBuffer payload, boolean retain) {
return mqttServer.publishAll(topic, payload, retain);
}
/**
* 发布消息给所以的在线设备
*
* @param topic topic
* @param payload 消息体
* @param qos MqttQoS
* @param retain 是否在服务器上保留消息
* @return 是否发送成功
*/
public boolean publishAll(String topic, ByteBuffer payload, MqttQoS qos, boolean retain) {
return mqttServer.publishAll(topic, payload, qos, retain);
}
/**
* 获取 ChannelContext
*
* @param clientId clientId
* @return ChannelContext
*/
public ChannelContext getChannelContext(String clientId) {
return mqttServer.getChannelContext(clientId);
}
/**
* 服务端主动断开连接
*
* @param clientId clientId
*/
public void close(String clientId) {
mqttServer.close(clientId);
}
}
|
3e07dbcf96569bbc3e7824ce6a1be3206674c160 | 1,833 | java | Java | TeamCode/src/main/java/hortonvillerobotics/FileUtils.java | hortonvilleroboticssamm/UltimateGoal2020 | 3520e811b5faa5f90fcf77aeb96aee6c6e318d3e | [
"MIT"
] | 1 | 2021-09-12T17:37:12.000Z | 2021-09-12T17:37:12.000Z | TeamCode/src/main/java/hortonvillerobotics/FileUtils.java | ritahortonvillerobotics/UltimateGoal2020 | 3520e811b5faa5f90fcf77aeb96aee6c6e318d3e | [
"MIT"
] | null | null | null | TeamCode/src/main/java/hortonvillerobotics/FileUtils.java | ritahortonvillerobotics/UltimateGoal2020 | 3520e811b5faa5f90fcf77aeb96aee6c6e318d3e | [
"MIT"
] | null | null | null | 31.603448 | 102 | 0.590289 | 3,323 | package hortonvillerobotics;
import android.os.Environment;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public class FileUtils {
public static void writeToFile(String fileName, Object contents){
try {
File f = new File(Environment.getExternalStorageDirectory() + fileName);
checkFileExistence(f);
OutputStream o = new FileOutputStream(f,false);
o.write(contents instanceof byte[] ? (byte[])contents : contents.toString().getBytes());
o.flush();
o.close();
}catch(Exception e){e.printStackTrace();}
}
public static void appendToFile(String fileName, Object contents){
try{
File f = new File(Environment.getExternalStorageDirectory() + fileName);
checkFileExistence(f);
OutputStream o = new FileOutputStream(f, true);
byte[] b = contents instanceof byte[] ? (byte[])contents : contents.toString().getBytes();
o.write(b);
o.flush();
o.close();
}catch(Exception e){e.printStackTrace();}
}
public static byte[] readFromFile(String fileName){
try{
File f = new File(Environment.getExternalStorageDirectory() + fileName);
checkFileExistence(f);
InputStream i = new FileInputStream(f);
byte[] b = new byte[(int)f.length()];
i.read(b);
return b;
}catch (Exception e) {
e.printStackTrace();
}
return null;
}
private static void checkFileExistence(File f){
try{
if(!f.exists()){
f.createNewFile();
}
}catch(Exception e){e.printStackTrace();}
}
}
|
3e07dc4812ae08406b9c2fd969c856753930f26d | 9,812 | java | Java | modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBConnectionInfo.java | smarthealth/cayenne | 444df33111c9bc30165275ed46137ef3c2daf34c | [
"Apache-2.0"
] | 289 | 2015-01-28T13:35:27.000Z | 2022-03-27T07:51:03.000Z | modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBConnectionInfo.java | smarthealth/cayenne | 444df33111c9bc30165275ed46137ef3c2daf34c | [
"Apache-2.0"
] | 78 | 2015-01-05T19:28:33.000Z | 2022-02-01T13:53:11.000Z | modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBConnectionInfo.java | hanie21/cayenne | 592ecfb41b756cedcc4c3fe54d31773e557860a6 | [
"Apache-2.0"
] | 150 | 2015-01-15T08:13:55.000Z | 2022-03-19T19:42:16.000Z | 29.914634 | 94 | 0.72768 | 3,324 | /*****************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
*
* https://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 org.apache.cayenne.modeler.pref;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.prefs.Preferences;
import javax.sql.DataSource;
import org.apache.cayenne.configuration.server.DbAdapterFactory;
import org.apache.cayenne.conn.DataSourceInfo;
import org.apache.cayenne.datasource.DriverDataSource;
import org.apache.cayenne.dba.AutoAdapter;
import org.apache.cayenne.dba.DbAdapter;
import org.apache.cayenne.di.AdhocObjectFactory;
import org.apache.cayenne.modeler.Application;
import org.apache.cayenne.modeler.ClassLoadingService;
import org.apache.cayenne.pref.CayennePreference;
import org.apache.cayenne.util.Util;
public class DBConnectionInfo extends CayennePreference {
private static final String EMPTY_STRING = "";
public static final String DB_ADAPTER_PROPERTY = "dbAdapter";
public static final String JDBC_DRIVER_PROPERTY = "jdbcDriver";
public static final String PASSWORD_PROPERTY = "password";
public static final String URL_PROPERTY = "url";
public static final String USER_NAME_PROPERTY = "userName";
private static final String DB_CONNECTION_INFO = "dbConnectionInfo";
public static final String ID_PK_COLUMN = "id";
private String nodeName;
private String dbAdapter;
private String jdbcDriver;
private String password;
private String url;
private String userName;
private Preferences dbConnectionInfoPreferences;
public DBConnectionInfo() {
dbConnectionInfoPreferences = getCayennePreference().node(DB_CONNECTION_INFO);
setCurrentPreference(dbConnectionInfoPreferences);
};
public DBConnectionInfo(final String nameNode, final boolean initFromPreferences) {
this();
setNodeName(nameNode);
if (initFromPreferences) {
initObjectPreference();
}
};
@Override
public Preferences getCurrentPreference() {
if (getNodeName() == null) {
return super.getCurrentPreference();
}
return dbConnectionInfoPreferences.node(getNodeName());
}
@Override
public void setObject(final CayennePreference object) {
if (object instanceof DBConnectionInfo) {
setUrl(((DBConnectionInfo) object).getUrl());
setUserName(((DBConnectionInfo) object).getUserName());
setPassword(((DBConnectionInfo) object).getPassword());
setJdbcDriver(((DBConnectionInfo) object).getJdbcDriver());
setDbAdapter(((DBConnectionInfo) object).getDbAdapter());
}
}
@Override
public void saveObjectPreference() {
if (getCurrentPreference() != null) {
if (getDbAdapter() != null) {
getCurrentPreference().put(DB_ADAPTER_PROPERTY, getDbAdapter());
}
if (getUrl() != null) {
getCurrentPreference().put(URL_PROPERTY, getUrl());
}
if (getUserName() != null) {
getCurrentPreference().put(USER_NAME_PROPERTY, getUserName());
}
if (getPassword() != null) {
getCurrentPreference().put(PASSWORD_PROPERTY, getPassword());
}
if (getJdbcDriver() != null) {
getCurrentPreference().put(JDBC_DRIVER_PROPERTY, getJdbcDriver());
}
}
}
public void initObjectPreference() {
if (getCurrentPreference() != null) {
setDbAdapter(getCurrentPreference().get(DB_ADAPTER_PROPERTY, null));
setUrl(getCurrentPreference().get(URL_PROPERTY, null));
setUserName(getCurrentPreference().get(USER_NAME_PROPERTY, null));
setPassword(getCurrentPreference().get(PASSWORD_PROPERTY, null));
setJdbcDriver(getCurrentPreference().get(JDBC_DRIVER_PROPERTY, null));
setNodeName(getCurrentPreference().name());
}
}
public String getNodeName() {
return nodeName;
}
public void setNodeName(final String nodeName) {
this.nodeName = nodeName;
}
public String getDbAdapter() {
return dbAdapter;
}
public void setDbAdapter(final String dbAdapter) {
this.dbAdapter = dbAdapter;
}
public String getJdbcDriver() {
return jdbcDriver;
}
public void setJdbcDriver(final String jdbcDriver) {
this.jdbcDriver = jdbcDriver;
}
public String getPassword() {
return password == null ? EMPTY_STRING : password;
}
public void setPassword(final String password) {
this.password = password;
}
public String getUrl() {
return url;
}
public void setUrl(final String url) {
this.url = url;
}
public String getUserName() {
return userName == null ? EMPTY_STRING : userName;
}
public void setUserName(final String userName) {
this.userName = userName;
}
public Preferences getDbConnectionInfoPreferences() {
return dbConnectionInfoPreferences;
}
public void setDbConnectionInfoPreferences(final Preferences dbConnectionInfoPreferences) {
this.dbConnectionInfoPreferences = dbConnectionInfoPreferences;
}
/**
* Creates a DbAdapter based on configured values.
*/
public DbAdapter makeAdapter(final ClassLoadingService classLoader) throws Exception {
String adapterClassName = getDbAdapter();
Application appInstance = Application.getInstance();
if (adapterClassName == null || AutoAdapter.class.getName().equals(adapterClassName)) {
return appInstance.getInjector().getInstance(DbAdapterFactory.class)
.createAdapter(null, makeDataSource(classLoader));
}
try {
return appInstance.getInjector().getInstance(AdhocObjectFactory.class)
.newInstance(DbAdapter.class, adapterClassName);
} catch (Throwable th) {
th = Util.unwindException(th);
throw new Exception("DbAdapter load error: " + th.getLocalizedMessage());
}
}
/**
* Returns a DataSource that uses connection information from this object.
* Returned DataSource is not pooling its connections. It can be wrapped in
* PoolManager if pooling is needed.
*/
public DataSource makeDataSource(final ClassLoadingService classLoader) throws SQLException {
// validate...
if (getJdbcDriver() == null) {
throw new SQLException("No JDBC driver set.");
}
if (getUrl() == null) {
throw new SQLException("No DB URL set.");
}
if (!Util.isBlank(getPassword()) && Util.isBlank(getUserName())) {
throw new SQLException("No username when password is set.");
}
// load driver...
Driver driver;
try {
driver = classLoader.loadClass(Driver.class, getJdbcDriver()).newInstance();
} catch (Throwable th) {
th = Util.unwindException(th);
throw new SQLException("Driver load error: " + th.getLocalizedMessage());
}
return new DriverDataSource(driver, getUrl(), getUserName(), getPassword());
}
/**
* Updates another DBConnectionInfo with this object's values.
*/
public boolean copyTo(final DBConnectionInfo dataSourceInfo) {
boolean updated = false;
if (!Util.nullSafeEquals(dataSourceInfo.getUrl(), getUrl())) {
dataSourceInfo.setUrl(getUrl());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getUserName(), getUserName())) {
dataSourceInfo.setUserName(getUserName());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getPassword(), getPassword())) {
dataSourceInfo.setPassword(getPassword());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getJdbcDriver(), getJdbcDriver())) {
dataSourceInfo.setJdbcDriver(getJdbcDriver());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getDbAdapter(), getDbAdapter())) {
dataSourceInfo.setDbAdapter(getDbAdapter());
updated = true;
}
return updated;
}
/**
* Updates DataSourceInfo with this object's values.
* <p>
* <i>Currently doesn't set the adapter property. Need to change the UI to
* handle adapter via DataSourceInfo first, and then it should be safe to do
* an adapter update here. </i>
* </p>
*/
public boolean copyTo(final DataSourceInfo dataSourceInfo) {
boolean updated = false;
if (!Util.nullSafeEquals(dataSourceInfo.getDataSourceUrl(), getUrl())) {
dataSourceInfo.setDataSourceUrl(getUrl());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getUserName(), getUserName())) {
dataSourceInfo.setUserName(getUserName());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getPassword(), getPassword())) {
dataSourceInfo.setPassword(getPassword());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getJdbcDriver(), getJdbcDriver())) {
dataSourceInfo.setJdbcDriver(getJdbcDriver());
updated = true;
}
return updated;
}
public boolean copyFrom(final DataSourceInfo dataSourceInfo) {
boolean updated = false;
if (!Util.nullSafeEquals(dataSourceInfo.getDataSourceUrl(), getUrl())) {
setUrl(dataSourceInfo.getDataSourceUrl());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getUserName(), getUserName())) {
setUserName(dataSourceInfo.getUserName());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getPassword(), getPassword())) {
setPassword(dataSourceInfo.getPassword());
updated = true;
}
if (!Util.nullSafeEquals(dataSourceInfo.getJdbcDriver(), getJdbcDriver())) {
setJdbcDriver(dataSourceInfo.getJdbcDriver());
updated = true;
}
return updated;
}
} |
3e07dc663351f68840e88e03fc61e24410edc970 | 2,402 | java | Java | smartdoc-oas/src/main/java/io/swagger/v3/oas/models/parameters/PathParameter.java | Open-source-sharing/REST-doc | 30c02524454d4203812d246d05837d4c149fcd03 | [
"Apache-2.0"
] | 2 | 2020-09-21T12:21:37.000Z | 2020-09-24T11:45:24.000Z | smartdoc-oas/src/main/java/io/swagger/v3/oas/models/parameters/PathParameter.java | Open-source-sharing/rest-doc | 30c02524454d4203812d246d05837d4c149fcd03 | [
"Apache-2.0"
] | 30 | 2020-09-13T12:03:41.000Z | 2021-01-26T04:35:21.000Z | smartdoc-oas/src/main/java/io/swagger/v3/oas/models/parameters/PathParameter.java | Open-source-sharing/rest-doc | 30c02524454d4203812d246d05837d4c149fcd03 | [
"Apache-2.0"
] | 2 | 2020-12-18T04:33:16.000Z | 2021-04-11T06:29:11.000Z | 25.284211 | 99 | 0.665279 | 3,325 | /**
* Copyright 2017 SmartBear Software
*
* <p>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
*
* <p>http://www.apache.org/licenses/LICENSE-2.0
*
* <p>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 io.swagger.v3.oas.models.parameters;
import java.util.Objects;
/** PathParameter */
public class PathParameter extends Parameter {
private String in = "path";
private Boolean required = true;
/**
* returns the in property from a PathParameter instance.
*
* @return String in
*/
@Override
public String getIn() {
return in;
}
@Override
public void setIn(String in) {
this.in = in;
}
@Override
public PathParameter in(String in) {
this.in = in;
return this;
}
/**
* returns the required property from a PathParameter instance.
*
* @return Boolean required
*/
@Override
public Boolean getRequired() {
return required;
}
@Override
public void setRequired(Boolean required) {
this.required = required;
}
@Override
public PathParameter required(Boolean required) {
this.required = required;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
PathParameter pathParameter = (PathParameter) o;
return Objects.equals(this.in, pathParameter.in)
&& Objects.equals(this.required, pathParameter.required)
&& super.equals(o);
}
@Override
public int hashCode() {
return Objects.hash(in, required, super.hashCode());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class PathParameter {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" in: ").append(toIndentedString(in)).append("\n");
sb.append(" required: ").append(toIndentedString(required)).append("\n");
sb.append("}");
return sb.toString();
}
}
|
3e07dd5abbbbd0b371e003db46d097eda65a6654 | 6,457 | java | Java | log/src/test/java/org/apache/karaf/log/core/internal/LogServiceLog4j2ImplTest.java | sho25/karaf | 95110009181760c3e7ef86e96834a763899962db | [
"Apache-2.0"
] | null | null | null | log/src/test/java/org/apache/karaf/log/core/internal/LogServiceLog4j2ImplTest.java | sho25/karaf | 95110009181760c3e7ef86e96834a763899962db | [
"Apache-2.0"
] | null | null | null | log/src/test/java/org/apache/karaf/log/core/internal/LogServiceLog4j2ImplTest.java | sho25/karaf | 95110009181760c3e7ef86e96834a763899962db | [
"Apache-2.0"
] | null | null | null | 15.74878 | 810 | 0.809354 | 3,326 | begin_unit|revision:0.9.5;language:Java;cregit-version:0.0.1
begin_comment
comment|/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */
end_comment
begin_package
package|package
name|org
operator|.
name|apache
operator|.
name|karaf
operator|.
name|log
operator|.
name|core
operator|.
name|internal
package|;
end_package
begin_import
import|import
name|org
operator|.
name|junit
operator|.
name|Test
import|;
end_import
begin_import
import|import
name|java
operator|.
name|util
operator|.
name|Dictionary
import|;
end_import
begin_import
import|import
name|java
operator|.
name|util
operator|.
name|Hashtable
import|;
end_import
begin_import
import|import static
name|org
operator|.
name|hamcrest
operator|.
name|Matchers
operator|.
name|hasEntry
import|;
end_import
begin_import
import|import static
name|org
operator|.
name|junit
operator|.
name|Assert
operator|.
name|assertThat
import|;
end_import
begin_class
specifier|public
class|class
name|LogServiceLog4j2ImplTest
block|{
specifier|private
specifier|static
specifier|final
name|String
name|ROOT_LOGGER
init|=
literal|"log4j.rootLogger"
decl_stmt|;
specifier|private
specifier|static
specifier|final
name|String
name|LOGGER_PREFIX
init|=
literal|"log4j2.logger."
decl_stmt|;
specifier|private
specifier|static
specifier|final
name|String
name|NAME_SUFFIX
init|=
literal|".name"
decl_stmt|;
specifier|private
specifier|static
specifier|final
name|String
name|LEVEL_SUFFIX
init|=
literal|".level"
decl_stmt|;
annotation|@
name|Test
specifier|public
name|void
name|testLoggerNameWithNumbers
parameter_list|()
block|{
specifier|final
name|String
name|name
init|=
literal|"some_logger_name"
decl_stmt|;
specifier|final
name|String
name|logger
init|=
literal|"org.ops4j.pax.web"
decl_stmt|;
specifier|final
name|String
name|level
init|=
literal|"WARN"
decl_stmt|;
specifier|final
name|Dictionary
argument_list|<
name|String
argument_list|,
name|Object
argument_list|>
name|config
init|=
operator|new
name|Hashtable
argument_list|<>
argument_list|()
decl_stmt|;
name|config
operator|.
name|put
argument_list|(
name|ROOT_LOGGER
argument_list|,
literal|"INFO"
argument_list|)
expr_stmt|;
name|config
operator|.
name|put
argument_list|(
name|LOGGER_PREFIX
operator|+
name|name
operator|+
name|NAME_SUFFIX
argument_list|,
name|logger
argument_list|)
expr_stmt|;
name|config
operator|.
name|put
argument_list|(
name|LOGGER_PREFIX
operator|+
name|name
operator|+
name|LEVEL_SUFFIX
argument_list|,
name|level
argument_list|)
expr_stmt|;
specifier|final
name|LogServiceInternal
name|logServiceInternal
init|=
operator|new
name|LogServiceLog4j2Impl
argument_list|(
name|config
argument_list|)
decl_stmt|;
name|assertThat
argument_list|(
name|logServiceInternal
operator|.
name|getLevel
argument_list|(
name|logger
argument_list|)
argument_list|,
name|hasEntry
argument_list|(
name|logger
argument_list|,
name|level
argument_list|)
argument_list|)
expr_stmt|;
block|}
annotation|@
name|Test
specifier|public
name|void
name|testSetLevelForLoggerNameWithNumbers
parameter_list|()
block|{
specifier|final
name|String
name|logger
init|=
literal|"org.ops4j.pax.web"
decl_stmt|;
specifier|final
name|String
name|level
init|=
literal|"WARN"
decl_stmt|;
specifier|final
name|Dictionary
argument_list|<
name|String
argument_list|,
name|Object
argument_list|>
name|config
init|=
operator|new
name|Hashtable
argument_list|<>
argument_list|()
decl_stmt|;
name|config
operator|.
name|put
argument_list|(
name|ROOT_LOGGER
argument_list|,
literal|"INFO"
argument_list|)
expr_stmt|;
specifier|final
name|LogServiceInternal
name|logServiceInternal
init|=
operator|new
name|LogServiceLog4j2Impl
argument_list|(
name|config
argument_list|)
decl_stmt|;
name|logServiceInternal
operator|.
name|setLevel
argument_list|(
name|logger
argument_list|,
name|level
argument_list|)
expr_stmt|;
name|assertThat
argument_list|(
name|logServiceInternal
operator|.
name|getLevel
argument_list|(
name|logger
argument_list|)
argument_list|,
name|hasEntry
argument_list|(
name|logger
argument_list|,
name|level
argument_list|)
argument_list|)
expr_stmt|;
block|}
annotation|@
name|Test
specifier|public
name|void
name|testUpdateLevelForLoggerNameWithNumbers
parameter_list|()
block|{
specifier|final
name|String
name|name
init|=
literal|"some_logger_name"
decl_stmt|;
specifier|final
name|String
name|logger
init|=
literal|"org.ops4j.pax.web"
decl_stmt|;
specifier|final
name|Dictionary
argument_list|<
name|String
argument_list|,
name|Object
argument_list|>
name|config
init|=
operator|new
name|Hashtable
argument_list|<>
argument_list|()
decl_stmt|;
name|config
operator|.
name|put
argument_list|(
name|ROOT_LOGGER
argument_list|,
literal|"INFO"
argument_list|)
expr_stmt|;
name|config
operator|.
name|put
argument_list|(
name|LOGGER_PREFIX
operator|+
name|name
operator|+
name|NAME_SUFFIX
argument_list|,
name|logger
argument_list|)
expr_stmt|;
name|config
operator|.
name|put
argument_list|(
name|LOGGER_PREFIX
operator|+
name|name
operator|+
name|LEVEL_SUFFIX
argument_list|,
literal|"WARN"
argument_list|)
expr_stmt|;
specifier|final
name|LogServiceInternal
name|logServiceInternal
init|=
operator|new
name|LogServiceLog4j2Impl
argument_list|(
name|config
argument_list|)
decl_stmt|;
specifier|final
name|String
name|newLevel
init|=
literal|"TRACE"
decl_stmt|;
name|logServiceInternal
operator|.
name|setLevel
argument_list|(
name|logger
argument_list|,
name|newLevel
argument_list|)
expr_stmt|;
name|assertThat
argument_list|(
name|logServiceInternal
operator|.
name|getLevel
argument_list|(
name|logger
argument_list|)
argument_list|,
name|hasEntry
argument_list|(
name|logger
argument_list|,
name|newLevel
argument_list|)
argument_list|)
expr_stmt|;
block|}
block|}
end_class
end_unit
|
3e07de324c6a92a1559a192fe6a4a88a77786678 | 1,081 | java | Java | src/test/java/de/uniks/networkparser/test/FXMLConverter.java | fujaba/NetworkParser | d690c9bf664358e249897a226f595585736b4a35 | [
"MIT"
] | 9 | 2015-06-28T20:12:07.000Z | 2019-03-27T13:11:14.000Z | src/test/java/de/uniks/networkparser/test/FXMLConverter.java | fujaba/NetworkParser | d690c9bf664358e249897a226f595585736b4a35 | [
"MIT"
] | 15 | 2015-07-01T06:51:41.000Z | 2019-10-18T05:46:58.000Z | src/test/java/de/uniks/networkparser/test/FXMLConverter.java | fujaba/NetworkParser | d690c9bf664358e249897a226f595585736b4a35 | [
"MIT"
] | 6 | 2016-06-10T20:32:50.000Z | 2019-09-30T05:42:49.000Z | 36.033333 | 228 | 0.724329 | 3,327 | package de.uniks.networkparser.test;
import org.junit.Assert;
import org.junit.Test;
import de.uniks.networkparser.buffer.CharacterBuffer;
import de.uniks.networkparser.converter.GUIConverter;
import de.uniks.networkparser.ext.io.FileBuffer;
import de.uniks.networkparser.gui.controls.Control;
public class FXMLConverter {
@Test
public void convert() {
CharacterBuffer fxml = new FileBuffer().readResource("test/javafx/GroupAccount.fxml");
GUIConverter converter = new GUIConverter();
Control convert = converter.convert(fxml);
//<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1">
// <children>
// <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
// <children>
// <Label text="Counter:"/><Spinner/>
// </children></HBox>
// <Button mnemonicParsing="false" text="Click"/>
// <Label text="0"></Label></children></VBox>
Assert.assertNotNull(convert);
}
}
|
3e07dfe0b78eb7f9fbf9aa241e971e59bcb38b68 | 6,312 | java | Java | app/src/main/java/in/mjtech/libraries/DateTimePicker.java | bewithdhanu/DateTimePicker | 20f2d7199436b5ad97479783f5edd798ca1ebe2d | [
"MIT"
] | 3 | 2019-10-01T15:35:43.000Z | 2020-07-14T17:58:34.000Z | app/src/main/java/in/mjtech/libraries/DateTimePicker.java | bewithdhanu/DateTimePicker | 20f2d7199436b5ad97479783f5edd798ca1ebe2d | [
"MIT"
] | 1 | 2020-08-16T13:44:05.000Z | 2020-08-16T13:44:05.000Z | app/src/main/java/in/mjtech/libraries/DateTimePicker.java | bewithdhanu/DateTimePicker | 20f2d7199436b5ad97479783f5edd798ca1ebe2d | [
"MIT"
] | 1 | 2019-10-09T18:42:44.000Z | 2019-10-09T18:42:44.000Z | 42.08 | 217 | 0.592205 | 3,328 | package in.mjtech.libraries;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TimePicker;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class DateTimePicker extends android.support.v7.widget.AppCompatEditText implements View.OnClickListener {
int FORMAT = 0;
Context context;
public DateTimePicker(Context context) {
super(context);
this.context = context;
super.setOnClickListener(this);
super.setFocusable(false);
}
public DateTimePicker(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DateTimePicker);
FORMAT = a.getInteger(R.styleable.DateTimePicker_format, 0);
a.recycle();
this.context = context;
super.setOnClickListener(this);
super.setFocusable(false);
}
public DateTimePicker(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DateTimePicker);
FORMAT = a.getInteger(R.styleable.DateTimePicker_format, 0);
a.recycle();
this.context = context;
super.setOnClickListener(this);
super.setFocusable(false);
}
@Override
public void onClick(final View v) {
Calendar calendar = Calendar.getInstance();
final int mYear = calendar.get(Calendar.YEAR);
final int mMonth = calendar.get(Calendar.MONTH);
final int mDay = calendar.get(Calendar.DAY_OF_MONTH);
final int hour = calendar.get(Calendar.HOUR_OF_DAY);
final int minute = calendar.get(Calendar.MINUTE);
if (FORMAT == 1) {
DatePickerDialog datePickerDialog = new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datepicker, int year, int month, int day) {
month++;
int finalMonth = month;
String dateTime = new StringBuilder().append(day).append("-").append(finalMonth).append("-").append(year).toString();
try {
String dt = new SimpleDateFormat("dd-MM-yyyy").format(new SimpleDateFormat("d-M-yyyy", Locale.ENGLISH).parse(dateTime));
((EditText) v).setText(dt);
} catch (ParseException e) {
e.printStackTrace();
}
}
} ,mYear, mMonth, mDay);
datePickerDialog.show();
} else if (FORMAT == 2) {
TimePickerDialog timePickerDialog = new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute1) {
String dateTime = new StringBuilder().append(hourOfDay).append(":").append(minute1).append(":00").toString();
try {
String dt = new SimpleDateFormat("HH:mm:ss").format(new SimpleDateFormat("H:m:ss", Locale.ENGLISH).parse(dateTime));
((EditText) v).setText(dt);
} catch (ParseException e) {
e.printStackTrace();
}
}
}, hour, minute, true);
timePickerDialog.show();
} else {
DatePickerDialog datePickerDialog = new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker datepicker, final int year, int month, final int day) {
month++;
final int finalMonth = month;
TimePickerDialog timePickerDialog = new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute1) {
String dateTime = new StringBuilder().append(day).append("-").append(finalMonth).append("-").append(year).append(" ").append(hourOfDay).append(":").append(minute1).append(":00").toString();
try {
String dt = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new SimpleDateFormat("d-M-yyyy H:m:ss", Locale.ENGLISH).parse(dateTime));
((EditText) v).setText(dt);
} catch (ParseException e) {
e.printStackTrace();
}
}
}, hour, minute, true);
timePickerDialog.show();
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
}
}
public String getDate(String resultFormat) throws ParseException {
String existingFormat = "dd-MM-yyyy HH:mm:ss";
if (FORMAT == 1) {
existingFormat = "dd-MM-yyyy";
} else if (FORMAT == 2) {
existingFormat = "HH:mm:ss";
}
return new SimpleDateFormat(resultFormat).format(new SimpleDateFormat(existingFormat, Locale.ENGLISH).parse(this.getText().toString()));
}
public Date getDate() throws ParseException {
String existingFormat = "dd-MM-yyyy HH:mm:ss";
if (FORMAT == 1) {
existingFormat = "dd-MM-yyyy";
} else if (FORMAT == 2) {
existingFormat = "HH:mm:ss";
}
return new SimpleDateFormat(existingFormat, Locale.ENGLISH).parse(this.getText().toString());
}
@Override
public void setOnClickListener(@Nullable OnClickListener l) {
super.setOnClickListener(l);
}
public void setFormat(int f){
this.FORMAT=f;
}
public int getFormat(){
return this.FORMAT;
}
}
|
3e07dfe3dc6ec203a46aef054225de808b7bc9ca | 3,311 | java | Java | arrow/src/gen/java/org/bytedeco/parquet/ColumnDecryptionProperties.java | oxisto/javacpp-presets | a70841e089cbe4269cd3e1b1e6de2005c3b4aa16 | [
"Apache-2.0"
] | 2,132 | 2015-01-14T10:02:38.000Z | 2022-03-31T07:51:08.000Z | arrow/src/gen/java/org/bytedeco/parquet/ColumnDecryptionProperties.java | oxisto/javacpp-presets | a70841e089cbe4269cd3e1b1e6de2005c3b4aa16 | [
"Apache-2.0"
] | 1,024 | 2015-01-11T18:35:03.000Z | 2022-03-31T14:52:22.000Z | arrow/src/gen/java/org/bytedeco/parquet/ColumnDecryptionProperties.java | oxisto/javacpp-presets | a70841e089cbe4269cd3e1b1e6de2005c3b4aa16 | [
"Apache-2.0"
] | 759 | 2015-01-15T08:41:48.000Z | 2022-03-29T17:05:57.000Z | 44.146667 | 126 | 0.739052 | 3,329 | // Targeted by JavaCPP version 1.5.7-SNAPSHOT: DO NOT EDIT THIS FILE
package org.bytedeco.parquet;
import java.nio.*;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
import static org.bytedeco.javacpp.presets.javacpp.*;
import org.bytedeco.arrow.*;
import static org.bytedeco.arrow.global.arrow.*;
import static org.bytedeco.arrow.global.parquet.*;
@Namespace("parquet") @NoOffset @Properties(inherit = org.bytedeco.arrow.presets.parquet.class)
public class ColumnDecryptionProperties extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public ColumnDecryptionProperties(Pointer p) { super(p); }
/** Native array allocator. Access with {@link Pointer#position(long)}. */
public ColumnDecryptionProperties(long size) { super((Pointer)null); allocateArray(size); }
private native void allocateArray(long size);
@Override public ColumnDecryptionProperties position(long position) {
return (ColumnDecryptionProperties)super.position(position);
}
@Override public ColumnDecryptionProperties getPointer(long i) {
return new ColumnDecryptionProperties((Pointer)this).offsetAddress(i);
}
@NoOffset public static class Builder extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public Builder(Pointer p) { super(p); }
public Builder(@StdString String name) { super((Pointer)null); allocate(name); }
private native void allocate(@StdString String name);
public Builder(@StdString BytePointer name) { super((Pointer)null); allocate(name); }
private native void allocate(@StdString BytePointer name);
public Builder(@SharedPtr ColumnPath path) { super((Pointer)null); allocate(path); }
private native void allocate(@SharedPtr ColumnPath path);
/** Set an explicit column key. If applied on a file that contains
* key metadata for this column the metadata will be ignored,
* the column will be decrypted with this key.
* key length must be either 16, 24 or 32 bytes. */
public native Builder key(@StdString String key);
public native Builder key(@StdString BytePointer key);
public native @SharedPtr @ByVal ColumnDecryptionProperties build();
}
public ColumnDecryptionProperties() { super((Pointer)null); allocate(); }
private native void allocate();
public ColumnDecryptionProperties(@Const @ByRef ColumnDecryptionProperties other) { super((Pointer)null); allocate(other); }
private native void allocate(@Const @ByRef ColumnDecryptionProperties other);
public native @StdString String column_path();
public native @StdString String key();
public native @Cast("bool") boolean is_utilized();
/** ColumnDecryptionProperties object can be used for reading one file only.
* Mark ColumnDecryptionProperties as utilized once it is used in
* FileDecryptionProperties as the encryption key will be wiped out upon
* completion of file reading. */
public native void set_utilized();
/** Upon completion of file reading, the encryption key
* will be wiped out. */
public native void WipeOutDecryptionKey();
public native @SharedPtr @ByVal ColumnDecryptionProperties DeepClone();
}
|
3e07e096eb8db275128af3164c8c6672d81a8e78 | 1,726 | java | Java | src/main/java/de/wiosense/webauthn/models/NoneAttestation.java | WIOsense/rauth-android | 5172bda5cdef9ff466cca95c800281b1b70663ff | [
"BSD-3-Clause"
] | 4 | 2020-10-27T23:17:35.000Z | 2021-11-17T09:00:58.000Z | src/main/java/de/wiosense/webauthn/models/NoneAttestation.java | WIOsense/rauth-android | 5172bda5cdef9ff466cca95c800281b1b70663ff | [
"BSD-3-Clause"
] | null | null | null | src/main/java/de/wiosense/webauthn/models/NoneAttestation.java | WIOsense/rauth-android | 5172bda5cdef9ff466cca95c800281b1b70663ff | [
"BSD-3-Clause"
] | 1 | 2021-07-21T09:20:40.000Z | 2021-07-21T09:20:40.000Z | 33.192308 | 84 | 0.632677 | 3,330 | package de.wiosense.webauthn.models;
import java.io.ByteArrayOutputStream;
import co.nstant.in.cbor.CborBuilder;
import co.nstant.in.cbor.CborEncoder;
import co.nstant.in.cbor.CborException;
import de.wiosense.webauthn.exceptions.VirgilException;
import de.wiosense.webauthn.fido.ctap2.Messages;
public class NoneAttestation extends AttestationObject {
/**
* Construct a new self-attestation attObj in packed format.
*
* @param authData The authenticator data.
*/
public NoneAttestation(byte[] authData) {
this.authData = authData;
this.fmt = FormatType.NONE;
this.signature = null;
this.certificate = null;
}
/**
* Encode this self-attestation attObj as the CBOR required by the WebAuthn spec
* https://www.w3.org/TR/webauthn/#sctn-attestation
* https://www.w3.org/TR/webauthn/#none-attestation
*
* @return CBOR encoding of the attestation object as a byte array
* @throws VirgilException
*/
@Override
public byte[] asCBOR() throws VirgilException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
new CborEncoder(baos).encode(new CborBuilder()
.addMap()
.put(Messages.MAKE_CREDENTIAL_RESPONSE_AUTH_DATA, this.authData)
.put(Messages.MAKE_CREDENTIAL_RESPONSE_FMT, this.fmt)
.putMap(Messages.MAKE_CREDENTIAL_RESPONSE_ATT_STMT)
.end()
.end()
.build()
);
} catch (CborException e) {
throw new VirgilException("couldn't serialize to cbor", e);
}
return baos.toByteArray();
}
}
|
3e07e0df52443833a1be45179be5c6b09cbba978 | 720 | java | Java | src/main/java/cmu/pasta/mu2/diff/guidance/DiffNoGuidance.java | cmu-pasta/mu2 | 391a2ddd97dd71aef71c683d2904985152cd3f48 | [
"MIT"
] | 7 | 2022-03-22T03:11:50.000Z | 2022-03-25T13:25:04.000Z | src/main/java/cmu/pasta/mu2/diff/guidance/DiffNoGuidance.java | cmu-pasta/mu2 | 391a2ddd97dd71aef71c683d2904985152cd3f48 | [
"MIT"
] | null | null | null | src/main/java/cmu/pasta/mu2/diff/guidance/DiffNoGuidance.java | cmu-pasta/mu2 | 391a2ddd97dd71aef71c683d2904985152cd3f48 | [
"MIT"
] | null | null | null | 27.692308 | 98 | 0.748611 | 3,331 | package cmu.pasta.mu2.diff.guidance;
import cmu.pasta.mu2.diff.junit.DiffTrialRunner;
import edu.berkeley.cs.jqf.fuzz.random.NoGuidance;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.TestClass;
import java.io.PrintStream;
import java.lang.reflect.Method;
public class DiffNoGuidance extends NoGuidance implements DiffGuidance {
public DiffNoGuidance(long maxTrials, PrintStream out) {
super(maxTrials, out);
}
@Override
public void setCompare(Method m) {
}
@Override
public void run(TestClass testClass, FrameworkMethod method, Object[] args) throws Throwable {
new DiffTrialRunner(testClass.getJavaClass(), method, args).run();
}
}
|
3e07e11eeeddb9b111078e4f284aba64f7df82c9 | 14,464 | java | Java | src/main/java/io/ous/jtoml/impl/Tokenizer.java | asafh/jtoml | 954caf117074b409561da3788759b86d0b0e8bdb | [
"Apache-2.0"
] | 12 | 2015-04-13T09:12:41.000Z | 2022-03-22T01:56:50.000Z | src/main/java/io/ous/jtoml/impl/Tokenizer.java | asafh/jtoml | 954caf117074b409561da3788759b86d0b0e8bdb | [
"Apache-2.0"
] | 4 | 2015-02-07T09:43:13.000Z | 2020-04-14T14:19:40.000Z | src/main/java/io/ous/jtoml/impl/Tokenizer.java | asafh/jtoml | 954caf117074b409561da3788759b86d0b0e8bdb | [
"Apache-2.0"
] | 1 | 2021-12-30T02:38:25.000Z | 2021-12-30T02:38:25.000Z | 32.947608 | 165 | 0.522954 | 3,332 | package io.ous.jtoml.impl;
import io.ous.jtoml.ParseException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created with IntelliJ IDEA.
* User: Asafh
* DateConstant: 01/03/15
* Time: 21:22
* To change this template use File | Settings | File Templates.
*/
class Tokenizer {
private static final String BREAK_LINE = System.getProperty("line.separator");
private static final String LITERAL_MULTILINE_STRING_DELIMITER = "\'\'\'";
private static final char LITERAL_STRING_DELIMITER = '\'';
private static final String MULTILINE_STRING_DELIMITER = "\"\"\"";
private static final char BASIC_STRING_DELIMITER = '\"';
private static final char COMMENT_START = '#';
private final BufferedReader reader;
public static Tokenizer parse(Reader reader) throws IOException {
return new Tokenizer(reader);
}
private static BufferedReader buffer(Reader reader) {
return (BufferedReader) (reader instanceof BufferedReader ? reader : new BufferedReader(reader));
}
static class ParsedToken {
final Token token;
final int line;
final int chars;
ParsedToken(Token token, int line, int chars) {
this.token = token;
this.line = line;
this.chars = chars;
}
@Override
public String toString() {
return token.getType() + " at " + this.line+":"+this.chars+" "+token;
}
}
/**
* 1979-05-27T07:32:00Z
1979-05-27T00:32:00-07:00
1979-05-27T00:32:00.999999-07:00
*/
private static final Pattern DATE_PATTERN = Pattern.compile("^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})(\\.(\\d{1,6}))?(Z|-\\d{2}:\\d{2})");
private static final int DATE_PATTERN_GROUP_DATETIME = 1;
private static final int DATE_PATTERN_GROUP_FRACTION = 3;
private static final int DATE_PATTERN_GROUP_TZ = 4;
private static final int DATE_FRACTION_PERCISION = 6;
private static final int DATE_FRACTION_MAX = 1000000;
private static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
/**
* # fractional
+1.0
3.1415
-0.01
# exponent
5e+22
1e6
-2E-2
# both
6.626e-34
*/
private static final Pattern FLOAT_PATTERN = Pattern.compile("^(\\+|-)?\\d+(_\\d+)*((\\.\\d+(_\\d+)*)|(?=E))(E(\\+|-)?\\d+(_\\d+)*)?", Pattern.CASE_INSENSITIVE);
private static final Pattern INTEGER_PATTERN = Pattern.compile("^(\\+|-)?\\d+(_\\d+)*");
private static final Pattern KEY_PATTERN = Pattern.compile("[A-Za-z0-9_-]+");
//Tokenizing State:
private StringCharacterIterator chars;
private boolean eof;
private int currentLine;
public Tokenizer(Reader reader) throws IOException {
this.reader = buffer(reader);
currentLine = 0;
eof = false;
nextRawLine();
}
private ParsedToken current = null;
private ParsedToken last = null;
public Tokenizer.ParsedToken peek() {
return last = (current == null ? current = next() : current);
}
public ParsedToken lastSeen() {
return last;
}
public boolean hasNext() {
return chars.hasNext() || !eof;
}
public Tokenizer.ParsedToken next() {
if(current == null) {
//No need to use whitespaces between tokens.
int lineIndex = currentLine;
int charIndex = chars.currentIndex();
try {
Token token = tryParseNext();
if(token != null) {
return last = new ParsedToken(token, lineIndex, charIndex);
}
else {
return last = next();
}
}
catch(NoSuchElementException e) {
throw error("Unexpected end of line", e);
}
catch(Exception e) {
throw error("Unexpected Exception", e);
}
}
else {
ParsedToken ret = current;
current = null;
return last = ret;
}
}
protected boolean matches(SymbolToken symbol, Tokenizer.ParsedToken ptoken) {
return ptoken.token == symbol;
}
public boolean peekIfMatch(SymbolToken symbol) {
return matches(symbol, peek());
}
public boolean nextIfMatch(SymbolToken symbol) {
if(matches(symbol, peek())) {
next();
return true;
}
return false;
}
ParseException error(String s) {
return new ParseException(s, currentLine, chars.currentIndex());
}
ParseException error(String s, Exception e) {
return new ParseException(s, currentLine, chars.currentIndex(), e);
}
private void nextRawLine() throws IOException {
if(eof) {
throw error("Unexpected end of file");
}
currentLine++;
String line = reader.readLine();
if(line == null) {
eof = true;
line = "";
}
chars = new StringCharacterIterator(line);
}
private char nextRawChar() throws IOException {
if(!chars.hasNext()) {
nextRawLine();
return '\n';
}
return chars.next();
}
private Token parseMultilineString() throws IOException {
StringBuilder builder = new StringBuilder();
char c = nextRawChar();
while(true) {
switch(c) {
default: //Normal character
if(c == '\n') {
builder.append(BREAK_LINE); //Normalizing to OS.
}
else {
builder.append(c);
}
c = nextRawChar();
break;
case '\\':
c = nextRawChar();
if(c == '\n') {
//Escaping the new line, skip until next non-whitespace
while(Character.isWhitespace(c)) {
c = nextRawChar();
}
//Now we have a character we don't need to ignore, re-enter the logic:
continue;
}
else {
String unescaped = unescapeCharacter(c);
c = nextRawChar();
builder.append(unescaped);
}
break;
case '\"':
char c2 = nextRawChar();
if(c2 == '\"') {
char c3 = nextRawChar();
if(c3 == '\"') { //END:
return ValuedToken.multilineString(builder.toString());
}
else { //Whoops, not really the end, only ""
builder.append(c); //appending c1="
builder.append(c2); //appending c2="
c = c3; //dealing with c3
}
}
else {
builder.append(c); //appending c1="
c = c2; //dealing with c2
}
break;
}
}
}
private Token parseBasicString() {
StringBuilder builder = new StringBuilder();
while(chars.hasNext()) {
char c = chars.next();
switch(c) {
case '\\':
char escaped = chars.next(); //NoSuchElement...
String unescaped = unescapeCharacter(escaped);
builder.append(unescaped);
break;
default: //Normal character
builder.append(c);
break;
case '\"': //END:
return ValuedToken.basicString(builder.toString());
}
}
throw new ParseException("No ending quote for basic string.",currentLine,chars.currentIndex());
}
private String unescapeCharacter(char escaped) {
String unicode;
switch(escaped) {
case 'b':
return "\b";
case 't':
return "\t";
case 'n':
return "\n";
case 'f':
return "\f";
case 'r':
return "\r";
case '\"':
return "\"";
case '\\':
return "\\";
case 'u':
unicode = chars.next(4);
break;
case 'U':
unicode = chars.next(4);
break;
default:
throw error("Reserved escaped character '" + escaped + "'");
}
try {
int code = Integer.parseInt(unicode, 16);
return new String(Character.toChars(code));
}
catch(NumberFormatException nfe) {
throw error("Bad escape code "+unicode);
}
}
private Token parseLiteralString() {
StringBuilder builder = new StringBuilder();
while(chars.hasNext()) {
char c = chars.next();
if(c == '\'') { //END:
return ValuedToken.literalString(builder.toString());
}
else {
builder.append(c);
}
}
throw error("No ending single quote for literal string.");
}
private Token parseMultilineLiteralString() throws IOException {
StringBuilder builder = new StringBuilder();
while(true) {
if(chars.nextIfSeqEquals("\'\'\'")) { //always in the same line
return ValuedToken.literalString(builder.toString());
}
else {
builder.append(nextRawChar());
}
}
}
/**
* 1979-05-27T07:32:00Z
* 1979-05-27T00:32:00-07:00
* 1979-05-27T00:32:00.999999-07:00
* @param group
* @return
*/
private Token parseDateToken(String group) {
Matcher matcher = DATE_PATTERN.matcher(group);
matcher.find();
String datetimeStr = matcher.group(DATE_PATTERN_GROUP_DATETIME);
String tz = matcher.group(DATE_PATTERN_GROUP_TZ);
if(tz.equals("Z")) {
tz = "+0000"; //SimpleDateFormat does not allow Z to be included instead of a timezone, see http://stackoverflow.com/a/2202300/777203
}
if(tz.indexOf(':')!= -1) {
//Again, Java 1.5 SimpleDateFormat is rather limited with its understanding of Timezone formats. 'X' isn't available yet.
tz = tz.replaceAll(":","");
}
String fractionStr = matcher.group(DATE_PATTERN_GROUP_FRACTION);
SimpleDateFormat parser = new SimpleDateFormat(DATETIME_FORMAT);
try {
String fullDate = datetimeStr + tz;
Date date = parser.parse(fullDate);
if(fractionStr != null) {
//So, if we got ".1" that's actually 100,000,000 nanos.
fractionStr = String.format("%-"+DATE_FRACTION_PERCISION+"s",fractionStr).replace(' ','0');
long fractional = Integer.parseInt(fractionStr);
int millies = (int)((fractional*1000)/DATE_FRACTION_MAX);
date = new Date(date.getTime()+millies);
}
return ValuedToken.dateToken(date);
} catch (java.text.ParseException e) {
throw error("Couldn't parse date "+group, e);
}
}
private Token parseFloatToken(String group) {
if(group.charAt(0) == '+') {
group = group.substring(1);
}
group = group.replaceAll("_","");
return ValuedToken.floatToken(Double.valueOf(group));
}
private Token parseIntegerToken(String group) {
if(group.charAt(0) == '+') {
group = group.substring(1);
}
group = group.replaceAll("_","");
return ValuedToken.integerToken(Long.valueOf(group));
}
private Token tryParseNext() throws IOException {
if(!chars.hasNext() || chars.nextIfEquals(COMMENT_START)) {
if(hasNext()) {
nextRawLine();
}
return SymbolToken.Newline; //Always adding a new line for the last line.
}
if(Character.isWhitespace(chars.peek())) {
chars.next();
return null;
}
if(chars.nextIfSeqEquals(MULTILINE_STRING_DELIMITER)) { //Multiline strings start with """
if(!chars.hasNext()) { //Ignore newline character immediately after """
nextRawLine();
}
return parseMultilineString();
}
if(chars.nextIfEquals(BASIC_STRING_DELIMITER)) { //Basic strings starts with just "
return parseBasicString();
}
if(chars.nextIfSeqEquals(LITERAL_MULTILINE_STRING_DELIMITER)) {
if(!chars.hasNext()) { //Ignore newline character immediately after '''
nextRawLine();
}
return parseMultilineLiteralString();
}
if(chars.nextIfEquals(LITERAL_STRING_DELIMITER)) {
return parseLiteralString();
}
if(chars.nextIfSeqEquals("true")) {
return ValuedToken.booleanToken(true);
}
if(chars.nextIfSeqEquals("false")) {
return ValuedToken.booleanToken(false);
}
String match;
if((match = chars.nextIfMatches(DATE_PATTERN)) != null) {
return parseDateToken(match);
}
if((match = chars.nextIfMatches(FLOAT_PATTERN)) != null) {
return parseFloatToken(match);
}
//This has the assumption keys never start with a digit.
if((match = chars.nextIfMatches(INTEGER_PATTERN)) != null) {
return parseIntegerToken(match);
}
char peek = chars.peek();
SymbolToken symbol = SymbolToken.getSymbolToken(peek);
if(symbol != null) {
chars.next();
return symbol;
}
if((match = chars.nextIfMatches(KEY_PATTERN)) != null) {
return ValuedToken.key(match);
}
throw error("Unexpected input: "+chars.peekAll());
}
}
|
3e07e142681b3e877bde10b40f4343f2a607f244 | 1,856 | java | Java | src/main/java/io/github/utk003/util/data/collection/multi/map/repeated/RepeatedMappingMultiMap.java | utk003/Utilities | b9fed06471aa6e9b4a0f0b4d2c7ba898961f3580 | [
"MIT"
] | 2 | 2020-12-02T06:46:52.000Z | 2020-12-04T05:24:57.000Z | src/main/java/io/github/utk003/util/data/collection/multi/map/repeated/RepeatedMappingMultiMap.java | utk003/Utilities | b9fed06471aa6e9b4a0f0b4d2c7ba898961f3580 | [
"MIT"
] | null | null | null | src/main/java/io/github/utk003/util/data/collection/multi/map/repeated/RepeatedMappingMultiMap.java | utk003/Utilities | b9fed06471aa6e9b4a0f0b4d2c7ba898961f3580 | [
"MIT"
] | null | null | null | 39.489362 | 136 | 0.731142 | 3,333 | package io.github.utk003.util.data.collection.multi.map.repeated;
import io.github.utk003.util.data.collection.multi.map.MultiMap;
import io.github.utk003.util.data.collection.multi.set.MultiSet;
import io.github.utk003.util.misc.annotations.ScheduledForRelease;
import io.github.utk003.util.misc.annotations.RequiresDocumentation;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Set;
@ScheduledForRelease(inVersion = "v2.2.0")
@RequiresDocumentation
public interface RepeatedMappingMultiMap<K, V> extends MultiMap<K, V> {
int count(K key, V value);
boolean contains(K key, V value, int count);
int add(K key, V value, int count);
int remove(K key, V value, int count);
@Nullable Set<V> getUnique(K key);
@Override
@Nullable MultiSet<V> get(K key);
@Override
@Nullable MultiSet<V> removeAll(K key);
@NotNull Set<Map.Entry<K, V>> uniqueEntries();
@Override
@NotNull MultiSet<Map.Entry<K, V>> entries();
/**
* Returns an unmodifiable {@code RepeatedMappingMultiMap} backed by the given {@code RepeatedMappingMultiMap}.
* <p>
* Changes in the original multimap will be reflected in the newly returned multimap.
*
* @param multiMap The multimap to wrap with an unmodifiability layer
* @param <K> The type of the keys in both multimaps
* @param <V> The type of the values in both multimap
* @return An unmodifiable copy of the given {@code RepeatedMappingMultiMap} backed by the original multimap
*/
static <K, V> @NotNull RepeatedMappingMultiMap<K, V> makeUnmodifiable(@NotNull RepeatedMappingMultiMap<K, V> multiMap) {
return multiMap instanceof UnmodifiableRepeatedMappingMultiMap ? multiMap : new UnmodifiableRepeatedMappingMultiMap<>(multiMap);
}
}
|
3e07e15f4a14f4349c646cd9c5a5d5391da73bfa | 4,064 | java | Java | jooby/src/main/java/org/jooby/internal/CookieSessionManager.java | paul-hammant/jooby-monorepo-experiment | da8f9889a39a98f9fc87da5a44c7eda5e59e2470 | [
"Apache-2.0"
] | null | null | null | jooby/src/main/java/org/jooby/internal/CookieSessionManager.java | paul-hammant/jooby-monorepo-experiment | da8f9889a39a98f9fc87da5a44c7eda5e59e2470 | [
"Apache-2.0"
] | null | null | null | jooby/src/main/java/org/jooby/internal/CookieSessionManager.java | paul-hammant/jooby-monorepo-experiment | da8f9889a39a98f9fc87da5a44c7eda5e59e2470 | [
"Apache-2.0"
] | null | null | null | 30.787879 | 100 | 0.692913 | 3,334 | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.jooby.internal;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Named;
import org.jooby.Cookie;
import org.jooby.Cookie.Definition;
import org.jooby.Request;
import org.jooby.Response;
import org.jooby.Route;
import org.jooby.Session;
import org.jooby.internal.parser.ParserExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Save session data in a cookie.
*
* @author edgar
*/
public class CookieSessionManager implements SessionManager {
/** The logging system. */
private final Logger log = LoggerFactory.getLogger(SessionManager.class);
private final ParserExecutor resolver;
private Definition cookie;
private long timeout;
private String secret;
@Inject
public CookieSessionManager(final ParserExecutor resolver, final Session.Definition cookie,
@Named("application.secret") final String secret) {
this.resolver = resolver;
this.cookie = cookie.cookie();
this.timeout = TimeUnit.SECONDS.toMillis(this.cookie.maxAge().get());
this.secret = secret;
}
@Override
public Session create(final Request req, final Response rsp) {
Session session = new SessionImpl.Builder(resolver, true, Session.COOKIE_SESSION, -1).build();
log.debug("session created: {}", session);
rsp.after(saveCookie());
return session;
}
@Override
public Session get(final Request req, final Response rsp) {
return req.cookie(cookie.name().get()).toOptional().map(raw -> {
SessionImpl.Builder session = new SessionImpl.Builder(resolver, false, Session.COOKIE_SESSION,
-1);
Map<String, String> attributes = attributes(raw);
session.set(attributes);
rsp.after(saveCookie());
return session.build();
}).orElse(null);
}
@Override
public void destroy(final Session session) {
// NOOP
}
@Override
public void requestDone(final Session session) {
// NOOP
}
@Override
public Definition cookie() {
return new Definition(cookie);
}
private Map<String, String> attributes(final String raw) {
String unsigned = Cookie.Signature.unsign(raw, secret);
return Cookie.URL_DECODER.apply(unsigned);
}
private Route.After saveCookie() {
return (req, rsp, result) -> {
req.ifSession().ifPresent(session -> {
Optional<String> value = req.cookie(cookie.name().get()).toOptional();
Map<String, String> initial = value
.map(this::attributes)
.orElse(Collections.emptyMap());
Map<String, String> attributes = session.attributes();
// is dirty?
boolean dirty = !initial.equals(attributes);
log.debug("session dirty: {}", dirty);
if (dirty) {
log.debug("saving session cookie");
String encoded = Cookie.URL_ENCODER.apply(attributes);
String signed = Cookie.Signature.sign(encoded, secret);
rsp.cookie(new Cookie.Definition(cookie).value(signed));
} else if (timeout > 0) {
// touch session
value.ifPresent(raw -> rsp.cookie(new Cookie.Definition(cookie).value(raw)));
}
});
return result;
};
}
}
|
3e07e1e92fa613df22c0f756fdc7289a8d0bd5be | 1,762 | java | Java | modules/api/src/main/java/org/apache/ignite/schema/definition/builder/ColumnDefinitionBuilder.java | YuryYudin/ignite-3 | 36c3236453adb1be3428a7c22ab99698c231a53c | [
"CC0-1.0"
] | null | null | null | modules/api/src/main/java/org/apache/ignite/schema/definition/builder/ColumnDefinitionBuilder.java | YuryYudin/ignite-3 | 36c3236453adb1be3428a7c22ab99698c231a53c | [
"CC0-1.0"
] | 1 | 2021-05-20T12:56:53.000Z | 2021-05-20T12:56:53.000Z | modules/api/src/main/java/org/apache/ignite/schema/definition/builder/ColumnDefinitionBuilder.java | YuryYudin/ignite-3 | 36c3236453adb1be3428a7c22ab99698c231a53c | [
"CC0-1.0"
] | null | null | null | 30.912281 | 89 | 0.707719 | 3,335 | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.ignite.schema.definition.builder;
import java.util.Map;
import org.apache.ignite.schema.definition.ColumnDefinition;
/**
* Table column builder.
*/
public interface ColumnDefinitionBuilder extends SchemaObjectBuilder {
/**
* Set nullable attribute.
*
* @param nullable If {@code false}, null values will not be allowed for this column.
*
* @return {@code this} for chaining.
*/
ColumnDefinitionBuilder asNullable(boolean nullable);
/**
* Sets column default value expression.
*
* @param defValExpr Default value expression.
* @return {@code this} for chaining.
*/
ColumnDefinitionBuilder withDefaultValueExpression(Object defValExpr);
/** {@inheritDoc} */
@Override
ColumnDefinitionBuilder withHints(Map<String, String> hints);
/**
* Builds column.
*
* @return Built column.
*/
@Override
ColumnDefinition build();
}
|
3e07e2173548af2971a58f62b88cc80b02d4495c | 10,730 | java | Java | ESLibraryAndroid/birthstone/src/main/java/com/birthstone/widgets/ESActionSheet.java | eruntechsoftware/AndroidESLibrary | 49776ccec8afe2d5c232189a465a9b3200bab57f | [
"MIT"
] | 1 | 2018-10-16T15:28:53.000Z | 2018-10-16T15:28:53.000Z | ESLibraryAndroid/birthstone/src/main/java/com/birthstone/widgets/ESActionSheet.java | eruntechsoftware/AndroidESLibrary | 49776ccec8afe2d5c232189a465a9b3200bab57f | [
"MIT"
] | null | null | null | ESLibraryAndroid/birthstone/src/main/java/com/birthstone/widgets/ESActionSheet.java | eruntechsoftware/AndroidESLibrary | 49776ccec8afe2d5c232189a465a9b3200bab57f | [
"MIT"
] | null | null | null | 23.225108 | 149 | 0.693569 | 3,336 | package com.birthstone.widgets;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.view.*;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import com.birthstone.R;
import com.birthstone.core.parse.Data;
import com.birthstone.core.parse.DataCollection;
import com.birthstone.core.parse.DataTable;
/***
* 日期:2015年9月1日
* 作者:杜明悦
* 功能:底部弹出式列表
*/
public class ESActionSheet extends PopupWindow implements View.OnClickListener
{
/**
* 声明控件
**/
private View view, parent;
private RelativeLayout dialog_rootView;
private LinearLayout viewGroup;
private LinearLayout divider;
/**
* 私有变量声明
**/
private Context context;
private OnActionSheetClickListener onActionSheetClickListener;
private String[] itemName;
private String[] itemValue;
private DataTable dataTable;
private String cancel;
/***
* ActionSheet
*
* @param context
* @param itemName 名称列表
*/
public ESActionSheet(Context context, View parent, String[] itemName)
{
super(context);
this.context = context;
this.parent = parent;
setParams();
this.itemName = itemName;
if(this.itemName != null && this.itemName.length > 0)
{
createMenu();
}
}
/***
* ActionSheet
*
* @param context
* @param itemName 名称列表
* @param itemValue 值列表
*/
public ESActionSheet(Context context, View parent, String[] itemName, String[] itemValue)
{
super(context);
this.context = context;
this.parent = parent;
setParams();
this.itemName = itemName;
this.itemValue = itemValue;
if(this.itemName != null && this.itemName.length > 0)
{
createMenu();
}
}
/***
* ActionSheet
*
* @param context
* @param dataTable 数据源
*/
public ESActionSheet(Context context, View parent, DataTable dataTable, String itemName, String itemValue,String cancel)
{
super(context);
this.context = context;
this.parent = parent;
this.cancel=cancel;
setParams();
this.dataTable = dataTable;
DataCollection cancelParams = new DataCollection();
cancelParams.add(new Data(itemName,cancel));
cancelParams.add(new Data(itemValue,-10000));
this.dataTable.add(cancelParams);
if(this.dataTable != null && this.dataTable.size() > 0)
{
createMenu(dataTable, itemName, itemValue);
}
}
/***
* 日期:2015年9月1日
* 作者:杜明悦
* 功能:设置必要参数
*/
protected void setParams()
{
view = View.inflate(context, R.layout.es_actionsheet, null);
setContentView(view);
viewGroup = (LinearLayout) view.findViewById(R.id.viewGroup);
dialog_rootView = (RelativeLayout) view.findViewById(R.id.dialog_rootView);
dialog_rootView.setOnClickListener(this);
}
/***
* 日期:2015年9月1日
* 作者:杜明悦
* 功能:创建弹出菜单
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void createMenu(DataTable table, String itemName, String itemValue)
{
if(table != null && table.size() > 0)
{
//设置button布局
ViewGroup.LayoutParams layoutParams;
int size = table.size();
for(int i = 0; i < size; i++)
{
//添加Button
Button btnItem = new Button(context);
//设置view的ID
btnItem.setId(i);
btnItem.setText(table.get(i).get(itemName).getStringValue());
btnItem.setTag(table.get(i).get(itemValue).getStringValue());
//设置字体样式
btnItem.setTextColor(Color.BLUE);
btnItem.setTextSize(16.0f);
btnItem.setPadding(0, 30, 0, 30);
//添加事件监听
btnItem.setOnClickListener(this);
//设置button布局
layoutParams = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
btnItem.setLayoutParams(layoutParams);
if(i == 0 && i == size - 2)
{
}
else if(i == 0)
{
btnItem.setBackground(context.getResources().getDrawable(R.drawable.es_actionsheet_top));
}
else if(i == size - 2)
{
btnItem.setBackground(context.getResources().getDrawable(R.drawable.es_actionsheet_bottom));
}
else if(i == size - 1)
{
//设置字体样式
btnItem.setTextColor(Color.RED);
btnItem.setTag(-10000);
btnItem.setBackground(context.getResources().getDrawable(R.drawable.es_actionsheet_background_selector));
}
else
{
btnItem.setBackground(context.getResources().getDrawable(R.drawable.es_actionsheet_item));
}
viewGroup.addView(btnItem);
//添加间隔线
if(i < size - 2)
{
divider = new LinearLayout(context);
divider.setBackgroundColor(Color.LTGRAY);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 0, 0, 0);
lp.height = 1;
divider.setLayoutParams(lp);
viewGroup.addView(divider);
}
if(i == size - 2)
{
divider = new LinearLayout(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 0, 0, 0);
lp.height = 20;
divider.setLayoutParams(lp);
viewGroup.addView(divider);
}
}
}
}
/***
* 日期:2015年9月1日
* 作者:杜明悦
* 功能:创建弹出菜单
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void createMenu()
{
if(this.itemName != null && this.itemName.length > 0)
{
int size = itemName.length;
for(int i = 0; i < size; i++)
{
//添加Button
Button btnItem = new Button(context);
//设置view的ID
btnItem.setId(i);
btnItem.setText(itemName[i]);
if(itemValue!=null && itemValue.length>i)
{
btnItem.setTag(itemValue[i]);
}
//设置字体样式
btnItem.setTextColor(Color.BLUE);
btnItem.setTextSize(16.0f);
btnItem.setPadding(0, 30, 0, 30);
//添加事件监听
btnItem.setOnClickListener(this);
//设置button布局
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
btnItem.setLayoutParams(layoutParams);
if(i == 0 && i == size - 2)
{
}
else if(i == 0)
{
btnItem.setBackground(context.getResources().getDrawable(R.drawable.es_actionsheet_top));
}
else if(i == size - 2)
{
btnItem.setBackground(context.getResources().getDrawable(R.drawable.es_actionsheet_bottom));
}
else if(i == size - 1)
{
//设置字体样式
btnItem.setTextColor(Color.RED);
btnItem.setTag(-10000);
btnItem.setBackground(context.getResources().getDrawable(R.drawable.es_actionsheet_background_selector));
}
else
{
btnItem.setBackground(context.getResources().getDrawable(R.drawable.es_actionsheet_item));
}
viewGroup.addView(btnItem);
//添加间隔线
if(i < size - 2)
{
divider = new LinearLayout(context);
divider.setBackgroundColor(Color.LTGRAY);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 0, 0, 0);
lp.height = 1;
divider.setLayoutParams(lp);
viewGroup.addView(divider);
}
if(i == size - 2)
{
divider = new LinearLayout(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 0, 0, 0);
lp.height = 20;
divider.setLayoutParams(lp);
viewGroup.addView(divider);
}
}
}
}
/**
* 修改时间:2016年04月25日
* <p>
* 作者:张景瑞
* <p>
* 功能:取得导航栏高度
*
* @param context
*
* @return
*/
public static int getNavigationBarHeight(Context context)
{
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
//获取NavigationBar的高度
int height = resources.getDimensionPixelSize(resourceId);
return height;
}
/**
* 修改时间:2016年04月25日
* <p>
* 作者:张景瑞
* <p>
* 功能:判断是否有导航栏
*
* @param context
*
* @return
*/
@SuppressLint("NewApi")
public static boolean checkDeviceHasNavigationBar(Context context)
{
//通过判断设备是否有返回键、菜单键(不是虚拟键,是手机屏幕外的按键)来确定是否有navigation bar
boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
if(!hasMenuKey && !hasBackKey)
{
// 做任何你需要做的,这个设备有一个导航栏
return true;
}
else
{
return false;
}
}
@SuppressLint("ResourceType")
public void onClick(View v)
{
if(v instanceof RelativeLayout)
{
dismiss();
return;
}
if(v.getId() != -10000)
{
if(onActionSheetClickListener != null)
{
onActionSheetClickListener.onItemClick ((Button) v);
}
}
dismiss();
}
/***
* 日期:2015年9月2日
* 作者:杜明悦
* 功能:显示ActionSheet
*/
public void show()
{
view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.es_actionsheet_backgroundview_show));
viewGroup.startAnimation(AnimationUtils.loadAnimation(context, R.anim.es_actionsheet_show));
setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
setBackgroundDrawable(new BitmapDrawable());
setFocusable(true);
setOutsideTouchable(true);
setContentView(view);
if(checkDeviceHasNavigationBar(context))
{
showAtLocation(parent, Gravity.BOTTOM, 0, getNavigationBarHeight(context));
}
else
{
showAtLocation(parent, Gravity.BOTTOM, 0, 0);
}
update();
}
/***
* 日期:2015年9月2日
* 作者:杜明悦
* 功能:隐藏ActionSheet
*/
public void dismiss()
{
//设置动画效果
Animation anim = AnimationUtils.loadAnimation(context, R.anim.es_actionsheet_dismiss);
anim.setAnimationListener(new Animation.AnimationListener()
{
@Override
public void onAnimationStart(Animation animation)
{
}
@Override
public void onAnimationRepeat(Animation animation)
{
}
@Override
public void onAnimationEnd(Animation animation)
{
view.post(new Runnable()
{
@Override
public void run()
{
ESActionSheet.super.dismiss();
}
});
}
});
//弹出框列表下滑
viewGroup.startAnimation(anim);
}
/***
* 日期:2015年9月2日
* 作者:杜明悦
* 功能:设置ActionSheet单击处理监听对象
* @param onActionSheetClickListener 监听器对象
*/
public void setOnActionSheetClickListener(OnActionSheetClickListener onActionSheetClickListener)
{
this.onActionSheetClickListener = onActionSheetClickListener;
}
/**
* 日期:2015年9月2日 作者:杜明悦 功能:ActionSheet单击事件监听器
*/
public interface OnActionSheetClickListener
{
public void onItemClick(Button view);
}
}
|
3e07e334101f803434644ce086cbcc0a7eaa1d50 | 2,947 | java | Java | src/java/com/echothree/model/control/cancellationpolicy/server/transfer/CancellationPolicyReasonTransferCache.java | echothreellc/echothree | 1744df7654097cc000e5eca32de127b5dc745302 | [
"Apache-2.0"
] | 1 | 2020-09-01T08:39:01.000Z | 2020-09-01T08:39:01.000Z | src/java/com/echothree/model/control/cancellationpolicy/server/transfer/CancellationPolicyReasonTransferCache.java | echothreellc/echothree | 1744df7654097cc000e5eca32de127b5dc745302 | [
"Apache-2.0"
] | null | null | null | src/java/com/echothree/model/control/cancellationpolicy/server/transfer/CancellationPolicyReasonTransferCache.java | echothreellc/echothree | 1744df7654097cc000e5eca32de127b5dc745302 | [
"Apache-2.0"
] | 1 | 2020-05-31T08:34:46.000Z | 2020-05-31T08:34:46.000Z | 57.784314 | 177 | 0.755684 | 3,337 | // --------------------------------------------------------------------------------
// Copyright 2002-2021 Echo Three, LLC
//
// 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 com.echothree.model.control.cancellationpolicy.server.transfer;
import com.echothree.model.control.cancellationpolicy.common.transfer.CancellationPolicyReasonTransfer;
import com.echothree.model.control.cancellationpolicy.common.transfer.CancellationPolicyTransfer;
import com.echothree.model.control.cancellationpolicy.common.transfer.CancellationReasonTransfer;
import com.echothree.model.control.cancellationpolicy.server.control.CancellationPolicyControl;
import com.echothree.model.data.cancellationpolicy.server.entity.CancellationPolicyReason;
import com.echothree.model.data.user.server.entity.UserVisit;
public class CancellationPolicyReasonTransferCache
extends BaseCancellationPolicyTransferCache<CancellationPolicyReason, CancellationPolicyReasonTransfer> {
/** Creates a new instance of CancellationPolicyReasonTransferCache */
public CancellationPolicyReasonTransferCache(UserVisit userVisit, CancellationPolicyControl cancellationPolicyControl) {
super(userVisit, cancellationPolicyControl);
}
public CancellationPolicyReasonTransfer getCancellationPolicyReasonTransfer(CancellationPolicyReason cancellationPolicyReason) {
CancellationPolicyReasonTransfer cancellationPolicyReasonTransfer = get(cancellationPolicyReason);
if(cancellationPolicyReasonTransfer == null) {
CancellationPolicyTransfer cancellationPolicy = cancellationPolicyControl.getCancellationPolicyTransfer(userVisit, cancellationPolicyReason.getCancellationPolicy());
CancellationReasonTransfer cancellationReason = cancellationPolicyControl.getCancellationReasonTransfer(userVisit, cancellationPolicyReason.getCancellationReason());
Boolean isDefault = cancellationPolicyReason.getIsDefault();
Integer sortOrder = cancellationPolicyReason.getSortOrder();
cancellationPolicyReasonTransfer = new CancellationPolicyReasonTransfer(cancellationPolicy, cancellationReason, isDefault, sortOrder);
put(cancellationPolicyReason, cancellationPolicyReasonTransfer);
}
return cancellationPolicyReasonTransfer;
}
}
|
3e07e35470dd831c52fa43ce110fb41efb585c73 | 101 | java | Java | api/src/main/java/com/posws/models/Skill.java | haxul/vacancy-statistics | be0300d7b1827d1eabe0511404495dafde9b3ec1 | [
"MIT"
] | null | null | null | api/src/main/java/com/posws/models/Skill.java | haxul/vacancy-statistics | be0300d7b1827d1eabe0511404495dafde9b3ec1 | [
"MIT"
] | 1 | 2022-01-21T23:41:19.000Z | 2022-01-21T23:41:19.000Z | api/src/main/java/com/posws/models/Skill.java | haxul/vacancy-statistics | be0300d7b1827d1eabe0511404495dafde9b3ec1 | [
"MIT"
] | 1 | 2020-04-26T16:01:30.000Z | 2020-04-26T16:01:30.000Z | 12.625 | 25 | 0.732673 | 3,338 | package com.posws.models;
import lombok.Data;
@Data
public class Skill {
private String name;
} |
3e07e4553489a2a2d25f7e2c09bd95ed4ab5a3f9 | 1,924 | java | Java | Java/0-100/6. ZigZag Conversion.java | DeyuGoGo/LeetCode | f7889b1001c41a6295a03ea24b34bef2a0d4e65b | [
"MIT"
] | null | null | null | Java/0-100/6. ZigZag Conversion.java | DeyuGoGo/LeetCode | f7889b1001c41a6295a03ea24b34bef2a0d4e65b | [
"MIT"
] | null | null | null | Java/0-100/6. ZigZag Conversion.java | DeyuGoGo/LeetCode | f7889b1001c41a6295a03ea24b34bef2a0d4e65b | [
"MIT"
] | null | null | null | 26.356164 | 175 | 0.448025 | 3,339 | // The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
//
// P A H N
// A P L S I I G
// Y I R
// And then read line by line: "PAHNAPLSIIGYIR"
// Write the code that will take a string and make this conversion given a number of rows:
//
// string convert(string text, int nRows);
// convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".
// Your input
//
// "123456789"
// 1
// "12"
// 2
// "ABC"
// 3
// "ABC"
// 2
// "ABCDE"
// 4
// "ABCDEFGIJKLMN"
// 4
// Your answer
//
// "123456789"
// "12"
// "ABC"
// "ACB"
// "ABCED"
// "AGNBFIMCEJLDK"
public class Solution {
public String convert(String s, int numRows) {
int sl = s.length();
int b = getblocknums(numRows);
int ok = sl%b;
int gogo = sl/b ;
StringBuffer sb = new StringBuffer();
for(int i = 0 ; i < numRows ; i++){
for(int k = 0 ; k <= gogo ; k++){
if(k==gogo){
if(i == 0 || i== numRows-1){
if(i<ok)
sb.append(s.charAt((k*b)+i));
}else{
if(i<ok)
sb.append(s.charAt((k*b)+i));
if(b-i<ok)
sb.append(s.charAt((k*b)+(b-i)));
}
break;
}
if(i == 0 || i== numRows-1){
sb.append(s.charAt((k*b)+i));
}else{
sb.append(s.charAt((k*b)+i));
sb.append(s.charAt((k*b)+(b-i)));
}
}
}
return sb.toString();
}
private int getblocknums(int nums){
int result = nums;
if(nums>2){
result = nums+(nums-2);
}
return result;
}
}
|
3e07e4bc358182169f17fe595d5db12f4ec948ac | 381 | java | Java | src/main/java/org/fernando/izazaga/repository/CategoriasReporitory.java | Zaza381026/empleos_imf | 30cc33b9e94407d6a136ca8676c1054b5b8cf558 | [
"CC0-1.0"
] | null | null | null | src/main/java/org/fernando/izazaga/repository/CategoriasReporitory.java | Zaza381026/empleos_imf | 30cc33b9e94407d6a136ca8676c1054b5b8cf558 | [
"CC0-1.0"
] | null | null | null | src/main/java/org/fernando/izazaga/repository/CategoriasReporitory.java | Zaza381026/empleos_imf | 30cc33b9e94407d6a136ca8676c1054b5b8cf558 | [
"CC0-1.0"
] | null | null | null | 29.307692 | 84 | 0.845144 | 3,340 | package org.fernando.izazaga.repository;
import org.fernando.izazaga.model.Categoria;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;
//public interface CategoriasReporitory extends CrudRepository<Categoria, Integer> {
public interface CategoriasReporitory extends JpaRepository<Categoria, Integer> {
}
|
3e07e5fe202356fd627f52788cfe2a1aa94bec7e | 970 | java | Java | projects/control-service/projects/pipelines_control_service/src/main/java/com/vmware/taurus/service/deploy/DataJobDefaultConfigurations.java | alod83/versatile-data-kit | 9ca672d3929eb3dc6fe5c677e8c8a75e2a0d2be8 | [
"Apache-2.0"
] | 100 | 2021-10-04T09:32:04.000Z | 2022-03-30T11:23:53.000Z | projects/control-service/projects/pipelines_control_service/src/main/java/com/vmware/taurus/service/deploy/DataJobDefaultConfigurations.java | alod83/versatile-data-kit | 9ca672d3929eb3dc6fe5c677e8c8a75e2a0d2be8 | [
"Apache-2.0"
] | 208 | 2021-10-04T16:56:40.000Z | 2022-03-31T10:41:44.000Z | projects/control-service/projects/pipelines_control_service/src/main/java/com/vmware/taurus/service/deploy/DataJobDefaultConfigurations.java | alod83/versatile-data-kit | 9ca672d3929eb3dc6fe5c677e8c8a75e2a0d2be8 | [
"Apache-2.0"
] | 14 | 2021-10-11T14:15:13.000Z | 2022-03-11T13:39:17.000Z | 29.393939 | 74 | 0.764948 | 3,341 | /*
* Copyright 2021 VMware, Inc.
* SPDX-License-Identifier: Apache-2.0
*/
package com.vmware.taurus.service.deploy;
import com.vmware.taurus.service.KubernetesService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class DataJobDefaultConfigurations {
@Value("${datajobs.job.resources.limits.memory:1G}")
private String memoryLimits;
@Value("${datajobs.job.resources.limits.cpu:2000m}")
private String cpuLimits;
@Value("${datajobs.job.resources.requests.memory:500Mi}")
private String memoryRequests;
@Value("${datajobs.job.resources.requests.cpu:1000m}")
private String cpuRequests;
public KubernetesService.Resources dataJobRequests() {
return new KubernetesService.Resources(cpuRequests, memoryRequests);
}
public KubernetesService.Resources dataJobLimits() {
return new KubernetesService.Resources(cpuLimits, memoryLimits);
}
}
|
3e07e6425de59527ad4f82f21c1b4772eb3acdaf | 2,041 | java | Java | aliyun-java-sdk-imm/src/main/java/com/aliyuncs/imm/model/v20170906/CreateTagSetResponse.java | ssy352959096/aliyun-openapi-java-sdk | 7decd0e2273445b4311d576202fb6151e2194596 | [
"Apache-2.0"
] | 3 | 2021-01-25T16:15:23.000Z | 2021-01-25T16:15:54.000Z | aliyun-java-sdk-imm/src/main/java/com/aliyuncs/imm/model/v20170906/CreateTagSetResponse.java | 03040081/aliyun-openapi-java-sdk | cf7a6bf5355f0dce0a7de21591f22d337377866c | [
"Apache-2.0"
] | null | null | null | aliyun-java-sdk-imm/src/main/java/com/aliyuncs/imm/model/v20170906/CreateTagSetResponse.java | 03040081/aliyun-openapi-java-sdk | cf7a6bf5355f0dce0a7de21591f22d337377866c | [
"Apache-2.0"
] | null | null | null | 22.184783 | 77 | 0.724155 | 3,342 | /*
* 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 com.aliyuncs.imm.model.v20170906;
import com.aliyuncs.AcsResponse;
import com.aliyuncs.imm.transform.v20170906.CreateTagSetResponseUnmarshaller;
import com.aliyuncs.transform.UnmarshallerContext;
/**
* @author auto create
* @version
*/
public class CreateTagSetResponse extends AcsResponse {
private String requestId;
private String setId;
private String status;
private Long photos;
private String createTime;
private String modifyTime;
public String getRequestId() {
return this.requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public String getSetId() {
return this.setId;
}
public void setSetId(String setId) {
this.setId = setId;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public Long getPhotos() {
return this.photos;
}
public void setPhotos(Long photos) {
this.photos = photos;
}
public String getCreateTime() {
return this.createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getModifyTime() {
return this.modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
@Override
public CreateTagSetResponse getInstance(UnmarshallerContext context) {
return CreateTagSetResponseUnmarshaller.unmarshall(this, context);
}
}
|
3e07e6dbfd9f3ee9cd0dfd9d90d33220d234bac1 | 768 | java | Java | src/main/java/com/elytradev/inredaddons/mixin/MixinLecternBlockEntity.java | elytra/InRedAddons | f2d7c11f1433134e5d91fe52c91cbcb4c730f9ff | [
"CC0-1.0"
] | null | null | null | src/main/java/com/elytradev/inredaddons/mixin/MixinLecternBlockEntity.java | elytra/InRedAddons | f2d7c11f1433134e5d91fe52c91cbcb4c730f9ff | [
"CC0-1.0"
] | null | null | null | src/main/java/com/elytradev/inredaddons/mixin/MixinLecternBlockEntity.java | elytra/InRedAddons | f2d7c11f1433134e5d91fe52c91cbcb4c730f9ff | [
"CC0-1.0"
] | null | null | null | 38.4 | 135 | 0.791667 | 3,343 | package com.elytradev.inredaddons.mixin;
import com.elytradev.infraredstone.api.EncoderScannable;
import net.minecraft.block.entity.LecternBlockEntity;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(LecternBlockEntity.class)
public class MixinLecternBlockEntity implements EncoderScannable {
@Shadow private int field_17390;
@Override
public int getEncoderValue(Direction direction) {
float percent = field_17390 > 1 ? (float)((LecternBlockEntity)(Object)this).method_17523() / ((float)this.field_17390 - 1.0F) : 1.0F;
return MathHelper.floor(percent * 62.0F) + (((LecternBlockEntity)(Object)this).method_17522() ? 1 : 0);
}
}
|
3e07e6efcccd9112e87d88d8585aa348400c59f2 | 2,564 | java | Java | core/rio/api/src/test/java/org/eclipse/rdf4j/rio/helpers/AbstractRDFParserTest.java | t-rasmud/rdf4j | 8c83d0c83f55017c585e0c40349b01bfd60d6e64 | [
"BSD-3-Clause"
] | 312 | 2016-01-14T20:04:24.000Z | 2022-03-30T22:21:41.000Z | core/rio/api/src/test/java/org/eclipse/rdf4j/rio/helpers/AbstractRDFParserTest.java | t-rasmud/rdf4j | 8c83d0c83f55017c585e0c40349b01bfd60d6e64 | [
"BSD-3-Clause"
] | 2,611 | 2016-01-18T22:32:22.000Z | 2022-03-31T17:38:43.000Z | core/rio/api/src/test/java/org/eclipse/rdf4j/rio/helpers/AbstractRDFParserTest.java | t-rasmud/rdf4j | 8c83d0c83f55017c585e0c40349b01bfd60d6e64 | [
"BSD-3-Clause"
] | 186 | 2016-01-14T21:18:37.000Z | 2022-03-22T12:32:33.000Z | 32.455696 | 112 | 0.713729 | 3,344 | /*******************************************************************************
* Copyright (c) 2020 Eclipse RDF4J contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*******************************************************************************/
package org.eclipse.rdf4j.rio.helpers;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.eclipse.rdf4j.rio.RDFHandlerException;
import org.eclipse.rdf4j.rio.RDFParseException;
import org.junit.Before;
import org.junit.Test;
/**
*
* @author Bart Hanssens
*/
public class AbstractRDFParserTest {
private MyRDFParser parser;
private class MyRDFParser extends AbstractRDFParser {
@Override
public RDFFormat getRDFFormat() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException {
throw new UnsupportedOperationException("Not supported yet.");
}
public Resource getBNode() {
return createNode();
}
public Resource getBNode(String id) {
return createNode(id);
}
};
@Before
public void setUp() throws Exception {
parser = new MyRDFParser();
}
@Test
public void testSkolemOrigin() throws Exception {
parser.getParserConfig().set(BasicParserSettings.SKOLEMIZE_ORIGIN, "http://www.example.com");
assertTrue(parser.getBNode().toString().startsWith("http://www.example.com"));
assertTrue(parser.getBNode("12").toString().startsWith("http://www.example.com"));
}
@Test
public void testSkolemOriginReset() throws Exception {
parser.getParserConfig().set(BasicParserSettings.SKOLEMIZE_ORIGIN, "http://www.example.com");
parser.getParserConfig().set(BasicParserSettings.SKOLEMIZE_ORIGIN, "");
assertFalse(parser.getBNode().toString().startsWith("http://www.example.com"));
assertTrue(parser.getBNode().toString().startsWith("_"));
assertTrue(parser.getBNode("12").toString().endsWith("12"));
}
}
|
3e07e74f078360796eb6d10e66fb39808e0e44bc | 668 | java | Java | 1.Solon/demo1011-hotplug_main/src/main/java/demo1011/App.java | noear/solon-examples | 7639392645298f7435df9e7bcc43bd3268ac5a38 | [
"MIT"
] | 2 | 2021-12-31T13:39:00.000Z | 2022-02-06T09:26:40.000Z | 1.Solon/demo1011-hotplug_main/src/main/java/demo1011/App.java | noear/solon-examples | 7639392645298f7435df9e7bcc43bd3268ac5a38 | [
"MIT"
] | null | null | null | 1.Solon/demo1011-hotplug_main/src/main/java/demo1011/App.java | noear/solon-examples | 7639392645298f7435df9e7bcc43bd3268ac5a38 | [
"MIT"
] | null | null | null | 23.857143 | 60 | 0.517964 | 3,345 | package demo1011;
import org.noear.solon.Solon;
import org.noear.solon.hotplug.PluginManager;
import org.noear.solon.schedule.annotation.EnableScheduling;
@EnableScheduling
public class App {
public static void main(String[] args) {
Solon.start(App.class, args, app -> {
//启动插件
app.get("start", ctx -> {
PluginManager.start("add1");
ctx.output("OK");
});
//停止插件
app.get("stop", ctx -> {
PluginManager.stop("add1");
ctx.output("OK");
});
});
//加载插件
PluginManager.load("add1").start();
}
}
|
3e07e757556943d8d1b626ad9b9d4eace0582e6a | 2,582 | java | Java | data/common/src/main/java/org/appfuse/Constants.java | geekcheng/appfuse | 3f4588dce74b7f0762bec65727731bc3bf6ae899 | [
"Apache-2.0"
] | 250 | 2015-01-03T06:46:25.000Z | 2022-02-03T00:02:43.000Z | data/common/src/main/java/org/appfuse/Constants.java | geekcheng/appfuse | 3f4588dce74b7f0762bec65727731bc3bf6ae899 | [
"Apache-2.0"
] | null | null | null | data/common/src/main/java/org/appfuse/Constants.java | geekcheng/appfuse | 3f4588dce74b7f0762bec65727731bc3bf6ae899 | [
"Apache-2.0"
] | 178 | 2015-01-05T05:37:39.000Z | 2021-11-03T01:13:06.000Z | 28.744444 | 89 | 0.643989 | 3,346 | package org.appfuse;
/**
* Constant values used throughout the application.
*
* @author <a href="mailto:lyhxr@example.com">Matt Raible</a>
*/
public final class Constants {
private Constants() {
// hide me
}
//~ Static fields/initializers =============================================
/**
* Assets Version constant
*/
public static final String ASSETS_VERSION = "assetsVersion";
/**
* The name of the ResourceBundle used in this application
*/
public static final String BUNDLE_KEY = "ApplicationResources";
/**
* File separator from System properties
*/
public static final String FILE_SEP = System.getProperty("file.separator");
/**
* User home from System properties
*/
public static final String USER_HOME = System.getProperty("user.home") + FILE_SEP;
/**
* The name of the configuration hashmap stored in application scope.
*/
public static final String CONFIG = "appConfig";
/**
* Session scope attribute that holds the locale set by the user. By setting this key
* to the same one that Struts uses, we get synchronization in Struts w/o having
* to do extra work or have two session-level variables.
*/
public static final String PREFERRED_LOCALE_KEY = "org.apache.struts2.action.LOCALE";
/**
* The request scope attribute under which an editable user form is stored
*/
public static final String USER_KEY = "userForm";
/**
* The request scope attribute that holds the user list
*/
public static final String USER_LIST = "userList";
/**
* The request scope attribute for indicating a newly-registered user
*/
public static final String REGISTERED = "registered";
/**
* The name of the Administrator role, as specified in web.xml
*/
public static final String ADMIN_ROLE = "ROLE_ADMIN";
/**
* The name of the User role, as specified in web.xml
*/
public static final String USER_ROLE = "ROLE_USER";
/**
* The name of the user's role list, a request-scoped attribute
* when adding/editing a user.
*/
public static final String USER_ROLES = "userRoles";
/**
* The name of the available roles list, a request-scoped attribute
* when adding/editing a user.
*/
public static final String AVAILABLE_ROLES = "availableRoles";
/**
* The name of the CSS Theme setting.
* @deprecated No longer used to set themes.
*/
public static final String CSS_THEME = "csstheme";
}
|
3e07e847e9a32e49b31f8256cf5555ffe58552a5 | 15,931 | java | Java | DeviceHandler/src/com/slim/device/settings/ScreenOffGesture.java | ScorpionRom-Devices/device_oneplus_bacon | 138360ffd28d4fe15e8e16721047a45815f62213 | [
"FTL"
] | null | null | null | DeviceHandler/src/com/slim/device/settings/ScreenOffGesture.java | ScorpionRom-Devices/device_oneplus_bacon | 138360ffd28d4fe15e8e16721047a45815f62213 | [
"FTL"
] | null | null | null | DeviceHandler/src/com/slim/device/settings/ScreenOffGesture.java | ScorpionRom-Devices/device_oneplus_bacon | 138360ffd28d4fe15e8e16721047a45815f62213 | [
"FTL"
] | null | null | null | 42.145503 | 98 | 0.657021 | 3,347 | /*
* Copyright (C) 2014 Slimroms
*
* 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 com.slim.device.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.android.internal.util.gzosp.AppHelper;
import com.android.internal.util.gzosp.ActionConstants;
import com.android.internal.util.gzosp.DeviceUtils;
import com.android.internal.util.gzosp.DeviceUtils.FilteredDeviceFeaturesArray;
import com.slim.device.KernelControl;
import com.slim.device.R;
import com.slim.device.util.ShortcutPickerHelper;
public class ScreenOffGesture extends PreferenceFragment implements
OnPreferenceChangeListener, OnPreferenceClickListener,
ShortcutPickerHelper.OnPickListener {
private static final String SETTINGS_METADATA_NAME = "com.android.settings";
public static final String GESTURE_SETTINGS = "screen_off_gesture_settings";
public static final String PREF_GESTURE_ENABLE = "enable_gestures";
public static final String PREF_GESTURE_CIRCLE = "gesture_circle";
public static final String PREF_GESTURE_DOUBLE_SWIPE = "gesture_double_swipe";
public static final String PREF_GESTURE_ARROW_UP = "gesture_arrow_up";
public static final String PREF_GESTURE_ARROW_DOWN = "gesture_arrow_down";
public static final String PREF_GESTURE_ARROW_LEFT = "gesture_arrow_left";
public static final String PREF_GESTURE_ARROW_RIGHT = "gesture_arrow_right";
private static final int DLG_SHOW_ACTION_DIALOG = 0;
private static final int DLG_RESET_TO_DEFAULT = 1;
private static final int MENU_RESET = Menu.FIRST;
private Preference mGestureCircle;
private Preference mGestureDoubleSwipe;
private Preference mGestureArrowUp;
private Preference mGestureArrowDown;
private Preference mGestureArrowLeft;
private Preference mGestureArrowRight;
private SwitchPreference mEnableGestures;
private boolean mCheckPreferences;
private SharedPreferences mScreenOffGestureSharedPreferences;
private ShortcutPickerHelper mPicker;
private String mPendingSettingsKey;
private static FilteredDeviceFeaturesArray sFinalActionDialogArray;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPicker = new ShortcutPickerHelper(getActivity(), this);
mScreenOffGestureSharedPreferences = getActivity().getSharedPreferences(
GESTURE_SETTINGS, Activity.MODE_PRIVATE);
// Before we start filter out unsupported options on the
// ListPreference values and entries
PackageManager pm = getActivity().getPackageManager();
Resources settingsResources = null;
try {
settingsResources = pm.getResourcesForApplication(SETTINGS_METADATA_NAME);
} catch (Exception e) {
return;
}
sFinalActionDialogArray = new FilteredDeviceFeaturesArray();
sFinalActionDialogArray = DeviceUtils.filterUnsupportedDeviceFeatures(getActivity(),
settingsResources.getStringArray(
settingsResources.getIdentifier(SETTINGS_METADATA_NAME
+ ":array/shortcut_action_screen_off_values", null, null)),
settingsResources.getStringArray(
settingsResources.getIdentifier(SETTINGS_METADATA_NAME
+ ":array/shortcut_action_screen_off_entries", null, null)));
// Attach final settings screen.
reloadSettings();
setHasOptionsMenu(true);
}
private PreferenceScreen reloadSettings() {
mCheckPreferences = false;
PreferenceScreen prefs = getPreferenceScreen();
if (prefs != null) {
prefs.removeAll();
}
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.screen_off_gesture);
prefs = getPreferenceScreen();
mEnableGestures = (SwitchPreference) prefs.findPreference(PREF_GESTURE_ENABLE);
mGestureCircle = (Preference) prefs.findPreference(PREF_GESTURE_CIRCLE);
mGestureDoubleSwipe = (Preference) prefs.findPreference(PREF_GESTURE_DOUBLE_SWIPE);
mGestureArrowUp = (Preference) prefs.findPreference(PREF_GESTURE_ARROW_UP);
mGestureArrowDown = (Preference) prefs.findPreference(PREF_GESTURE_ARROW_DOWN);
mGestureArrowLeft = (Preference) prefs.findPreference(PREF_GESTURE_ARROW_LEFT);
mGestureArrowRight = (Preference) prefs.findPreference(PREF_GESTURE_ARROW_RIGHT);
setupOrUpdatePreference(mGestureCircle, mScreenOffGestureSharedPreferences
.getString(PREF_GESTURE_CIRCLE, ActionConstants.ACTION_CAMERA));
setupOrUpdatePreference(mGestureDoubleSwipe, mScreenOffGestureSharedPreferences
.getString(PREF_GESTURE_DOUBLE_SWIPE, ActionConstants.ACTION_MEDIA_PLAY_PAUSE));
setupOrUpdatePreference(mGestureArrowUp, mScreenOffGestureSharedPreferences
.getString(PREF_GESTURE_ARROW_UP, ActionConstants.ACTION_TORCH));
setupOrUpdatePreference(mGestureArrowDown, mScreenOffGestureSharedPreferences
.getString(PREF_GESTURE_ARROW_DOWN, ActionConstants.ACTION_VIB_SILENT));
setupOrUpdatePreference(mGestureArrowLeft, mScreenOffGestureSharedPreferences
.getString(PREF_GESTURE_ARROW_LEFT, ActionConstants.ACTION_MEDIA_PREVIOUS));
setupOrUpdatePreference(mGestureArrowRight, mScreenOffGestureSharedPreferences
.getString(PREF_GESTURE_ARROW_RIGHT, ActionConstants.ACTION_MEDIA_NEXT));
boolean enableGestures =
mScreenOffGestureSharedPreferences.getBoolean(PREF_GESTURE_ENABLE, true);
mEnableGestures.setChecked(enableGestures);
mEnableGestures.setOnPreferenceChangeListener(this);
mCheckPreferences = true;
return prefs;
}
private void setupOrUpdatePreference(Preference preference, String action) {
if (preference == null || action == null) {
return;
}
if (action.startsWith("**")) {
preference.setSummary(getDescription(action));
} else {
preference.setSummary(AppHelper.getFriendlyNameForUri(
getActivity(), getActivity().getPackageManager(), action));
}
preference.setOnPreferenceClickListener(this);
}
private String getDescription(String action) {
if (sFinalActionDialogArray == null || action == null) {
return null;
}
int i = 0;
for (String actionValue : sFinalActionDialogArray.values) {
if (action.equals(actionValue)) {
return sFinalActionDialogArray.entries[i];
}
i++;
}
return null;
}
@Override
public boolean onPreferenceClick(Preference preference) {
String settingsKey = null;
int dialogTitle = 0;
if (preference == mGestureCircle) {
settingsKey = PREF_GESTURE_CIRCLE;
dialogTitle = R.string.gesture_circle_title;
} else if (preference == mGestureDoubleSwipe) {
settingsKey = PREF_GESTURE_DOUBLE_SWIPE;
dialogTitle = R.string.gesture_double_swipe_title;
} else if (preference == mGestureArrowUp) {
settingsKey = PREF_GESTURE_ARROW_UP;
dialogTitle = R.string.gesture_arrow_up_title;
} else if (preference == mGestureArrowDown) {
settingsKey = PREF_GESTURE_ARROW_DOWN;
dialogTitle = R.string.gesture_arrow_down_title;
} else if (preference == mGestureArrowLeft) {
settingsKey = PREF_GESTURE_ARROW_LEFT;
dialogTitle = R.string.gesture_arrow_left_title;
} else if (preference == mGestureArrowRight) {
settingsKey = PREF_GESTURE_ARROW_RIGHT;
dialogTitle = R.string.gesture_arrow_right_title;
}
if (settingsKey != null) {
showDialogInner(DLG_SHOW_ACTION_DIALOG, settingsKey, dialogTitle);
return true;
}
return false;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!mCheckPreferences) {
return false;
}
if (preference == mEnableGestures) {
mScreenOffGestureSharedPreferences.edit()
.putBoolean(PREF_GESTURE_ENABLE, (Boolean) newValue).commit();
KernelControl.enableGestures((Boolean) newValue);
return true;
}
return false;
}
// Reset all entries to default.
private void resetToDefault() {
SharedPreferences.Editor editor = mScreenOffGestureSharedPreferences.edit();
mScreenOffGestureSharedPreferences.edit()
.putBoolean(PREF_GESTURE_ENABLE, true).commit();
editor.putString(PREF_GESTURE_CIRCLE,
ActionConstants.ACTION_CAMERA).commit();
editor.putString(PREF_GESTURE_DOUBLE_SWIPE,
ActionConstants.ACTION_MEDIA_PLAY_PAUSE).commit();
editor.putString(PREF_GESTURE_ARROW_UP,
ActionConstants.ACTION_TORCH).commit();
editor.putString(PREF_GESTURE_ARROW_DOWN,
ActionConstants.ACTION_VIB_SILENT).commit();
editor.putString(PREF_GESTURE_ARROW_LEFT,
ActionConstants.ACTION_MEDIA_PREVIOUS).commit();
editor.putString(PREF_GESTURE_ARROW_RIGHT,
ActionConstants.ACTION_MEDIA_NEXT).commit();
editor.commit();
KernelControl.enableGestures(true);
reloadSettings();
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void shortcutPicked(String action,
String description, Bitmap bmp, boolean isApplication) {
if (mPendingSettingsKey == null || action == null) {
return;
}
mScreenOffGestureSharedPreferences.edit().putString(mPendingSettingsKey, action).commit();
reloadSettings();
mPendingSettingsKey = null;
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == ShortcutPickerHelper.REQUEST_PICK_SHORTCUT
|| requestCode == ShortcutPickerHelper.REQUEST_PICK_APPLICATION
|| requestCode == ShortcutPickerHelper.REQUEST_CREATE_SHORTCUT) {
mPicker.onActivityResult(requestCode, resultCode, data);
}
} else {
mPendingSettingsKey = null;
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_RESET:
showDialogInner(DLG_RESET_TO_DEFAULT, null, 0);
break;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.add(0, MENU_RESET, 0, R.string.reset)
.setIcon(R.drawable.ic_settings_reset)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}
private void showDialogInner(int id, String settingsKey, int dialogTitle) {
DialogFragment newFragment =
MyAlertDialogFragment.newInstance(id, settingsKey, dialogTitle);
newFragment.setTargetFragment(this, 0);
newFragment.show(getFragmentManager(), "dialog " + id);
}
public static class MyAlertDialogFragment extends DialogFragment {
public static MyAlertDialogFragment newInstance(
int id, String settingsKey, int dialogTitle) {
MyAlertDialogFragment frag = new MyAlertDialogFragment();
Bundle args = new Bundle();
args.putInt("id", id);
args.putString("settingsKey", settingsKey);
args.putInt("dialogTitle", dialogTitle);
frag.setArguments(args);
return frag;
}
ScreenOffGesture getOwner() {
return (ScreenOffGesture) getTargetFragment();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
int id = getArguments().getInt("id");
final String settingsKey = getArguments().getString("settingsKey");
int dialogTitle = getArguments().getInt("dialogTitle");
switch (id) {
case DLG_SHOW_ACTION_DIALOG:
if (sFinalActionDialogArray == null) {
return null;
}
return new AlertDialog.Builder(getActivity())
.setTitle(dialogTitle)
.setNegativeButton(R.string.cancel, null)
.setItems(getOwner().sFinalActionDialogArray.entries,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
if (getOwner().sFinalActionDialogArray.values[item]
.equals(ActionConstants.ACTION_APP)) {
if (getOwner().mPicker != null) {
getOwner().mPendingSettingsKey = settingsKey;
getOwner().mPicker.pickShortcut(getOwner().getId());
}
} else {
getOwner().mScreenOffGestureSharedPreferences.edit()
.putString(settingsKey,
getOwner().sFinalActionDialogArray.values[item]).commit();
getOwner().reloadSettings();
}
}
})
.create();
case DLG_RESET_TO_DEFAULT:
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.reset)
.setMessage(R.string.reset_message)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.dlg_ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
getOwner().resetToDefault();
}
})
.create();
}
throw new IllegalArgumentException("unknown id " + id);
}
@Override
public void onCancel(DialogInterface dialog) {
}
}
}
|
3e07e8ffe5a9ebf5112a5df74998c209827dbd8c | 1,788 | java | Java | annotations/crd-annotations/src/test/java/io/dekorate/crd/util/JsonSchemaTest.java | ppatierno/dekorate | fde89dd6263ac71a64ba439b34e3b47c361bb9f6 | [
"Apache-2.0"
] | null | null | null | annotations/crd-annotations/src/test/java/io/dekorate/crd/util/JsonSchemaTest.java | ppatierno/dekorate | fde89dd6263ac71a64ba439b34e3b47c361bb9f6 | [
"Apache-2.0"
] | null | null | null | annotations/crd-annotations/src/test/java/io/dekorate/crd/util/JsonSchemaTest.java | ppatierno/dekorate | fde89dd6263ac71a64ba439b34e3b47c361bb9f6 | [
"Apache-2.0"
] | null | null | null | 35.76 | 132 | 0.752796 | 3,348 | /**
* Copyright 2018 The original authors.
*
* 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 io.dekorate.crd.util;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import io.dekorate.crd.example.person.Person;
import io.dekorate.crd.example.recipe.Recipe;
import io.dekorate.utils.Serialization;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaProps;
import io.sundr.codegen.functions.ClassTo;
import io.sundr.codegen.model.TypeDef;
class JsonSchemaTest {
@Test
void shouldCreateJsonSchemaFromClass() {
TypeDef person = ClassTo.TYPEDEF.apply(Person.class);
JSONSchemaProps schema = JsonSchema.from(person);
System.out.println(Serialization.asJson(schema));
assertNotNull(schema);
}
@Test
void shouldMapQuantityToObject() {
TypeDef recipe = ClassTo.TYPEDEF.apply(Recipe.class);
JSONSchemaProps schema = JsonSchema.from(recipe);
assertNotNull(schema);
assertTrue(schema.getProperties().containsKey("quantity"));
JSONSchemaProps quantity = schema.getProperties().get("quantity");
assertNotNull(quantity.getAnyOf());
assertTrue(quantity.getAllOf().stream().map(JSONSchemaProps::getType).allMatch(s -> s.equals("string") || s.equals("integer")));
}
}
|
3e07e94d0800fe892423539137ba9231f94cd7ee | 4,300 | java | Java | src/main/java/com/ziroom/qa/quality/defende/provider/execTask/controller/TaskTestCaseController.java | ziroom-oss/thanos | ebc6901c6e81c8521cd2a564e285702d1471ca3b | [
"Apache-1.1"
] | null | null | null | src/main/java/com/ziroom/qa/quality/defende/provider/execTask/controller/TaskTestCaseController.java | ziroom-oss/thanos | ebc6901c6e81c8521cd2a564e285702d1471ca3b | [
"Apache-1.1"
] | null | null | null | src/main/java/com/ziroom/qa/quality/defende/provider/execTask/controller/TaskTestCaseController.java | ziroom-oss/thanos | ebc6901c6e81c8521cd2a564e285702d1471ca3b | [
"Apache-1.1"
] | null | null | null | 45.263158 | 131 | 0.759535 | 3,349 | package com.ziroom.qa.quality.defende.provider.execTask.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ziroom.qa.quality.defende.provider.caseRepository.entity.TestCase;
import com.ziroom.qa.quality.defende.provider.caseRepository.entity.dto.SingleApiCaseListDto;
import com.ziroom.qa.quality.defende.provider.execTask.entity.TaskTestCase;
import com.ziroom.qa.quality.defende.provider.execTask.service.TaskTestCaseService;
import com.ziroom.qa.quality.defende.provider.result.RestResultVo;
import com.ziroom.qa.quality.defende.provider.vo.Pagination;
import com.ziroom.qa.quality.defende.provider.vo.TaskTestCaseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Api(value = "测试执行任务关联的测试用例集合", tags = {"测试执行任务关联的测试用例集合"})
@Slf4j
@RestController
@RequestMapping("/taskTestCase")
public class TaskTestCaseController {
@Autowired
private TaskTestCaseService taskTestCaseService;
@ApiOperation("测试执行批量关联测试用例")
@PostMapping("/batchSaveOrUpdateTaskTestCase")
public RestResultVo batchSaveOrUpdateTaskTestCase(@RequestHeader String userName, @RequestBody TaskTestCaseVo taskTestCaseVo) {
try {
taskTestCaseService.batchSaveOrUpdateTaskTestCase(taskTestCaseVo, userName);
return RestResultVo.fromSuccess("关联成功");
} catch (Exception e) {
return RestResultVo.fromErrorMessage("关联失败");
}
}
@ApiOperation("根据测试执行任务ID获取关联用例集合列表")
@GetMapping("/getTaskTestCaseListByTaskId")
public RestResultVo<List<TaskTestCase>> getTaskTestCaseListByTaskId(@RequestParam Long taskId) {
return RestResultVo.fromData(taskTestCaseService.getTaskTestCaseByTaskId(taskId));
}
@ApiOperation("批量删除关联测试执行用例列表")
@PostMapping("/batchDeleteTaskTestCase")
public RestResultVo batchDeleteTaskTestCase(@RequestHeader String userName, @RequestBody TaskTestCaseVo taskTestCaseVo) {
taskTestCaseVo.setUserName(userName);
taskTestCaseService.batchDeleteTaskTestCase(taskTestCaseVo);
return RestResultVo.fromSuccess("删除成功");
}
@ApiOperation("数据清洗-清洗创建人和更新的用户信息")
@GetMapping("/updateTaskTestCaseUserInfo")
public RestResultVo updateTaskTestCaseUserInfo() {
boolean result = taskTestCaseService.updateTaskTestCaseUserInfo();
return RestResultVo.fromData(result);
}
@ApiOperation("分页查询已关联的测试用例")
@PostMapping(value = "/queryRelTestCaseByPage", produces = {"application/json;charset=UTF-8"})
public RestResultVo<Page<TaskTestCase>> queryRelTestCaseByPage(@RequestBody Pagination<TaskTestCase> pagination) {
RestResultVo restResultVo;
try {
Page<TaskTestCase> page = taskTestCaseService.queryRelTestCaseByPage(pagination);
restResultVo = RestResultVo.fromData(page);
} catch (Exception e) {
log.error("/taskTestCase/queryRelTestCaseByPage uid=={} 分页查询已关联的测试用例失败!", e);
restResultVo = RestResultVo.fromErrorMessage(e.getMessage());
}
return restResultVo;
}
@ApiOperation("分页查询未关联的测试用例(自动)")
@PostMapping(value = "/queryUnRelApiCaseByPage", produces = {"application/json;charset=UTF-8"})
public RestResultVo queryUnRelApiCaseByPage(@RequestBody Pagination<SingleApiCaseListDto> pagination) {
return RestResultVo.fromData(taskTestCaseService.queryUnRelApiCaseByPage(pagination));
}
@ApiOperation("分页查询未关联的测试用例(人工)")
@PostMapping(value = "/queryUnRelTestCaseByPage", produces = {"application/json;charset=UTF-8"})
public RestResultVo<Page<TestCase>> queryUnRelTestCaseByPage(@RequestBody Pagination<TestCase> pagination) {
Page<TestCase> page = taskTestCaseService.queryUnRelTestCaseByPage(pagination);
return RestResultVo.fromData(page);
}
@ApiOperation("获取测试用例详情信息(已关联的)")
@GetMapping("/getCaseDetailById")
public RestResultVo getCaseDetailById(@RequestHeader String userName, @RequestParam Long id) {
TaskTestCase taskTestCase = taskTestCaseService.getCaseDetailById(id);
return RestResultVo.fromData(taskTestCase);
}
}
|
3e07e9d2b5fab555b396e731cf2443499adf9bed | 235 | java | Java | HW14-Spring/src/main/java/com/oneso/hibernate/core/service/ServiceAddress.java | TheOneSo/JavaSE_Gradle | a62cf51ca44b786b770b25481133d47cefe84537 | [
"MIT"
] | null | null | null | HW14-Spring/src/main/java/com/oneso/hibernate/core/service/ServiceAddress.java | TheOneSo/JavaSE_Gradle | a62cf51ca44b786b770b25481133d47cefe84537 | [
"MIT"
] | null | null | null | HW14-Spring/src/main/java/com/oneso/hibernate/core/service/ServiceAddress.java | TheOneSo/JavaSE_Gradle | a62cf51ca44b786b770b25481133d47cefe84537 | [
"MIT"
] | null | null | null | 18.076923 | 46 | 0.787234 | 3,350 | package com.oneso.hibernate.core.service;
import com.oneso.hibernate.core.model.Address;
import java.util.Optional;
public interface ServiceAddress {
long saveAddress(Address address);
Optional<Address> getAddress(long id);
}
|
3e07ec46f6c7b3d2f5e7d3df65d07d33a25446f3 | 1,245 | java | Java | gravitee-am-service/src/main/java/io/gravitee/am/service/exception/UserInvalidException.java | StratoAG/graviteeio-access-management | 985571a4becb50694dc8ca227bdf031058653bee | [
"Apache-2.0"
] | 122 | 2016-12-08T18:11:50.000Z | 2021-07-15T11:25:26.000Z | gravitee-am-service/src/main/java/io/gravitee/am/service/exception/UserInvalidException.java | StratoAG/graviteeio-access-management | 985571a4becb50694dc8ca227bdf031058653bee | [
"Apache-2.0"
] | 362 | 2016-12-09T17:24:37.000Z | 2021-07-05T19:48:49.000Z | gravitee-am-service/src/main/java/io/gravitee/am/service/exception/UserInvalidException.java | StratoAG/graviteeio-access-management | 985571a4becb50694dc8ca227bdf031058653bee | [
"Apache-2.0"
] | 94 | 2017-07-20T20:37:54.000Z | 2021-06-16T13:56:40.000Z | 28.295455 | 75 | 0.706827 | 3,351 | /**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* 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 io.gravitee.am.service.exception;
/**
* @author Titouan COMPIEGNE (titouan.compiegne at graviteesource.com)
* @author GraviteeSource Team
*/
public class UserInvalidException extends AbstractManagementException {
public UserInvalidException() {
}
public UserInvalidException(Throwable cause) {
super(cause);
}
public UserInvalidException(String message) {
super(message);
}
public UserInvalidException(String message, Throwable cause) {
super(message, cause);
}
@Override
public int getHttpStatusCode() {
return 400;
}
}
|
3e07ed01b5cbdc2ef51f71af363bf2b994690ecc | 7,664 | java | Java | src/main/java/com/dimple/utils/VerifyCodeUtil.java | DongShiyuan123/online_exam_system-master | 1cef8ca4c610ce08c8e8e15aeda29309e322f897 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/dimple/utils/VerifyCodeUtil.java | DongShiyuan123/online_exam_system-master | 1cef8ca4c610ce08c8e8e15aeda29309e322f897 | [
"Apache-2.0"
] | 3 | 2020-05-15T22:27:27.000Z | 2021-12-09T22:13:48.000Z | src/main/java/com/dimple/utils/VerifyCodeUtil.java | DongShiyuan123/online_exam_system-master | 1cef8ca4c610ce08c8e8e15aeda29309e322f897 | [
"Apache-2.0"
] | null | null | null | 35.481481 | 207 | 0.495433 | 3,352 | package com.dimple.utils;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Random;
/**
* 验证码生成器
* @see --------------------------------------------------------------------------------------------------------------
* @see 可生成数字、大写、小写字母及三者混合类型的验证码
* @see 支持自定义验证码字符数量,支持自定义验证码图片的大小,支持自定义需排除的特殊字符,支持自定义干扰线的数量,支持自定义验证码图文颜色
* @see --------------------------------------------------------------------------------------------------------------
* @see 另外,给Shiro加入验证码有多种方式,也可以通过继承修改FormAuthenticationFilter类,通过Shiro去验证验证码
* @see 而这里既然使用了SpringMVC,也为了简化操作,就使用此工具生成验证码,并在Controller中处理验证码的校验
* @see --------------------------------------------------------------------------------------------------------------
*/
public class VerifyCodeUtil {
/**
* 验证码类型为仅数字,即0~9
*/
public static final int TYPE_NUM_ONLY = 0;
/**
* 验证码类型为仅字母,即大小写字母混合
*/
public static final int TYPE_LETTER_ONLY = 1;
/**
* 验证码类型为数字和大小写字母混合
*/
public static final int TYPE_ALL_MIXED = 2;
/**
* 验证码类型为数字和大写字母混合
*/
public static final int TYPE_NUM_UPPER = 3;
/**
* 验证码类型为数字和小写字母混合
*/
public static final int TYPE_NUM_LOWER = 4;
/**
* 验证码类型为仅大写字母
*/
public static final int TYPE_UPPER_ONLY = 5;
/**
* 验证码类型为仅小写字母
*/
public static final int TYPE_LOWER_ONLY = 6;
private VerifyCodeUtil(){}
/**
* 生成随机颜色
*/
private static Color generateRandomColor() {
Random random = new Random();
return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
}
/**
* 生成图片验证码
* @param type 验证码类型,参见本类的静态属性
* @param length 验证码字符长度,要求大于0的整数
* @param excludeString 需排除的特殊字符
* @param width 图片宽度(注意此宽度若过小,容易造成验证码文本显示不全,如4个字符的文本可使用85到90的宽度)
* @param height 图片高度
* @param interLine 图片中干扰线的条数
* @param randomLocation 每个字符的高低位置是否随机
* @param backColor 图片颜色,若为null则表示采用随机颜色
* @param foreColor 字体颜色,若为null则表示采用随机颜色
* @param lineColor 干扰线颜色,若为null则表示采用随机颜色
* @return 图片缓存对象
*/
public static BufferedImage generateImageCode(int type, int length, String excludeString, int width, int height, int interLine, boolean randomLocation, Color backColor, Color foreColor, Color lineColor){
String textCode = generateTextCode(type, length, excludeString);
return generateImageCode(textCode, width, height, interLine, randomLocation, backColor, foreColor, lineColor);
}
/**
* 生成验证码字符串
* @param type 验证码类型,参见本类的静态属性
* @param length 验证码长度,要求大于0的整数
* @param excludeString 需排除的特殊字符(无需排除则为null)
* @return 验证码字符串
*/
public static String generateTextCode(int type, int length, String excludeString){
if(length <= 0){
return "";
}
StringBuffer verifyCode = new StringBuffer();
int i = 0;
Random random = new Random();
switch(type){
case TYPE_NUM_ONLY:
while(i < length){
int t = random.nextInt(10);
//排除特殊字符
if(null==excludeString || excludeString.indexOf(t+"")<0) {
verifyCode.append(t);
i++;
}
}
break;
case TYPE_LETTER_ONLY:
while(i < length){
int t = random.nextInt(123);
if((t>=97 || (t>=65&&t<=90)) && (null==excludeString||excludeString.indexOf((char)t)<0)){
verifyCode.append((char)t);
i++;
}
}
break;
case TYPE_ALL_MIXED:
while(i < length){
int t = random.nextInt(123);
if((t>=97 || (t>=65&&t<=90) || (t>=48&&t<=57)) && (null==excludeString||excludeString.indexOf((char)t)<0)){
verifyCode.append((char)t);
i++;
}
}
break;
case TYPE_NUM_UPPER:
while(i < length){
int t = random.nextInt(91);
if((t>=65 || (t>=48&&t<=57)) && (null==excludeString || excludeString.indexOf((char)t)<0)){
verifyCode.append((char)t);
i++;
}
}
break;
case TYPE_NUM_LOWER:
while(i < length){
int t = random.nextInt(123);
if((t>=97 || (t>=48&&t<=57)) && (null==excludeString || excludeString.indexOf((char)t)<0)){
verifyCode.append((char)t);
i++;
}
}
break;
case TYPE_UPPER_ONLY:
while(i < length){
int t = random.nextInt(91);
if((t >= 65) && (null==excludeString||excludeString.indexOf((char)t)<0)){
verifyCode.append((char)t);
i++;
}
}
break;
case TYPE_LOWER_ONLY:
while(i < length){
int t = random.nextInt(123);
if((t>=97) && (null==excludeString||excludeString.indexOf((char)t)<0)){
verifyCode.append((char)t);
i++;
}
}
break;
}
return verifyCode.toString();
}
/**
* 已有验证码,生成验证码图片
* @param textCode 文本验证码
* @param width 图片宽度(注意此宽度若过小,容易造成验证码文本显示不全,如4个字符的文本可使用85到90的宽度)
* @param height 图片高度
* @param interLine 图片中干扰线的条数
* @param randomLocation 每个字符的高低位置是否随机
* @param backColor 图片颜色,若为null则表示采用随机颜色
* @param foreColor 字体颜色,若为null则表示采用随机颜色
* @param lineColor 干扰线颜色,若为null则表示采用随机颜色
* @return 图片缓存对象
*/
public static BufferedImage generateImageCode(String textCode, int width, int height, int interLine, boolean randomLocation, Color backColor, Color foreColor, Color lineColor){
//创建内存图像
BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
//获取图形上下文
Graphics graphics = bufferedImage.getGraphics();
//画背景图
graphics.setColor(null==backColor ? generateRandomColor() : backColor);
graphics.fillRect(0, 0, width, height);
//画干扰线
Random random = new Random();
if(interLine > 0){
int x = 0, y = 0, x1 = width, y1 = 0;
for(int i=0; i<interLine; i++){
graphics.setColor(null==lineColor ? generateRandomColor() : lineColor);
y = random.nextInt(height);
y1 = random.nextInt(height);
graphics.drawLine(x, y, x1, y1);
}
}
//字体大小为图片高度的80%
int fsize = (int)(height * 0.8);
int fx = height - fsize;
int fy = fsize;
//设定字体
graphics.setFont(new Font("微软雅黑", Font.BOLD, fsize));
//写验证码字符
for(int i=0; i<textCode.length(); i++){
fy = randomLocation ? (int)((Math.random()*0.3+0.6)*height) : fy;
graphics.setColor(null==foreColor ? generateRandomColor() : foreColor);
//将验证码字符显示到图象中
graphics.drawString(textCode.charAt(i)+"", fx, fy);
fx += fsize * 0.9;
}
graphics.dispose();
return bufferedImage;
}
}
|
3e07ed8d67fee517401be006c55ce7f2bfc9813b | 717 | java | Java | spring-boot-sample-quartz/src/main/java/com/wxs/quartz/job/Job1.java | wuxinshui/spring-boot-samples | c930257fa143329268483c034c9beee550635749 | [
"Apache-2.0"
] | 19 | 2017-06-16T03:35:33.000Z | 2021-06-03T06:03:09.000Z | spring-boot-sample-quartz/src/main/java/com/wxs/quartz/job/Job1.java | wuxinshui/spring-boot-samples | c930257fa143329268483c034c9beee550635749 | [
"Apache-2.0"
] | null | null | null | spring-boot-sample-quartz/src/main/java/com/wxs/quartz/job/Job1.java | wuxinshui/spring-boot-samples | c930257fa143329268483c034c9beee550635749 | [
"Apache-2.0"
] | 24 | 2017-10-27T08:33:04.000Z | 2020-05-21T03:30:50.000Z | 23.129032 | 89 | 0.709902 | 3,353 | package com.wxs.quartz.job;
import com.wxs.quartz.util.LoggerUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
* @ClassName: Job1
* @author: [Wuxinshui]
* @CreateDate: 2017/8/7 18:21
* @UpdateUser: [Wuxinshui]
* @UpdateDate: 2017/8/7 18:21
* @UpdateRemark: [说明本次修改内容]
* @Description: [TODO(用一句话描述该文件做什么)]
* @version: [V1.0]
*/
public class Job1 implements Job {
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
try {
System.out.println("Job1:This is quartz print test!!! " + System.currentTimeMillis());
} catch (Exception e) {
LoggerUtil.error("Job1 exception:",e);
throw e;
}
}
}
|
3e07eea64782c008239cf0ebaf1896952ef9d063 | 1,662 | java | Java | core/src/main/java/org/judal/storage/table/SchemalessIndexableView.java | sergiomt/judal | bda7f8a34b6811e979edd988ec87d89f4c84450e | [
"Apache-2.0"
] | null | null | null | core/src/main/java/org/judal/storage/table/SchemalessIndexableView.java | sergiomt/judal | bda7f8a34b6811e979edd988ec87d89f4c84450e | [
"Apache-2.0"
] | 5 | 2020-03-04T21:41:43.000Z | 2021-11-06T23:33:41.000Z | core/src/main/java/org/judal/storage/table/SchemalessIndexableView.java | sergiomt/judal | bda7f8a34b6811e979edd988ec87d89f4c84450e | [
"Apache-2.0"
] | null | null | null | 36.933333 | 124 | 0.726835 | 3,354 | package org.judal.storage.table;
/**
* © Copyright 2016 the original author.
* This file is licensed under the Apache License version 2.0.
* 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.
*/
import javax.jdo.JDOException;
import org.judal.storage.Param;
import javax.jdo.FetchGroup;
/**
* <p>Interface for indexable views.</p>
* @author Sergio Montoro Ten
* @version 1.0
*/
public interface SchemalessIndexableView extends SchemalessView {
/**
* <p>Fetch records which columns contain a given set of values.</p>
* Using each Param name as a column name, return those records for which
* each column has the value held in its corresponding Param.
* This is to say, for example, if the Engine is JDBC and params are
* Param("col1", 1, "value1"), Param("col2", 2, "value2"), Param("col3", 3, "value3")
* then the resulting WHERE clause for the underlying SQL statement will be
* col1='value1' AND col2='value2' AND col3='value3'
* @param fetchGroup FetchGroup Columns to be fetched
* @param maxrows int Maximum number of records to return
* @param offset int
* @param params Param…
* @return RecordSet<<? extends Record>>
* @throws JDOException
*/
<R extends Record> RecordSet<R> fetch(FetchGroup fetchGroup, int maxrows, int offset, Param... params) throws JDOException;
} |
3e07eeabfa4b04b12ca682e96fff5cd880f370ad | 16,398 | java | Java | backend/src/main/java/com/diunipisocc/routeparser/RouteParser.java | di-unipi-socc/MR | 0c235be9d255ae4a5b27464239375ddaf15b1017 | [
"Apache-2.0"
] | null | null | null | backend/src/main/java/com/diunipisocc/routeparser/RouteParser.java | di-unipi-socc/MR | 0c235be9d255ae4a5b27464239375ddaf15b1017 | [
"Apache-2.0"
] | null | null | null | backend/src/main/java/com/diunipisocc/routeparser/RouteParser.java | di-unipi-socc/MR | 0c235be9d255ae4a5b27464239375ddaf15b1017 | [
"Apache-2.0"
] | null | null | null | 49.690909 | 103 | 0.338456 | 3,355 | package com.diunipisocc.routeparser;
import com.diunipisocc.routeparser.model.IntegrationArchitecture;
import com.diunipisocc.routeparser.model.IntegrationNode;
import com.diunipisocc.routeparser.utils.NODE_TYPE;
import com.diunipisocc.routeparser.utils.Utils;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseResult;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Node;
import com.google.gson.Gson;
import com.diunipisocc.routeparser.model.Channel;
import com.diunipisocc.routeparser.utils.ChoiceStruct;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class RouteParser {
private String rawRoute;
public IntegrationArchitecture A;
public RouteParser(@JsonProperty("route") String rawRoute){
this.rawRoute = rawRoute;
A = new IntegrationArchitecture();
}
public String getRoute(){
return rawRoute;
}
public void parseRoute(){
JavaParser parser = new JavaParser();
ParseResult<CompilationUnit> result = parser.parse(this.rawRoute);
Optional<Node> configureNode = null;
for (Node n : result.getResult().get().getChildNodes())
configureNode=findConfigureNode(n);
if(configureNode.isPresent()){
Optional<List<Node>> routes = null;
routes = findRoutes(configureNode.get());
if(routes.isPresent()) getNewNodesAndChannels(routes.get());
}else{
System.out.println("Insert a valid Java File");
}
}
private Optional<Node> findConfigureNode(Node node){
if(node.toString().equals("configure")) {
return node.getParentNode();
}
for (Node child : node.getChildNodes()){
Optional<Node> configureNode = findConfigureNode(child);
if(configureNode.isPresent())
return configureNode;
}
return Optional.empty();
}
private Optional<List<Node>> findRoutes(Node node) {
List<Node> routes = new ArrayList<>();
if(node.toString().startsWith("from")){
routes.add(node);
} else {
for (Node n : node.getChildNodes()) {
Optional<List<Node>> routesFound = findRoutes(n);
if (routesFound.isPresent()) {
routes = Stream.concat(routes.stream(), routesFound.get().stream())
.collect(Collectors.toList());
}
}
}
return Optional.of(routes);
}
private void getNewNodesAndChannels(List<Node> routes){
for (Node route : routes) {
List<String> commands = getCommands(route);
LinkedList<ChoiceStruct> choiceQueue = new LinkedList<>();
int choiceCount = 0;
boolean endFlag = false;
int previousNode = -1;
boolean startChoice = false;
for (int i = commands.size() - 1; i >= 0; i--) {
for (String nodeCommand : Utils.NodeCommands)
if (commands.get(i).startsWith(nodeCommand)) {
String arguments = commands.get(i).substring(nodeCommand.length() + 1);
arguments = arguments.substring(0, arguments.length() - 1);
IntegrationNode n = null;
int node_id = -1;
switch (nodeCommand) {
case "from":
case "wireTap":
case "bean":
case "aggregate":
case "split":
case "process":
case "filter":
case "convertBodyTo":
case "setHeader":
case "setProperty":
case "enrich":
case "translate":
case "wrap":
if(!arguments.equals(""))
n = new IntegrationNode(
-1,
Utils.matchCommand(nodeCommand) + " : " + arguments.trim(),
new ArrayList<>(),
new ArrayList<>()
);
else
n = new IntegrationNode(
-1,
Utils.matchCommand(nodeCommand),
new ArrayList<>(),
new ArrayList<>()
);
node_id = A.insertNode(n);
if (choiceCount > 0) { // IF I AM IN A CHOICE
if (endFlag) { //IF I AM THE FIRST NODE AFTER AN END COMMAND
for (int leaf : choiceQueue.getFirst().leaves)
A.insertChannel(new Channel(
leaf, null, node_id, null
));
choiceQueue.pop();
endFlag = false;
choiceCount--;
if (choiceCount > 0) {
choiceQueue.getFirst().lastID = node_id;
}
} else {
if (startChoice) {
A.insertChannel(new Channel(
choiceQueue.getFirst().lastChoiceID,
null,
node_id,
null
));
startChoice = false;
} else {
A.insertChannel(new Channel(
choiceQueue.getFirst().lastID,
null,
node_id,
null
));
}
choiceQueue.getFirst().lastID = node_id;
}
} else if (previousNode >= 0) { // IF I AM IN A STANDARD ROUTE
A.insertChannel(new Channel(
previousNode,
null,
node_id,
null
));
}
previousNode = node_id;
break;
case "to": //SEND TO ENDPOINT
case "recipientList":
String[] argument = arguments.split(",");
for (String s : argument) {
n = new IntegrationNode(
-1,
NODE_TYPE.ENDPOINT.toString() + " : " + s.trim(),
new ArrayList<>(),
new ArrayList<>());
node_id = A.insertNode(n);
n = A.getNodes().get(A.getNodes().size() - 1);
if (choiceCount > 0) { // IF I AM IN A CHOICE
if (endFlag) { //IF I AM THE FIRST NODE AFTER AN END COMMAND
for (int leaf : choiceQueue.getFirst().leaves)
A.insertChannel(new Channel(
leaf, null, node_id, null
));
choiceQueue.pop();
endFlag = false;
choiceCount--;
if (choiceCount > 0) {
choiceQueue.getFirst().lastID = -1;
startChoice = true;
}
} else {
if (startChoice) {
A.insertChannel(new Channel(
choiceQueue.getFirst().lastChoiceID,
null,
node_id,
null
));
} else {
A.insertChannel(new Channel(
choiceQueue.getFirst().lastID,
null,
node_id,
null
));
}
choiceQueue.getFirst().lastID = -1;
startChoice = true;
}
} else if (previousNode >= 0) { // IF I AM IN A STANDARD ROUTE
A.insertChannel(new Channel(
previousNode,
null,
node_id,
null
));
}
//previousNode = node_id;
}
break;
case "choice": //BRANCH THE ROUTE AMONG MULTIPLE SUB-ROUTES
case "multicast":
n = new IntegrationNode(
-1,
Utils.matchCommand(nodeCommand),
new ArrayList<>(),
new ArrayList<>()
);
node_id = A.insertNode(n);
if (choiceCount > 0) { // IF I AM IN A CHOICE
if (endFlag) { //IF I AM THE FIRST NODE AFTER AN END COMMAND
for (int leaf : choiceQueue.getFirst().leaves)
A.insertChannel(new Channel(
leaf, null, node_id, null
));
choiceQueue.pop();
endFlag = false;
choiceCount--;
if (choiceCount > 0) {
choiceQueue.getFirst().lastID = node_id;
}
} else { // I AM A STANDARD NODE IN A CHOICE
if (startChoice) {
A.insertChannel(new Channel(
choiceQueue.getFirst().lastChoiceID,
null,
node_id,
null
));
} else {
A.insertChannel(new Channel(
choiceQueue.getFirst().lastID,
null,
node_id,
null
));
}
choiceQueue.getFirst().lastID = node_id;
}
} else if (previousNode >= 0) { // IF I AM IN A STANDARD ROUTE
A.insertChannel(new Channel(
previousNode,
null,
node_id,
null
));
}
previousNode = node_id;
//CODE FOR CHANNELS
choiceCount++;
choiceQueue.push(new ChoiceStruct(node_id));
startChoice = true;
break;
case "endChoice": //END CHOICE BRANCH
if (choiceQueue.getFirst().lastID > 0)
choiceQueue.getFirst().leaves.add(choiceQueue.getFirst().lastID);
startChoice = true;
break;
case "end": // END ALL CHOICE BRANCHES AND COME BACK TO MAIN ROUTE
endFlag = true;
startChoice = false;
break;
default:
break;
}
break;
}
}
}
}
private static List<String> getCommands(Node route){
List<String> commands = new ArrayList<>();
List<Node> childs = route.getChildNodes();
if (childs.size()>=3 && Utils.NodeCommands.contains(childs.get(1).toString())){
String newCommand = childs.get(1) + "(";
for (int i = 2; i < childs.size()-1; i++) newCommand = newCommand + childs.get(i) + ", ";
newCommand = newCommand + childs.get(childs.size()-1) + ")";
commands.add(newCommand);
}else if (childs.size()==2){
boolean allLeaves = true;
for (Node c : childs){
if (!c.getChildNodes().isEmpty()){
allLeaves = false;
break;
}
}
if (allLeaves){
if (Utils.NodeCommands.contains(childs.get(0).toString()))
commands.add(childs.get(0) + "(" + childs.get(1) + ")");
}else{
if (Utils.NodeCommands.contains(childs.get(1).toString()))
commands.add(childs.get(1) + "(" + ")");
}
}
for (Node c : childs)
commands = Stream.concat(
commands.stream(),
getCommands(c).stream()).collect(Collectors.toList());
return commands;
}
public String getJSON(){
Gson gson = new Gson();
String jsonStr = gson.toJson(A);
return jsonStr;
}
}
|
3e07ef31b681e0d18eff156c1fe410d6e07783f0 | 5,295 | java | Java | trunk/src/main/java/uk/co/streefland/rhys/mapreduce/output/FlightInventory.java | rstreefland/MapReduce | ce2a279da34bbd2d1c2271b39dd9913a8f6a34ed | [
"MIT"
] | null | null | null | trunk/src/main/java/uk/co/streefland/rhys/mapreduce/output/FlightInventory.java | rstreefland/MapReduce | ce2a279da34bbd2d1c2271b39dd9913a8f6a34ed | [
"MIT"
] | null | null | null | trunk/src/main/java/uk/co/streefland/rhys/mapreduce/output/FlightInventory.java | rstreefland/MapReduce | ce2a279da34bbd2d1c2271b39dd9913a8f6a34ed | [
"MIT"
] | null | null | null | 36.267123 | 107 | 0.61492 | 3,356 | package uk.co.streefland.rhys.mapreduce.output;
import com.itextpdf.text.*;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.streefland.rhys.mapreduce.data.Flight;
import uk.co.streefland.rhys.mapreduce.framework.Pair;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.List;
/**
* Prints out the inventory and passenger list of each flight
* @author Rhys Streefland
* @version 1.0
*/
public class FlightInventory extends Output {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final List<Pair> flights;
public FlightInventory(List<Pair> flights) {
this.flights = flights;
}
public void toConsole() {
System.out.println("\nList of Flights");
System.out.println("---------------");
for (Pair pair : flights) {
String flightId = (String) pair.getKey();
Flight flight = (Flight) pair.getValue();
System.out.println("Flight ID: " + flightId);
System.out.println("Source airport IATA/FAA code: " + flight.getSourceAirportCode());
System.out.println("Destination airport IATA/FAA code: " + flight.getDestinationAirportCode());
System.out.println("Departure time: " + flight.getDepartureTime());
System.out.println("Arrival time: " + flight.getArrivalTime());
System.out.println("Flight Duration: " + flight.getDuration());
System.out.println("Passenger list:");
// Print each passenger
for (String passenger : flight.getPassengers()) {
System.out.println(" " + passenger);
}
System.out.print("\n\n");
}
}
public void toTextFile() throws FileNotFoundException {
String fileName = "output/flightslist.txt";
logger.info("Writing list of flights to file: " + fileName);
PrintWriter out = new PrintWriter(fileName);
out.println("\nList of Flights");
out.println("---------------");
for (Pair pair : flights) {
String flightId = (String) pair.getKey();
Flight flight = (Flight) pair.getValue();
out.println("Flight ID: " + flightId);
out.println("Source airport IATA/FAA code: " + flight.getSourceAirportCode());
out.println("Destination airport IATA/FAA code: " + flight.getDestinationAirportCode());
out.println("Departure time: " + flight.getDepartureTime());
out.println("Arrival time: " + flight.getArrivalTime());
out.println("Flight Duration: " + flight.getDuration());
out.println("Passenger list:");
// Print each passenger
for (String passenger : flight.getPassengers()) {
out.println(" " + passenger);
}
out.println("");
}
out.close();
}
public void toPDFFile() throws DocumentException, FileNotFoundException {
String fileName = "output/flightslist.pdf";
logger.info("Writing list of flights to file: " + fileName);
// Create and open the document
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(fileName));
document.open();
document.add(getPDFTitle());
Paragraph title1 = new Paragraph("List of Flights", FONT[1]);
title1.setSpacingAfter(15);
document.add(title1);
// Each flight is represented by a separate table
for (Pair pair : flights) {
PdfPTable table = new PdfPTable(2);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setSpacingAfter(15);
String flightId = (String) pair.getKey();
Flight flight = (Flight) pair.getValue();
table.addCell(new Phrase("Flight ID", FONT[2]));
table.addCell(new Phrase(flightId, FONT[2]));
table.addCell(new Phrase("Source airport IATA/FAA code"));
table.addCell(new Phrase(flight.getSourceAirportCode()));
table.addCell(new Phrase("Destination airport IATA/FAA code"));
table.addCell(new Phrase(flight.getDestinationAirportCode()));
table.addCell(new Phrase("Departure time"));
table.addCell(new Phrase(flight.getDepartureTime()));
table.addCell(new Phrase("Arrival time"));
table.addCell(new Phrase(flight.getArrivalTime()));
table.addCell(new Phrase("Flight duration"));
table.addCell(new Phrase(flight.getDuration()));
table.addCell(new Phrase("Passenger list"));
// Sub-table for passengers of current flight
PdfPTable passengerTable = new PdfPTable(2);
passengerTable.getDefaultCell().setBorder(0);
// Write each passenger
for (String passenger : flight.getPassengers()) {
passengerTable.addCell(new Phrase(passenger));
}
table.addCell(passengerTable);
document.add(table);
}
document.add(getPDFFooter());
document.close();
}
}
|
3e07ef5dd5771c3ebafcf5451f08e19ce9e80bd0 | 2,632 | java | Java | docs/sourcecodes/OpenBridge-base/ob-framework/src/main/java/com/harmazing/framework/authorization/filter/FilterChainProxy.java | gavin2lee/incubator-gl | c95623af811195c3e89513ec30e52862d6562add | [
"Apache-2.0"
] | 3 | 2016-07-25T03:47:06.000Z | 2019-11-18T08:42:00.000Z | docs/sourcecodes/OpenBridge-base/ob-framework/src/main/java/com/harmazing/framework/authorization/filter/FilterChainProxy.java | gavin2lee/incubator-gl | c95623af811195c3e89513ec30e52862d6562add | [
"Apache-2.0"
] | null | null | null | docs/sourcecodes/OpenBridge-base/ob-framework/src/main/java/com/harmazing/framework/authorization/filter/FilterChainProxy.java | gavin2lee/incubator-gl | c95623af811195c3e89513ec30e52862d6562add | [
"Apache-2.0"
] | 2 | 2019-11-18T08:41:53.000Z | 2020-09-11T08:53:18.000Z | 29.909091 | 78 | 0.723404 | 3,357 | package com.harmazing.framework.authorization.filter;
import java.io.IOException;
import java.util.List;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.harmazing.framework.util.UrlUtils;
public class FilterChainProxy implements Filter {
private static final Log logger = LogFactory.getLog(FilterChainProxy.class);
private List<Filter> filters;
public List<Filter> getFilters() {
return filters;
}
public void setFilters(List<Filter> filters) {
this.filters = filters;
}
public void init(FilterConfig filterConfig) throws ServletException {
for (int i = 0; i < filters.size(); i++)
filters.get(i).init(filterConfig);
}
public void destroy() {
for (int i = 0; i < filters.size(); i++)
filters.get(i).destroy();
}
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) arg0;
HttpServletResponse response = (HttpServletResponse) arg1;
if (filters == null || filters.size() == 0) {
if (logger.isDebugEnabled()) {
logger.debug(UrlUtils.buildRequestUrl(request)
+ (filters == null ? " has no matching filters"
: " has an empty filter list"));
}
chain.doFilter(request, response);
} else {
VirtualFilterChain vfc = new VirtualFilterChain(chain, filters);
vfc.doFilter(request, response);
}
}
private static class VirtualFilterChain implements FilterChain {
private final FilterChain originalChain;
private final List<Filter> additionalFilters;
private final int size;
private int currentPosition = 0;
private VirtualFilterChain(FilterChain chain,
List<Filter> additionalFilters) {
this.originalChain = chain;
this.additionalFilters = additionalFilters;
this.size = additionalFilters.size();
}
public void doFilter(ServletRequest request, ServletResponse response)
throws IOException, ServletException {
if (currentPosition == size) {
originalChain.doFilter(request, response);
} else {
currentPosition++;
Filter nextFilter = additionalFilters.get(currentPosition - 1);
nextFilter.doFilter(request, response, this);
}
}
}
}
|
3e07ef6e907cc338582e600883cd1ca94f0ff35c | 3,283 | java | Java | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/transformations/SourceTransformation.java | Shih-Wei-Hsu/flink | 3fed93d62d8f79627d4ded2dd1fae6fae91b36e8 | [
"MIT",
"Apache-2.0",
"MIT-0",
"BSD-3-Clause"
] | 41 | 2018-11-14T04:05:42.000Z | 2022-02-09T10:39:23.000Z | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/transformations/SourceTransformation.java | Shih-Wei-Hsu/flink | 3fed93d62d8f79627d4ded2dd1fae6fae91b36e8 | [
"MIT",
"Apache-2.0",
"MIT-0",
"BSD-3-Clause"
] | 15 | 2021-06-13T18:06:12.000Z | 2022-02-09T22:40:04.000Z | flink-streaming-java/src/main/java/org/apache/flink/streaming/api/transformations/SourceTransformation.java | Shih-Wei-Hsu/flink | 3fed93d62d8f79627d4ded2dd1fae6fae91b36e8 | [
"MIT",
"Apache-2.0",
"MIT-0",
"BSD-3-Clause"
] | 16 | 2019-01-04T09:19:03.000Z | 2022-01-10T14:34:31.000Z | 33.161616 | 141 | 0.780688 | 3,358 | /*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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 org.apache.flink.streaming.api.transformations;
import org.apache.flink.annotation.Internal;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.connector.source.Boundedness;
import org.apache.flink.api.connector.source.Source;
import org.apache.flink.api.connector.source.SourceSplit;
import org.apache.flink.api.dag.Transformation;
import org.apache.flink.streaming.api.operators.ChainingStrategy;
import java.util.Collections;
import java.util.List;
import static org.apache.flink.util.Preconditions.checkNotNull;
/**
* A {@link PhysicalTransformation} for {@link Source}.
*/
@Internal
public class SourceTransformation<OUT, SplitT extends SourceSplit, EnumChkT> extends PhysicalTransformation<OUT> implements WithBoundedness {
private final Source<OUT, SplitT, EnumChkT> source;
private final WatermarkStrategy<OUT> watermarkStrategy;
private ChainingStrategy chainingStrategy = ChainingStrategy.DEFAULT_CHAINING_STRATEGY;
/**
* Creates a new {@code Transformation} with the given name, output type and parallelism.
*
* @param name The name of the {@code Transformation}, this will be shown in Visualizations
* and the Log
* @param source The {@link Source} itself
* @param watermarkStrategy The {@link WatermarkStrategy} to use
* @param outputType The output type of this {@code Transformation}
* @param parallelism The parallelism of this {@code Transformation}
*/
public SourceTransformation(
String name,
Source<OUT, SplitT, EnumChkT> source,
WatermarkStrategy<OUT> watermarkStrategy,
TypeInformation<OUT> outputType,
int parallelism) {
super(name, outputType, parallelism);
this.source = source;
this.watermarkStrategy = watermarkStrategy;
}
public Source<OUT, SplitT, EnumChkT> getSource() {
return source;
}
public WatermarkStrategy<OUT> getWatermarkStrategy() {
return watermarkStrategy;
}
@Override
public Boundedness getBoundedness() {
return source.getBoundedness();
}
@Override
public List<Transformation<?>> getTransitivePredecessors() {
return Collections.singletonList(this);
}
@Override
public List<Transformation<?>> getInputs() {
return Collections.emptyList();
}
@Override
public void setChainingStrategy(ChainingStrategy chainingStrategy) {
this.chainingStrategy = checkNotNull(chainingStrategy);
}
public ChainingStrategy getChainingStrategy() {
return chainingStrategy;
}
}
|
3e07f03bcf92657214400a704935830150d7490f | 128 | java | Java | api/src/main/java/org/hashcode/Solver.java | alessandrodalbello/google-hash-code | 82549417284abc6a44af056c52d5e43d2197a37d | [
"MIT"
] | 2 | 2020-06-17T12:31:15.000Z | 2020-10-13T13:10:40.000Z | api/src/main/java/org/hashcode/Solver.java | alessandrodalbello/google-hash-code | 82549417284abc6a44af056c52d5e43d2197a37d | [
"MIT"
] | null | null | null | api/src/main/java/org/hashcode/Solver.java | alessandrodalbello/google-hash-code | 82549417284abc6a44af056c52d5e43d2197a37d | [
"MIT"
] | 1 | 2021-01-24T07:59:06.000Z | 2021-01-24T07:59:06.000Z | 16 | 71 | 0.75 | 3,359 | package org.hashcode;
public interface Solver<IN extends InputData, OUT extends OutputData> {
OUT solve(IN inputData);
}
|
3e07f06307ba9841aee8089cfab62fee2ca736c6 | 907 | java | Java | ogc-csw/src/main/java/io/arlas/server/ogc/csw/utils/CSWRequestType.java | gisaia/ARLAS-server | 864e3bfc32ba45e9e3b72ea774c984f0c8d5342a | [
"Apache-2.0"
] | 17 | 2018-04-04T07:57:54.000Z | 2022-02-10T14:24:12.000Z | ogc-csw/src/main/java/io/arlas/server/ogc/csw/utils/CSWRequestType.java | gisaia/ARLAS-server | 864e3bfc32ba45e9e3b72ea774c984f0c8d5342a | [
"Apache-2.0"
] | 879 | 2018-01-17T15:47:36.000Z | 2022-03-30T09:56:53.000Z | ogc-csw/src/main/java/io/arlas/server/ogc/csw/utils/CSWRequestType.java | gisaia/ARLAS-server | 864e3bfc32ba45e9e3b72ea774c984f0c8d5342a | [
"Apache-2.0"
] | 2 | 2019-03-24T17:45:17.000Z | 2019-03-29T04:54:47.000Z | 32.392857 | 63 | 0.748622 | 3,360 | /*
* Licensed to Gisaïa under one or more contributor
* license agreements. See the NOTICE.txt file distributed with
* this work for additional information regarding copyright
* ownership. Gisaïa licenses this file to you 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 io.arlas.server.ogc.csw.utils;
public enum CSWRequestType {
GetCapabilities,
GetRecordById,
GetRecords
}
|
3e07f084853fa9259336bb7565d8033571b33dd8 | 1,829 | java | Java | OPE/Auto_OPE/src/test/java/logicsSteps/ope001/LogicOpe001.java | HugoJr778/auto_OPE | a4f6a50d2ab6f83553ee64213705e2b6caf46205 | [
"Apache-2.0"
] | 1 | 2019-09-17T21:48:30.000Z | 2019-09-17T21:48:30.000Z | OPE/Auto_OPE/src/test/java/logicsSteps/ope001/LogicOpe001.java | HugoJr778/Auto_OPE | a4f6a50d2ab6f83553ee64213705e2b6caf46205 | [
"Apache-2.0"
] | null | null | null | OPE/Auto_OPE/src/test/java/logicsSteps/ope001/LogicOpe001.java | HugoJr778/Auto_OPE | a4f6a50d2ab6f83553ee64213705e2b6caf46205 | [
"Apache-2.0"
] | null | null | null | 31.534483 | 91 | 0.691635 | 3,361 | package logicsSteps.ope001;
import static org.junit.Assert.assertEquals;
import java.util.HashMap;
import chromeDriver.ConnectionDriver;
import opeValues.GeneratorValues;
import utils.UtilsOPE;
public class LogicOpe001 extends ConnectionDriver {
private HashMap<String, String> x;
public LogicOpe001() {
this.x = GeneratorValues.getData();
}
public void indoParaCasdatro() {
System.out.println(">>> Go Register...");
click(getElements().goRegister());
UtilsOPE.sleep(3000, ">>> Signing Up...");
}
public void preenchendoDados() {
System.out.println(">>> Filling in Data...");
sendKeys(getElements().inputName(), x.get("nome"));
sendKeys(getElements().inputCEP(), x.get("cep"));
click(getElements().clickSearchCEP());
UtilsOPE.sleep(10000, ">>> Waiting Content 'Endereço+Bairro', 'Estado' and 'Cidade'...");
sendKeys(getElements().inputCPF(), x.get("cpf"));
sendKeys(getElements().inputTel(), x.get("telefone"));
clickCheckBox(getElements().checkBoxCar());
UtilsOPE.sleep(3000, ">>> Clicking and Wainting CheckBox...");
sendKeys(getElements().inputModelCar(), x.get("carro"));
sendKeys(getElements().inputBoard(), x.get("placa"));
sendKeys(getElements().inputColor(), x.get("cor"));
click(getElements().btnRegister());
UtilsOPE.sleep(5000, ">>> Waiting Register...");
}
public void vouParaRelatorio() {
UtilsOPE.sleep(5000, ">>> Sleep and go Report...");
click(getElements().goReport());
scroll(0, 1500);
}
public void procuroCadastro() {
sendKeys(getElements().searchReport(), x.get("nome"));
UtilsOPE.sleep(3000, ">>> Search vaule in Report...");
}
public void validoDadosCadastrados() {
String value = getValue(getElements().fieldReport());
assertEquals(x.get("nome"), value);
System.out.println(">>> Successful registration of: " + value);
}
} |
3e07f0b7e6b7c82e17894f965f3899e2e836ccb1 | 5,449 | java | Java | src/main/java/org/lean/presentation/connector/hop/LeanPipelineConnector.java | mattcasters/lean-hop-plugins | f73a7545a9fe26834f79002ec2b4e602e4139165 | [
"Apache-2.0"
] | 1 | 2020-06-27T14:30:45.000Z | 2020-06-27T14:30:45.000Z | src/main/java/org/lean/presentation/connector/hop/LeanPipelineConnector.java | mattcasters/lean-hop-plugins | f73a7545a9fe26834f79002ec2b4e602e4139165 | [
"Apache-2.0"
] | 1 | 2021-10-13T15:41:36.000Z | 2021-10-13T15:41:36.000Z | src/main/java/org/lean/presentation/connector/hop/LeanPipelineConnector.java | mattcasters/lean-hop-plugins | f73a7545a9fe26834f79002ec2b4e602e4139165 | [
"Apache-2.0"
] | 1 | 2020-06-27T13:23:48.000Z | 2020-06-27T13:23:48.000Z | 38.64539 | 143 | 0.727289 | 3,362 | package org.lean.presentation.connector.hop;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.hop.core.HopEnvironment;
import org.apache.hop.core.exception.HopTransformException;
import org.apache.hop.core.logging.LogLevel;
import org.apache.hop.core.row.IRowMeta;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.pipeline.engine.IEngineComponent;
import org.apache.hop.pipeline.engine.IPipelineEngine;
import org.apache.hop.pipeline.engines.local.LocalPipelineEngine;
import org.apache.hop.pipeline.transform.RowAdapter;
import org.apache.hop.pipeline.transform.TransformMeta;
import org.lean.core.ILeanRowListener;
import org.lean.core.exception.LeanException;
import org.lean.presentation.connector.type.ILeanConnector;
import org.lean.presentation.connector.type.LeanBaseConnector;
import org.lean.presentation.connector.type.LeanConnectorPlugin;
import org.lean.presentation.datacontext.IDataContext;
import java.util.List;
@LeanConnectorPlugin( id = "LeanPipelineConnector", name = "Kettle", description = "Read from a Kettle transformation" )
public class LeanPipelineConnector extends LeanBaseConnector implements ILeanConnector {
@HopMetadataProperty
private String pipelineFilename;
@HopMetadataProperty
private String outputTransformName;
public LeanPipelineConnector() {
super( "LeanPipelineConnector" );
}
public LeanPipelineConnector( String pipelineFilename, String outputTransformName ) {
this();
this.pipelineFilename = pipelineFilename;
this.outputTransformName = outputTransformName;
}
public LeanPipelineConnector( LeanPipelineConnector c ) {
super( c );
this.pipelineFilename = c.pipelineFilename;
this.outputTransformName = c.outputTransformName;
}
@Override public LeanBaseConnector clone() {
return new LeanPipelineConnector( this );
}
@JsonIgnore
private transient IPipelineEngine<PipelineMeta> pipeline;
@Override public void startStreaming( IDataContext dataContext ) throws LeanException {
IVariables variables = dataContext.getVariables();
final String realPipelineFilename = variables.resolve( pipelineFilename );
final String realOutputTransformName = variables.resolve( outputTransformName );
try {
HopEnvironment.init();
PipelineMeta pipelineMeta = loadPipelineMeta( dataContext );
pipeline = new LocalPipelineEngine( pipelineMeta );
pipelineMeta.setInternalHopVariables( pipeline );
pipeline.setLogLevel( LogLevel.BASIC ); // TODO make configurable
pipeline.prepareExecution();
// Add a row listener to all transform copies
//
List<IEngineComponent> componentCopies = pipeline.getComponentCopies( realOutputTransformName );
for ( IEngineComponent componentCopy : componentCopies ) {
componentCopy.addRowListener( new RowAdapter() {
@Override public void rowWrittenEvent( IRowMeta rowMeta, Object[] row ) throws HopTransformException {
// Pass the row to all the listeners for this component...
//
for ( ILeanRowListener listener : LeanPipelineConnector.super.getRowListeners() ) {
try {
synchronized ( listener ) {
listener.rowReceived( rowMeta, row );
}
} catch ( LeanException e ) {
throw new HopTransformException( "Error passing row from Hop to Lean in pipeline '" + realPipelineFilename, e );
}
}
}
} );
}
pipeline.startThreads();
pipeline.waitUntilFinished();
outputDone();
} catch ( Exception e ) {
if ( pipeline != null ) {
pipeline.stopAll();
}
throw new LeanException( "Error running pipeline '" + realPipelineFilename + "'", e );
}
}
@Override public void waitUntilFinished() throws LeanException {
// Handled above
}
public IRowMeta describeOutput( IDataContext dataContext ) throws LeanException {
IVariables variables = dataContext.getVariables();
String realTransFilename = variables.resolve( pipelineFilename );
String realOutputStepname = variables.resolve( outputTransformName );
PipelineMeta pipelineMeta = loadPipelineMeta( dataContext );
TransformMeta outputTransformMeta = pipelineMeta.findTransform( realOutputStepname );
if ( outputTransformMeta == null ) {
throw new LeanException( "There is no transform called '" + outputTransformName + "' in pipeline '" + realTransFilename + "'" );
}
try {
return pipelineMeta.getTransformFields( variables, outputTransformMeta );
} catch ( Exception e ) {
throw new LeanException( "Error getting output fields for transform '" + realOutputStepname + "' in pipeline '" + realTransFilename, e );
}
}
private PipelineMeta loadPipelineMeta( IDataContext dataContext ) throws LeanException {
IVariables variables = dataContext.getVariables();
String realPipelineFilename = variables.resolve( pipelineFilename );
try {
PipelineMeta pipelineMeta = new PipelineMeta( realPipelineFilename, dataContext.getMetadataProvider(), true, variables );
return pipelineMeta;
} catch ( Exception e ) {
throw new LeanException( "Unable to load pipeline file '" + realPipelineFilename + "'", e );
}
}
}
|
3e07f10e4654bee22f594cbd067096fd30ea0318 | 1,364 | java | Java | salesmore-integration-shopee/src/main/java/com/salesmore/yak/integration/shopee/model/item/request/GetAttributes.java | tinybright/shopee4j | 02f41713ee3c5bc220da15d3727ab0ad8d096b30 | [
"Apache-2.0"
] | 11 | 2019-05-15T14:51:48.000Z | 2021-07-15T12:02:27.000Z | salesmore-integration-shopee/src/main/java/com/salesmore/yak/integration/shopee/model/item/request/GetAttributes.java | tinybright/shopee4j | 02f41713ee3c5bc220da15d3727ab0ad8d096b30 | [
"Apache-2.0"
] | 7 | 2019-06-17T06:07:37.000Z | 2021-12-14T21:12:16.000Z | salesmore-integration-shopee/src/main/java/com/salesmore/yak/integration/shopee/model/item/request/GetAttributes.java | tinybright/shopee4j | 02f41713ee3c5bc220da15d3727ab0ad8d096b30 | [
"Apache-2.0"
] | 18 | 2019-04-06T13:58:09.000Z | 2022-03-09T03:13:48.000Z | 29.652174 | 126 | 0.733138 | 3,363 | package com.salesmore.yak.integration.shopee.model.item.request;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.salesmore.yak.integration.shopee.model.BaseRequest;
import com.salesmore.yak.integration.shopee.model.common.Country;
import com.salesmore.yak.integration.shopee.model.item.Language;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
@Data
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public class GetAttributes extends BaseRequest {
private static final long serialVersionUID = 1L;
/**
* The Identify of category. Should call shopee.item.GetCategories to get category_id first.
* Attributes can ONLY be fetched for the category_id WITHOUT children.
*/
@JsonProperty("category_id")
private Long categoryId;
/**
* This value indicate the language of the attribute_name and options. Applicable values: en (for English), th (for Thai).
* And if there is no information in this language, we will return the default information.
* Now this param is only valid for Thailand sellers.
*/
private Language language;
/**
* Two-digit country code.
*/
private Country country;
/**
* Is cross-border or not. Should be provided if no "shopid".
*/
@JsonProperty("is_cb")
private boolean cb;
}
|
3e07f1612f630e2cc2ad502571ad2f840da81044 | 1,838 | java | Java | src/main/java/wtf/pants/stamp/obfuscator/ObfuscatorManager.java | Spacks/stamp-obfuscator | 0ad6faed2c1abcf843ef424e2cac83573b69a67c | [
"Apache-2.0"
] | 25 | 2017-01-20T12:36:05.000Z | 2022-01-14T01:57:39.000Z | src/main/java/wtf/pants/stamp/obfuscator/ObfuscatorManager.java | Spacks/stamp-obfuscator | 0ad6faed2c1abcf843ef424e2cac83573b69a67c | [
"Apache-2.0"
] | null | null | null | src/main/java/wtf/pants/stamp/obfuscator/ObfuscatorManager.java | Spacks/stamp-obfuscator | 0ad6faed2c1abcf843ef424e2cac83573b69a67c | [
"Apache-2.0"
] | 12 | 2017-05-27T11:55:40.000Z | 2021-04-15T22:33:59.000Z | 33.418182 | 114 | 0.682263 | 3,364 | package wtf.pants.stamp.obfuscator;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
import wtf.pants.stamp.Stamp;
import wtf.pants.stamp.obfuscator.obfuscators.*;
import wtf.pants.stamp.obfuscator.obfuscators.classes.ObfuscatorClasses;
import wtf.pants.stamp.util.Log;
import java.util.ArrayList;
import java.util.List;
/**
* @author Pants
*/
public class ObfuscatorManager {
private List<Obfuscator> obfuscatorList;
public ObfuscatorManager(Stamp stamp) {
this.obfuscatorList = new ArrayList<>();
this.obfuscatorList.add(new ObfuscatorMethods(stamp.getCollector()));
this.obfuscatorList.add(new ObfuscatorFields(stamp.getCollector()));
this.obfuscatorList.add(new ObfuscatorClasses(stamp.getCollector()));
this.obfuscatorList.add(new ObfuscatorStrings(stamp.getCollector()));
this.obfuscatorList.add(new ObfuscatorLocalVars(stamp.getCollector()));
}
public byte[] obfuscate(ClassReader cr, ClassNode cn) {
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
cr.accept(cn, 0);
obfuscatorList.stream()
.sorted((o1, o2) -> Integer.compare(o2.getPriority(), o1.getPriority())) //o1.get, o2.get
.filter(Obfuscator::isEnabled)
.forEach(o -> o.obfuscate(cr, cn, 0));
Log.debug("Accepting class: %s", cn.name);
cn.accept(cw);
Log.debug("Accepted class");
return cw.toByteArray();
}
/**
* Disables an obfuscation type.
*
* @param name The name of the obfuscation type to disable
*/
public void disableObfuscation(String name) {
obfuscatorList.stream().filter(o -> o.getName().equalsIgnoreCase(name)).forEach(o -> o.setEnabled(false));
}
}
|
3e07f1665cb96caa952e06e99a13c3602ad32c77 | 1,006 | java | Java | chapter3-synchronization_primitives/MBoundedBufferMonitor.java | vijaygarg1/Option3-Multicore | 5920069e43bfc62fb647a656cfe56145fffdf665 | [
"CC0-1.0"
] | 1 | 2016-08-24T03:13:44.000Z | 2016-08-24T03:13:44.000Z | chapter3-synchronization_primitives/MBoundedBufferMonitor.java | vijaygarg1/Option3-Multicore | 5920069e43bfc62fb647a656cfe56145fffdf665 | [
"CC0-1.0"
] | null | null | null | chapter3-synchronization_primitives/MBoundedBufferMonitor.java | vijaygarg1/Option3-Multicore | 5920069e43bfc62fb647a656cfe56145fffdf665 | [
"CC0-1.0"
] | 3 | 2016-08-24T21:47:16.000Z | 2020-12-12T17:04:31.000Z | 23.952381 | 58 | 0.588469 | 3,365 | import java.util.concurrent.locks.*;
class MBoundedBufferMonitor {
final int size = 10;
final ReentrantLock monitorLock = new ReentrantLock();
final Condition notFull = monitorLock.newCondition();
final Condition notEmpty = monitorLock.newCondition();
final Object[] buffer = new Object[size];
int inBuf=0, outBuf=0, count=0;
public void put(Object x) throws InterruptedException {
monitorLock.lock();
try {
while (count == buffer.length)
notFull.await();
buffer[inBuf] = x;
inBuf = (inBuf + 1) % size;
count++;
notEmpty.signal();
} finally {
monitorLock.unlock();
}
}
public Object take() throws InterruptedException {
monitorLock.lock();
try {
while (count == 0)
notEmpty.await();
Object x = buffer[outBuf];
outBuf = (outBuf + 1) % size;
count--;
notFull.signal();
return x;
} finally {
monitorLock.unlock();
}
}
}
|
3e07f177709aa90cd32867de49bf9acbe91e7c1e | 2,674 | java | Java | src/test/java/org/apache/ibatis/submitted/default_method/DefaultMethodTest.java | lice019/lice-mybatis | 2923b1ac656e1689ed9c5f3655dd40316b5fea23 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2020-05-29T00:08:32.000Z | 2020-05-29T00:08:32.000Z | src/test/java/org/apache/ibatis/submitted/default_method/DefaultMethodTest.java | lice019/lice-mybatis | 2923b1ac656e1689ed9c5f3655dd40316b5fea23 | [
"ECL-2.0",
"Apache-2.0"
] | 3 | 2021-12-10T01:45:32.000Z | 2022-02-16T01:12:13.000Z | src/test/java/org/apache/ibatis/submitted/default_method/DefaultMethodTest.java | lice019/lice-mybatis | 2923b1ac656e1689ed9c5f3655dd40316b5fea23 | [
"ECL-2.0",
"Apache-2.0"
] | 1 | 2020-01-11T10:41:54.000Z | 2020-01-11T10:41:54.000Z | 35.653333 | 97 | 0.737846 | 3,366 | /**
* Copyright ${license.git.copyrightYears} the original author or authors.
*
* 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 org.apache.ibatis.submitted.default_method;
import static org.junit.jupiter.api.Assertions.*;
import java.io.Reader;
import org.apache.ibatis.BaseDataTest;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.submitted.default_method.Mapper.SubMapper;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class DefaultMethodTest {
private static SqlSessionFactory sqlSessionFactory;
@BeforeAll
public static void setUp() throws Exception {
// create an SqlSessionFactory
try (Reader reader = Resources.getResourceAsReader(
"org/apache/ibatis/submitted/default_method/mybatis-config.xml")) {
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
}
// populate in-memory database
BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(),
"org/apache/ibatis/submitted/default_method/CreateDB.sql");
}
@Test
public void shouldInvokeDefaultMethod() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
Mapper mapper = sqlSession.getMapper(Mapper.class);
User user = mapper.defaultGetUser(1);
assertEquals("User1", user.getName());
}
}
@Test
public void shouldInvokeDefaultMethodOfSubclass() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
SubMapper mapper = sqlSession.getMapper(SubMapper.class);
User user = mapper.defaultGetUser("User1", 1);
assertEquals("User1", user.getName());
}
}
@Test
public void shouldInvokeDefaultMethodOfPackagePrivateMapper() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PackageMapper mapper = sqlSession.getMapper(PackageMapper.class);
User user = mapper.defaultGetUser(1);
assertEquals("User1", user.getName());
}
}
}
|
3e07f2b8c84c8315b4efe0efe3fa06c2e2990c0f | 1,298 | java | Java | addressbook-web-tests/src/test/java/ru/stqa/pft/addressbook/appmanager/ContactHelper.java | lordx14/java_ptf | 005dc39e460efe8f0dfb63e3329c1b6cd943c804 | [
"Apache-2.0"
] | null | null | null | addressbook-web-tests/src/test/java/ru/stqa/pft/addressbook/appmanager/ContactHelper.java | lordx14/java_ptf | 005dc39e460efe8f0dfb63e3329c1b6cd943c804 | [
"Apache-2.0"
] | null | null | null | addressbook-web-tests/src/test/java/ru/stqa/pft/addressbook/appmanager/ContactHelper.java | lordx14/java_ptf | 005dc39e460efe8f0dfb63e3329c1b6cd943c804 | [
"Apache-2.0"
] | null | null | null | 24.961538 | 99 | 0.713405 | 3,367 | package ru.stqa.pft.addressbook.appmanager;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.Select;
import org.testng.Assert;
import ru.stqa.pft.addressbook.model.ContactData;
import org.openqa.selenium.firefox.FirefoxDriver;
/**
* Created by user on 020 20.08.19.
*/
public class ContactHelper extends HelperBase {
public ContactHelper(WebDriver wd) {
super(wd);
}
public void initContactCreation() {
click(By.linkText("add new"));
}
public void fillContactForm(ContactData contactData, boolean creation) {
type(By.name("firstname"), contactData.getFirstname());
type(By.name("lastname"), contactData.getLastname());
if (creation) {
new Select(wd.findElement(By.name("new_group"))).selectByVisibleText(contactData.getGroup());
} else {
Assert.assertFalse(isElementPresent(By.name("new_group")));
}
}
public void submitContactCreation() {
click(By.name("submit"));
}
public void returnToHomePage() {
click(By.linkText("home page"));
}
public void initContactModification() {
click(By.cssSelector("img[alt='Edit']"));
}
public void submitContactModification() {
click(By.name("update"));
}
}
|
3e07f337ada77afcdd41f90e7f27c361dccc8b33 | 296 | java | Java | admin/src/main/java/com/vincent/admin/controller/TestController.java | NyaNekoplus/SoraBlog | 173655cb6925e051b99670fceacb2c3faec04c30 | [
"MIT"
] | null | null | null | admin/src/main/java/com/vincent/admin/controller/TestController.java | NyaNekoplus/SoraBlog | 173655cb6925e051b99670fceacb2c3faec04c30 | [
"MIT"
] | null | null | null | admin/src/main/java/com/vincent/admin/controller/TestController.java | NyaNekoplus/SoraBlog | 173655cb6925e051b99670fceacb2c3faec04c30 | [
"MIT"
] | null | null | null | 18.5 | 62 | 0.72973 | 3,368 | package com.vincent.admin.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
//@RestController
public class TestController {
@GetMapping(value = "/test")
String test(){
return "test";
}
}
|
3e07f47e35d22d62ee653155e6d7f4bf3e63e3ec | 4,732 | java | Java | services/server/src/main/java/com/ncloud/server/model/CreateBlockStorageInstanceResponse.java | NaverCloudPlatform/ncloud-sdk-java | f6c16c1f701de49411592bfdaf235a6265dc3f5c | [
"MIT"
] | null | null | null | services/server/src/main/java/com/ncloud/server/model/CreateBlockStorageInstanceResponse.java | NaverCloudPlatform/ncloud-sdk-java | f6c16c1f701de49411592bfdaf235a6265dc3f5c | [
"MIT"
] | 14 | 2020-06-30T21:26:48.000Z | 2020-12-22T18:05:27.000Z | services/server/src/main/java/com/ncloud/server/model/CreateBlockStorageInstanceResponse.java | NaverCloudPlatform/ncloud-sdk-java | f6c16c1f701de49411592bfdaf235a6265dc3f5c | [
"MIT"
] | null | null | null | 26.435754 | 127 | 0.754438 | 3,369 | /*
* server
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* OpenAPI spec version: 2021-03-04T10:39:42Z
*
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
package com.ncloud.server.model;
import java.util.Objects;
import com.ncloud.server.model.BlockStorageInstance;
import java.util.ArrayList;
import java.util.List;
/**
* CreateBlockStorageInstanceResponse
*/
public class CreateBlockStorageInstanceResponse {
private String requestId = null;
private String returnCode = null;
private String returnMessage = null;
private Integer totalRows = null;
private List<BlockStorageInstance> blockStorageInstanceList = null;
public CreateBlockStorageInstanceResponse requestId(String requestId) {
this.requestId = requestId;
return this;
}
/**
* Get requestId
* @return requestId
**/
public String getRequestId() {
return requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public CreateBlockStorageInstanceResponse returnCode(String returnCode) {
this.returnCode = returnCode;
return this;
}
/**
* Get returnCode
* @return returnCode
**/
public String getReturnCode() {
return returnCode;
}
public void setReturnCode(String returnCode) {
this.returnCode = returnCode;
}
public CreateBlockStorageInstanceResponse returnMessage(String returnMessage) {
this.returnMessage = returnMessage;
return this;
}
/**
* Get returnMessage
* @return returnMessage
**/
public String getReturnMessage() {
return returnMessage;
}
public void setReturnMessage(String returnMessage) {
this.returnMessage = returnMessage;
}
public CreateBlockStorageInstanceResponse totalRows(Integer totalRows) {
this.totalRows = totalRows;
return this;
}
/**
* Get totalRows
* @return totalRows
**/
public Integer getTotalRows() {
return totalRows;
}
public void setTotalRows(Integer totalRows) {
this.totalRows = totalRows;
}
public CreateBlockStorageInstanceResponse blockStorageInstanceList(List<BlockStorageInstance> blockStorageInstanceList) {
this.blockStorageInstanceList = blockStorageInstanceList;
return this;
}
public CreateBlockStorageInstanceResponse addBlockStorageInstanceListItem(BlockStorageInstance blockStorageInstanceListItem) {
if (this.blockStorageInstanceList == null) {
this.blockStorageInstanceList = new ArrayList<BlockStorageInstance>();
}
this.blockStorageInstanceList.add(blockStorageInstanceListItem);
return this;
}
/**
* Get blockStorageInstanceList
* @return blockStorageInstanceList
**/
public List<BlockStorageInstance> getBlockStorageInstanceList() {
return blockStorageInstanceList;
}
public void setBlockStorageInstanceList(List<BlockStorageInstance> blockStorageInstanceList) {
this.blockStorageInstanceList = blockStorageInstanceList;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CreateBlockStorageInstanceResponse createBlockStorageInstanceResponse = (CreateBlockStorageInstanceResponse) o;
return Objects.equals(this.requestId, createBlockStorageInstanceResponse.requestId) &&
Objects.equals(this.returnCode, createBlockStorageInstanceResponse.returnCode) &&
Objects.equals(this.returnMessage, createBlockStorageInstanceResponse.returnMessage) &&
Objects.equals(this.totalRows, createBlockStorageInstanceResponse.totalRows) &&
Objects.equals(this.blockStorageInstanceList, createBlockStorageInstanceResponse.blockStorageInstanceList);
}
@Override
public int hashCode() {
return Objects.hash(requestId, returnCode, returnMessage, totalRows, blockStorageInstanceList);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateBlockStorageInstanceResponse {\n");
sb.append(" requestId: ").append(toIndentedString(requestId)).append("\n");
sb.append(" returnCode: ").append(toIndentedString(returnCode)).append("\n");
sb.append(" returnMessage: ").append(toIndentedString(returnMessage)).append("\n");
sb.append(" totalRows: ").append(toIndentedString(totalRows)).append("\n");
sb.append(" blockStorageInstanceList: ").append(toIndentedString(blockStorageInstanceList)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
|
3e07f537a322545ffccf5c1d553bcec599da39af | 835 | java | Java | Lib/src/com/gnps/lib/net/NetAdapter.java | cb0s/GNPS | 406ea91d9cd1db5be51378e4b270599160b09af0 | [
"MIT"
] | 1 | 2020-11-24T10:14:28.000Z | 2020-11-24T10:14:28.000Z | Lib/src/com/gnps/lib/net/NetAdapter.java | cb0s/GNPS | 406ea91d9cd1db5be51378e4b270599160b09af0 | [
"MIT"
] | null | null | null | Lib/src/com/gnps/lib/net/NetAdapter.java | cb0s/GNPS | 406ea91d9cd1db5be51378e4b270599160b09af0 | [
"MIT"
] | null | null | null | 29.821429 | 104 | 0.71018 | 3,370 | package com.gnps.lib.net;
import java.net.InetSocketAddress;
import com.gnps.lib.protocol.definition.MessageType;
/**
* A custom implementation of {@link Thread} which as long as the Thread is alive
* (<code>!{@link #isInterrupted()}</code>) calls {@link #receive()}.<br>
* <br>
* Further implementations must still implement {@link #send(InetSocketAddress, MessageType, String)},
* {@link #onReceive(String)} and {@link #receive()}.<br>
* <br>
* The advantage of this is that the event-like structure of {@link NetReceiver} is already implemented.
*
* @author Cedric Boes
* @version 1.0
*/
public abstract class NetAdapter extends Thread implements NetReceiver, NetSender {
@Override
public void run() {
while (!Thread.currentThread().isInterrupted()) {
receive();
}
Thread.currentThread().interrupt();
}
}
|
3e07f5ca1f86e7ff0374ba7632c3f607a258691d | 149,854 | java | Java | src/main/java/ezvcard/VCard.java | mangstadt/ez-vcard | 96e455b1e798b71c01973fde08d519a9659ed97d | [
"BSD-2-Clause-FreeBSD"
] | 368 | 2015-03-27T12:37:51.000Z | 2022-02-28T11:20:00.000Z | src/main/java/ezvcard/VCard.java | mangstadt/ez-vcard | 96e455b1e798b71c01973fde08d519a9659ed97d | [
"BSD-2-Clause-FreeBSD"
] | 98 | 2015-05-06T20:44:18.000Z | 2022-03-11T16:36:53.000Z | src/main/java/ezvcard/VCard.java | mangstadt/ez-vcard | 96e455b1e798b71c01973fde08d519a9659ed97d | [
"BSD-2-Clause-FreeBSD"
] | 103 | 2015-03-25T23:53:00.000Z | 2021-12-12T20:15:12.000Z | 32.484717 | 154 | 0.661079 | 3,371 | package ezvcard;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.transform.TransformerException;
import ezvcard.io.html.HCardPage;
import ezvcard.io.json.JCardWriter;
import ezvcard.io.text.VCardWriter;
import ezvcard.io.xml.XCardWriter;
import ezvcard.parameter.EmailType;
import ezvcard.parameter.TelephoneType;
import ezvcard.parameter.VCardParameters;
import ezvcard.property.Address;
import ezvcard.property.Agent;
import ezvcard.property.Anniversary;
import ezvcard.property.Birthday;
import ezvcard.property.Birthplace;
import ezvcard.property.CalendarRequestUri;
import ezvcard.property.CalendarUri;
import ezvcard.property.Categories;
import ezvcard.property.Classification;
import ezvcard.property.ClientPidMap;
import ezvcard.property.Deathdate;
import ezvcard.property.Deathplace;
import ezvcard.property.Email;
import ezvcard.property.Expertise;
import ezvcard.property.FormattedName;
import ezvcard.property.FreeBusyUrl;
import ezvcard.property.Gender;
import ezvcard.property.Geo;
import ezvcard.property.HasAltId;
import ezvcard.property.Hobby;
import ezvcard.property.Impp;
import ezvcard.property.Interest;
import ezvcard.property.Key;
import ezvcard.property.Kind;
import ezvcard.property.Label;
import ezvcard.property.Language;
import ezvcard.property.Logo;
import ezvcard.property.Mailer;
import ezvcard.property.Member;
import ezvcard.property.Nickname;
import ezvcard.property.Note;
import ezvcard.property.OrgDirectory;
import ezvcard.property.Organization;
import ezvcard.property.Photo;
import ezvcard.property.ProductId;
import ezvcard.property.Profile;
import ezvcard.property.RawProperty;
import ezvcard.property.Related;
import ezvcard.property.Revision;
import ezvcard.property.Role;
import ezvcard.property.SortString;
import ezvcard.property.Sound;
import ezvcard.property.Source;
import ezvcard.property.SourceDisplayText;
import ezvcard.property.StructuredName;
import ezvcard.property.Telephone;
import ezvcard.property.Timezone;
import ezvcard.property.Title;
import ezvcard.property.Uid;
import ezvcard.property.Url;
import ezvcard.property.VCardProperty;
import ezvcard.property.Xml;
import ezvcard.util.ListMultimap;
import ezvcard.util.StringUtils;
/*
Copyright (c) 2012-2021, Michael Angstadt
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
/**
* Represents a vCard.
* @author Michael Angstadt
*/
public class VCard implements Iterable<VCardProperty> {
private VCardVersion version;
private final ListMultimap<Class<? extends VCardProperty>, VCardProperty> properties = new ListMultimap<Class<? extends VCardProperty>, VCardProperty>();
/**
* Creates a new vCard set to version 3.0.
*/
public VCard() {
this(VCardVersion.V3_0);
}
/**
* Creates a new vCard.
* @param version the version to assign to the vCard
*/
public VCard(VCardVersion version) {
this.version = version;
}
/**
* Creates a deep copy of the given vCard.
* @param original the vCard to copy
*/
public VCard(VCard original) {
version = original.version;
for (VCardProperty property : original.getProperties()) {
addProperty(property.copy());
}
}
/**
* <p>
* Marshals this vCard to its text representation.
* </p>
* <p>
* The vCard will be marshalled to whatever vCard version is assigned to
* this object (see {@link #setVersion(VCardVersion)}). If no version is
* set, then it will be marshalled to 3.0.
* </p>
* <p>
* Use the {@link VCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @return the vCard string
* @see VCardWriter
* @see <a href="http://www.imc.org/pdi/vcard-21.rtf">vCard 2.1</a>
* @see <a href="http://tools.ietf.org/html/rfc2426">RFC 2426 (3.0)</a>
* @see <a href="http://tools.ietf.org/html/rfc6350">RFC 6350 (4.0)</a>
*/
public String write() {
return Ezvcard.write(this).go();
}
/**
* <p>
* Marshals this vCard to its text representation.
* </p>
* <p>
* The vCard will be marshalled to whatever vCard version is assigned to
* this object (see {@link #setVersion(VCardVersion)}). If no version is
* set, then it will be marshalled to 3.0.
* </p>
* <p>
* Use the {@link VCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param file the file to write the vCard to
* @throws IOException if there's a problem writing to the file
* @see VCardWriter
* @see <a href="http://www.imc.org/pdi/vcard-21.rtf">vCard 2.1</a>
* @see <a href="http://tools.ietf.org/html/rfc2426">RFC 2426 (3.0)</a>
* @see <a href="http://tools.ietf.org/html/rfc6350">RFC 6350 (4.0)</a>
*/
public void write(File file) throws IOException {
Ezvcard.write(this).go(file);
}
/**
* <p>
* Marshals this vCard to its text representation.
* </p>
* <p>
* The vCard will be marshalled to whatever vCard version is assigned to
* this object (see {@link #setVersion(VCardVersion)}). If no version is
* set, then it will be marshalled to 3.0.
* </p>
* <p>
* Use the {@link VCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param out the output stream to write the vCard to
* @see VCardWriter
* @throws IOException if there's a problem writing to the output stream
* @see <a href="http://www.imc.org/pdi/vcard-21.rtf">vCard 2.1</a>
* @see <a href="http://tools.ietf.org/html/rfc2426">RFC 2426 (3.0)</a>
* @see <a href="http://tools.ietf.org/html/rfc6350">RFC 6350 (4.0)</a>
*/
public void write(OutputStream out) throws IOException {
Ezvcard.write(this).go(out);
}
/**
* <p>
* Marshals this vCard to its text representation.
* </p>
* <p>
* The vCard will be marshalled to whatever vCard version is assigned to
* this object (see {@link #setVersion(VCardVersion)}). If no version is
* set, then it will be marshalled to 3.0.
* </p>
* <p>
* Use the {@link VCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param writer the writer to write the vCard to
* @throws IOException if there's a problem writing to the writer
* @see VCardWriter
* @see <a href="http://www.imc.org/pdi/vcard-21.rtf">vCard 2.1</a>
* @see <a href="http://tools.ietf.org/html/rfc2426">RFC 2426 (3.0)</a>
* @see <a href="http://tools.ietf.org/html/rfc6350">RFC 6350 (4.0)</a>
*/
public void write(Writer writer) throws IOException {
Ezvcard.write(this).go(writer);
}
/**
* <p>
* Marshals this vCard to its XML representation (xCard).
* </p>
* <p>
* Use the {@link XCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @return the vCard XML document
* @see XCardWriter
* @see <a href="http://tools.ietf.org/html/rfc6351">RFC 6351</a>
*/
public String writeXml() {
return Ezvcard.writeXml(this).indent(2).go();
}
/**
* <p>
* Marshals this vCard to its XML representation (xCard).
* </p>
* <p>
* Use the {@link XCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param file the file to write to
* @throws IOException if there's a problem writing to the file
* @throws TransformerException if there's a problem writing the vCard
* @see XCardWriter
* @see <a href="http://tools.ietf.org/html/rfc6351">RFC 6351</a>
*/
public void writeXml(File file) throws IOException, TransformerException {
Ezvcard.writeXml(this).indent(2).go(file);
}
/**
* <p>
* Marshals this vCard to its XML representation (xCard).
* </p>
* <p>
* Use the {@link XCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param out the output stream to write the vCard to
* @throws TransformerException if there's a problem writing to the output
* stream
* @see XCardWriter
* @see <a href="http://tools.ietf.org/html/rfc6351">RFC 6351</a>
*/
public void writeXml(OutputStream out) throws TransformerException {
Ezvcard.writeXml(this).indent(2).go(out);
}
/**
* <p>
* Marshals this vCard to its XML representation (xCard).
* </p>
* <p>
* Use the {@link XCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param writer the writer to write the vCard to
* @throws TransformerException if there's a problem writing to the writer
* @see XCardWriter
* @see <a href="http://tools.ietf.org/html/rfc6351">RFC 6351</a>
*/
public void writeXml(Writer writer) throws TransformerException {
Ezvcard.writeXml(this).indent(2).go(writer);
}
/**
* <p>
* Marshals this vCard to a basic HTML page (hCard).
* </p>
* <p>
* Use the {@link HCardPage} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @return the HTML page
* @see HCardPage
* @see <a href="http://microformats.org/wiki/hcard">hCard 1.0</a>
*/
public String writeHtml() {
return Ezvcard.writeHtml(this).go();
}
/**
* <p>
* Marshals this vCard to a basic HTML page (hCard).
* </p>
* <p>
* Use the {@link HCardPage} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param file the file to write to
* @throws IOException if there's a problem writing to the file
* @see HCardPage
* @see <a href="http://microformats.org/wiki/hcard">hCard 1.0</a>
*/
public void writeHtml(File file) throws IOException {
Ezvcard.writeHtml(this).go(file);
}
/**
* <p>
* Marshals this vCard to a basic HTML page (hCard).
* </p>
* <p>
* Use the {@link HCardPage} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param out the output stream to write to
* @throws IOException if there's a problem writing to the output stream
* @see HCardPage
* @see <a href="http://microformats.org/wiki/hcard">hCard 1.0</a>
*/
public void writeHtml(OutputStream out) throws IOException {
Ezvcard.writeHtml(this).go(out);
}
/**
* <p>
* Marshals this vCard to a basic HTML page (hCard).
* </p>
* <p>
* Use the {@link HCardPage} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param writer the writer to write to
* @throws IOException if there's a problem writing to the writer
* @see HCardPage
* @see <a href="http://microformats.org/wiki/hcard">hCard 1.0</a>
*/
public void writeHtml(Writer writer) throws IOException {
Ezvcard.writeHtml(this).go(writer);
}
/**
* <p>
* Marshals this vCard to its JSON representation (jCard).
* </p>
* <p>
* Use the {@link JCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @return the JSON string
* @see JCardWriter
* @see <a href="http://tools.ietf.org/html/rfc7095">RFC 7095</a>
*/
public String writeJson() {
return Ezvcard.writeJson(this).go();
}
/**
* <p>
* Marshals this vCard to its JSON representation (jCard).
* </p>
* <p>
* Use the {@link JCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param file the file to write the vCard to
* @throws IOException if there's a problem writing to the file
* @see JCardWriter
* @see <a href="http://tools.ietf.org/html/rfc7095">RFC 7095</a>
*/
public void writeJson(File file) throws IOException {
Ezvcard.writeJson(this).go(file);
}
/**
* <p>
* Marshals this vCard to its JSON representation (jCard).
* </p>
* <p>
* Use the {@link JCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param out the output stream to write the vCard to
* @see JCardWriter
* @throws IOException if there's a problem writing to the output stream
* @see <a href="http://tools.ietf.org/html/rfc7095">RFC 7095</a>
*/
public void writeJson(OutputStream out) throws IOException {
Ezvcard.writeJson(this).go(out);
}
/**
* <p>
* Marshals this vCard to its JSON representation (jCard).
* </p>
* <p>
* Use the {@link JCardWriter} class for more control over the marshalling
* process and to write multiple vCards to the same stream.
* </p>
* @param writer the writer to write the vCard to
* @throws IOException if there's a problem writing to the writer
* @see JCardWriter
* @see <a href="http://tools.ietf.org/html/rfc7095">RFC 7095</a>
*/
public void writeJson(Writer writer) throws IOException {
Ezvcard.writeJson(this).go(writer);
}
/**
* Gets the version attached to this vCard.
* @return the vCard version
*/
public VCardVersion getVersion() {
return version;
}
/**
* <p>
* Sets the version of this vCard.
* </p>
* <p>
* When marshalling a vCard with the {@link VCardWriter} class, use the
* {@link VCardWriter#setTargetVersion setTargetVersion} method to define
* what version the vCard should be marshalled as. {@link VCardWriter}
* <b>does not</b> look at the version that is set on the VCard object.
* </p>
* @param version the vCard version
*/
public void setVersion(VCardVersion version) {
this.version = version;
}
/**
* <p>
* Gets the type of entity this vCard represents.
* </p>
* <p>
* <b>Property name:</b> {@code KIND}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the kind property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-25">RFC 6350
* p.25</a>
*/
public Kind getKind() {
return getProperty(Kind.class);
}
/**
* <p>
* Sets the type of entity this vCard represents.
* </p>
* <p>
* <b>Property name:</b> {@code KIND}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param kind the kind property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-25">RFC 6350
* p.25</a>
*/
public void setKind(Kind kind) {
setProperty(Kind.class, kind);
}
/**
* <p>
* Gets the gender of the person.
* </p>
* <p>
* <b>Property name:</b> {@code GENDER}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the gender property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-32">RFC 6350
* p.32</a>
*/
public Gender getGender() {
return getProperty(Gender.class);
}
/**
* <p>
* Sets the gender of the person.
* </p>
* <p>
* <b>Property name:</b> {@code GENDER}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param gender the gender property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-32">RFC 6350
* p.32</a>
*/
public void setGender(Gender gender) {
setProperty(Gender.class, gender);
}
/**
* <p>
* Gets the members of the group that this vCard represents.
* </p>
* <p>
* Note: If a vCard has any {@link Member} properties, then it must also
* have a {@link Kind} property whose value is set to "group".
* </p>
* <p>
* <b>Property name:</b> {@code MEMBER}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the members properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-41">RFC 6350
* p.41</a>
*/
public List<Member> getMembers() {
return getProperties(Member.class);
}
/**
* <p>
* Adds a member to the group that this vCard represents.
* </p>
* <p>
* Note: If a vCard has any {@link Member} properties, then it must also
* have a {@link Kind} property whose value is set to "group".
* </p>
* <p>
* <b>Property name:</b> {@code MEMBER}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param member the member property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-41">RFC 6350
* p.41</a>
*/
public void addMember(Member member) {
addProperty(member);
}
/**
* <p>
* Adds a member to the group that this vCard represents.
* </p>
* <p>
* Note: If a vCard has any {@link Member} properties, then it must also
* have a {@link Kind} property whose value is set to "group".
* </p>
* <p>
* <b>Property name:</b> {@code MEMBER}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-41">RFC 6350
* p.41</a>
*/
public void addMemberAlt(Member... altRepresentations) {
addPropertyAlt(Member.class, altRepresentations);
}
/**
* <p>
* Gets the profile property. This property simply identifies the vCard as a
* vCard.
* </p>
* <p>
* <b>Property name:</b> {@code PROFILE}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @return the profile property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc2426#page-5">RFC 2426 p.5</a>
*/
public Profile getProfile() {
return getProperty(Profile.class);
}
/**
* <p>
* Sets the profile property. This property simply identifies the vCard as a
* vCard.
* </p>
* <p>
* <b>Property name:</b> {@code PROFILE}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-5">RFC 2426 p.5</a>
* @param profile the profile property or null to remove
*/
public void setProfile(Profile profile) {
setProperty(Profile.class, profile);
}
/**
* <p>
* Gets the classification of the vCard, which describes the sensitivity of
* the information in the vCard.
* </p>
* <p>
* <b>Property name:</b> {@code CLASS}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @return the classification property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc2426#page-26">RFC 2426
* p.26</a>
*/
public Classification getClassification() {
return getProperty(Classification.class);
}
/**
* <p>
* Sets the classification of the vCard, which describes the sensitivity of
* the information in the vCard.
* </p>
* <p>
* <b>Property name:</b> {@code CLASS}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @param classification the classification property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc2426#page-26">RFC 2426
* p.26</a>
*/
public void setClassification(Classification classification) {
setProperty(Classification.class, classification);
}
/**
* <p>
* Sets the classification of the vCard, which describes the sensitivity of
* the information in the vCard.
* </p>
* <p>
* <b>Supported versions:</b> {@code 3.0}<br>
* <b>Property name:</b> {@code CLASS}
* </p>
* @param classification the classification (e.g. "PUBLIC", "PRIVATE",
* "CONFIDENTIAL") or null to remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc2426#page-26">RFC 2426
* p.26</a>
*/
public Classification setClassification(String classification) {
Classification type = (classification == null) ? null : new Classification(classification);
setClassification(type);
return type;
}
/**
* <p>
* Gets the URIs that can be used to retrieve the most up-to-date version of
* the person's vCard.
* </p>
* <p>
* <b>Property name:</b> {@code SOURCE} <b>Supported versions:</b>
* {@code 3.0, 4.0}
* </p>
* @return the source properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-24">RFC 6350
* p.24</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-5">RFC 2426 p.5</a>
*/
public List<Source> getSources() {
return getProperties(Source.class);
}
/**
* <p>
* Adds a URI that can be used to retrieve the most up-to-date version of
* the person's vCard.
* </p>
* <p>
* <b>Property name:</b> {@code SOURCE} <b>Supported versions:</b>
* {@code 3.0, 4.0}
* </p>
* @param source the source property
* @see <a href="http://tools.ietf.org/html/rfc6350#page-24">RFC 6350
* p.24</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-5">RFC 2426 p.5</a>
*/
public void addSource(Source source) {
addProperty(source);
}
/**
* <p>
* Adds a URI that can be used to retrieve the most up-to-date version of
* the person's vCard.
* </p>
* <p>
* <b>Property name:</b> {@code SOURCE}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @param source the source URI (e.g. "http://example.com/vcard.vcf")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-24">RFC 6350
* p.24</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-5">RFC 2426 p.5</a>
*/
public Source addSource(String source) {
Source type = new Source(source);
addSource(type);
return type;
}
/**
* <p>
* Adds a URI that can be used to retrieve the most up-to-date version of
* the person's vCard.
* </p>
* <p>
* <b>Property name:</b> {@code SOURCE}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-24">RFC 6350
* p.24</a>
*/
public void addSourceAlt(Source... altRepresentations) {
addPropertyAlt(Source.class, altRepresentations);
}
/**
* <p>
* Gets a textual representation of the {@link Source} property.
* </p>
* <p>
* <b>Property name:</b> {@code NAME}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @return the property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc2426#page-5">RFC 2426 p.5</a>
*/
public SourceDisplayText getSourceDisplayText() {
return getProperty(SourceDisplayText.class);
}
/**
* <p>
* Sets a textual representation of the {@link Source} property.
* </p>
* <p>
* <b>Property name:</b> {@code NAME}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @param sourceDisplayText the property null to remove
* @see <a href="http://tools.ietf.org/html/rfc2426#page-5">RFC 2426 p.5</a>
*/
public void setSourceDisplayText(SourceDisplayText sourceDisplayText) {
setProperty(SourceDisplayText.class, sourceDisplayText);
}
/**
* <p>
* Sets a textual representation of the {@link Source} property.
* </p>
* <p>
* <b>Property name:</b> {@code NAME}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @param sourceDisplayText a textual representation of the vCard source or
* null to remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc2426#page-5">RFC 2426 p.5</a>
*/
public SourceDisplayText setSourceDisplayText(String sourceDisplayText) {
SourceDisplayText type = (sourceDisplayText == null) ? null : new SourceDisplayText(sourceDisplayText);
setSourceDisplayText(type);
return type;
}
/**
* <p>
* Gets all instances of the {@link FormattedName} property.
* </p>
* <p>
* Version 4.0 vCards may have multiple instances if alternative
* representations are defined (see
* {@link #addFormattedNameAlt(FormattedName...) addFormattedNameAlt}) or if
* properties with different TYPE parameters are defined.
* </p>
* <p>
* <b>Property name:</b> {@code FN}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @return the formatted name properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-28">RFC 6350
* p.28</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-8">RFC 2426 p.8</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public List<FormattedName> getFormattedNames() {
return getProperties(FormattedName.class);
}
/**
* <p>
* Gets the person's full name.
* </p>
* <p>
* <b>Property name:</b> {@code FN}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the first formatted name property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-28">RFC 6350
* p.28</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-8">RFC 2426 p.8</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public FormattedName getFormattedName() {
return getProperty(FormattedName.class);
}
/**
* <p>
* Sets the person's full name.
* </p>
* <p>
* <b>Property name:</b> {@code FN}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-28">RFC 6350
* p.28</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-8">RFC 2426 p.8</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public void setFormattedNameAlt(FormattedName... altRepresentations) {
setPropertyAlt(FormattedName.class, altRepresentations);
}
/**
* <p>
* Adds a version of the person's full name.
* </p>
* <p>
* <b>Property name:</b> {@code FN}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-28">RFC 6350
* p.28</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-8">RFC 2426 p.8</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public void addFormattedNameAlt(FormattedName... altRepresentations) {
addPropertyAlt(FormattedName.class, altRepresentations);
}
/**
* <p>
* Sets the person's full name.
* </p>
* <p>
* <b>Property name:</b> {@code FN}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param formattedName the formatted name property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-28">RFC 6350
* p.28</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-8">RFC 2426 p.8</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public void setFormattedName(FormattedName formattedName) {
setProperty(FormattedName.class, formattedName);
}
/**
* <p>
* Adds a version of the person's full name.
* </p>
* <p>
* <b>Property name:</b> {@code FN}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @param formattedName the formatted name property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-28">RFC 6350
* p.28</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-8">RFC 2426 p.8</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public void addFormattedName(FormattedName formattedName) {
addProperty(formattedName);
}
/**
* <p>
* Sets the person's full name.
* </p>
* <p>
* <b>Property name:</b> {@code FN}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param formattedName the formatted name (e.g. "John Doe") or null to
* remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-28">RFC 6350
* p.28</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-8">RFC 2426 p.8</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public FormattedName setFormattedName(String formattedName) {
FormattedName type = (formattedName == null) ? null : new FormattedName(formattedName);
setFormattedName(type);
return type;
}
/**
* <p>
* Gets all structured name properties.
* </p>
* <p>
* Version 4.0 vCards may have multiple instances if alternative
* representations are defined (see
* {@link #setStructuredNameAlt(StructuredName...) setStructuredNameAlt}) or
* if properties with different TYPE parameters are defined.
* </p>
* <p>
* <b>Property name:</b> {@code N}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @return the structured name properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public List<StructuredName> getStructuredNames() {
return getProperties(StructuredName.class);
}
/**
* <p>
* Gets the individual components of the person's name.
* </p>
* <p>
* <b>Property name:</b> {@code N}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the first structured name property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public StructuredName getStructuredName() {
return getProperty(StructuredName.class);
}
/**
* <p>
* Sets the individual components of the person's name.
* </p>
* <p>
* <b>Property name:</b> {@code N}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.9</a>
*/
public void setStructuredNameAlt(StructuredName... altRepresentations) {
setPropertyAlt(StructuredName.class, altRepresentations);
}
/**
* Sets the individual components of the person's name.
* <p>
* <b>Property name:</b> {@code N}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param structuredName the structured name property or null to remove
*/
public void setStructuredName(StructuredName structuredName) {
setProperty(StructuredName.class, structuredName);
}
/**
* <p>
* Gets all instances of the {@link Nickname} property.
* </p>
* <p>
* Version 4.0 vCards may have multiple instances if alternative
* representations are defined (see {@link #setNicknameAlt(Nickname...)
* setNicknameAlt}) or if properties with different TYPE parameters are
* defined.
* </p>
* <p>
* <b>Property name:</b> {@code NICKNAME}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @return the nickname properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
*/
public List<Nickname> getNicknames() {
return getProperties(Nickname.class);
}
/**
* <p>
* Gets the person's nicknames.
* </p>
* <p>
* <b>Property name:</b> {@code NICKNAME}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @return the nickname property (may contain multiple values) or null if
* not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
*/
public Nickname getNickname() {
return getProperty(Nickname.class);
}
/**
* <p>
* Sets the person's nicknames.
* </p>
* <p>
* <b>Property name:</b> {@code NICKNAME}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
*/
public void setNicknameAlt(Nickname... altRepresentations) {
setPropertyAlt(Nickname.class, altRepresentations);
}
/**
* <p>
* Adds a collection of nicknames for the person.
* </p>
* <p>
* <b>Property name:</b> {@code NICKNAME}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
*/
public void addNicknameAlt(Nickname... altRepresentations) {
addPropertyAlt(Nickname.class, altRepresentations);
}
/**
* <p>
* Sets the person's nicknames.
* </p>
* <p>
* <b>Property name:</b> {@code NICKNAME}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @param nickname the nickname property (may contain multiple values) or
* null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
*/
public void setNickname(Nickname nickname) {
setProperty(Nickname.class, nickname);
}
/**
* <p>
* Adds a set of nicknames for the person.
* </p>
* <p>
* Note that only version 4.0 vCards support multiple instances of this
* property.
* </p>
* <p>
* <b>Property name:</b> {@code NICKNAME}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @param nickname the nickname property (may contain multiple values)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
*/
public void addNickname(Nickname nickname) {
addProperty(nickname);
}
/**
* <p>
* Sets the person's nicknames.
* </p>
* <p>
* <b>Property name:</b> {@code NICKNAME}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @param nicknames the nicknames (e.g. "John", "Jon")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-29">RFC 6350
* p.29</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-9">RFC 2426 p.9</a>
*/
public Nickname setNickname(String... nicknames) {
Nickname property = null;
if (nicknames != null && nicknames.length > 0 && nicknames[0] != null) {
property = new Nickname();
property.getValues().addAll(Arrays.asList(nicknames));
}
setNickname(property);
return property;
}
/**
* <p>
* Gets the string that should be used to sort the vCard. This typically set
* to the person's family name (last name).
* </p>
* <p>
* For 4.0 vCards, this information is stored in the
* {@link StructuredName#getSortAs} and/or {@link Organization#getSortAs}
* methods.
* </p>
* <p>
* <b>Property name:</b> {@code SORT-STRING}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @return the sort string property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc2426#page-22">RFC 2426
* p.22</a>
*/
public SortString getSortString() {
return getProperty(SortString.class);
}
/**
* <p>
* Sets the string that should be used to sort the vCard. This typically set
* to the person's family name (last name).
* </p>
* <p>
* For 4.0 vCards, this information is stored in the
* {@link StructuredName#getSortAs} and/or {@link Organization#getSortAs}
* methods.
* </p>
* <p>
* <b>Property name:</b> {@code SORT-STRING}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @param sortString the sort string property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc2426#page-22">RFC 2426
* p.22</a>
*/
public void setSortString(SortString sortString) {
setProperty(SortString.class, sortString);
}
/**
* <p>
* Sets the string that should be used to sort the vCard. This typically set
* to the person's family name (last name).
* </p>
* <p>
* For 4.0 vCards, this information is stored in the
* {@link StructuredName#getSortAs} and/or {@link Organization#getSortAs}
* methods.
* </p>
* <p>
* <b>Property name:</b> {@code SORT-STRING}<br>
* <b>Supported versions:</b> {@code 3.0}
* </p>
* @param sortString the sort string (e.g. "Armour" if the person's last
* name is "d'Armour") or null to remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc2426#page-22">RFC 2426
* p.22</a>
*/
public SortString setSortString(String sortString) {
SortString type = (sortString == null) ? null : new SortString(sortString);
setSortString(type);
return type;
}
/**
* <p>
* Gets the titles associated with the person.
* </p>
* <p>
* <b>Property name:</b> {@code TITLE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the title properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-39">RFC 6350
* p.39</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-17">RFC 2426
* p.17</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public List<Title> getTitles() {
return getProperties(Title.class);
}
/**
* <p>
* Adds a title associated with the person.
* </p>
* <p>
* <b>Property name:</b> {@code TITLE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param title the title property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-39">RFC 6350
* p.39</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-17">RFC 2426
* p.17</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public void addTitle(Title title) {
addProperty(title);
}
/**
* <p>
* Adds a title associated with the person.
* </p>
* <p>
* <b>Property name:</b> {@code TITLE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param title the title to add (e.g. "V.P. Research and Development")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-39">RFC 6350
* p.39</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-17">RFC 2426
* p.17</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public Title addTitle(String title) {
Title type = new Title(title);
addTitle(type);
return type;
}
/**
* <p>
* Adds a title associated with the person.
* </p>
* <p>
* <b>Property name:</b> {@code TITLE}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-39">RFC 6350
* p.39</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-17">RFC 2426
* p.17</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public void addTitleAlt(Title... altRepresentations) {
addPropertyAlt(Title.class, altRepresentations);
}
/**
* <p>
* Gets the roles associated with the person.
* </p>
* <p>
* <b>Property name:</b> {@code ROLE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the role properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-39">RFC 6350
* p.39</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-18">RFC 2426
* p.18</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public List<Role> getRoles() {
return getProperties(Role.class);
}
/**
* <p>
* Adds a role associated with the person.
* </p>
* <p>
* <b>Property name:</b> {@code ROLE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param role the role property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-39">RFC 6350
* p.39</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-18">RFC 2426
* p.18</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public void addRole(Role role) {
addProperty(role);
}
/**
* <p>
* Adds a role associated with the person.
* </p>
* <p>
* <b>Property name:</b> {@code ROLE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param role the role to add (e.g. "Executive")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-39">RFC 6350
* p.39</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-18">RFC 2426
* p.18</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public Role addRole(String role) {
Role type = new Role(role);
addRole(type);
return type;
}
/**
* <p>
* Adds a role associated with the person.
* </p>
* <p>
* <b>Property name:</b> {@code ROLE}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-39">RFC 6350
* p.39</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-18">RFC 2426
* p.18</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public void addRoleAlt(Role... altRepresentations) {
addPropertyAlt(Role.class, altRepresentations);
}
/**
* <p>
* Gets the photos attached to the vCard, such as the person's portrait.
* </p>
* <p>
* <b>Property name:</b> {@code PHOTO}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the photo properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-30">RFC 6350
* p.30</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-10">RFC 2426
* p.10</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.10</a>
*/
public List<Photo> getPhotos() {
return getProperties(Photo.class);
}
/**
* <p>
* Adds a photo to the vCard, such as the person's portrait.
* </p>
* <p>
* <b>Property name:</b> {@code PHOTO}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param photo the photo property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-30">RFC 6350
* p.30</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-10">RFC 2426
* p.10</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.10</a>
*/
public void addPhoto(Photo photo) {
addProperty(photo);
}
/**
* <p>
* Adds a photo to the vCard, such as the person's portrait.
* </p>
* <p>
* <b>Property name:</b> {@code PHOTO}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-30">RFC 6350
* p.30</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-10">RFC 2426
* p.10</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.10</a>
*/
public void addPhotoAlt(Photo... altRepresentations) {
addPropertyAlt(Photo.class, altRepresentations);
}
/**
* <p>
* Gets the logos attached to the vCard, such a company logo.
* </p>
* <p>
* <b>Property name:</b> {@code LOGO}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the logo properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-18">RFC 2426
* p.18</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public List<Logo> getLogos() {
return getProperties(Logo.class);
}
/**
* <p>
* Adds a logo to the vCard, such as a company logo.
* </p>
* <p>
* <b>Property name:</b> {@code LOGO}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param logo the logo property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-18">RFC 2426
* p.18</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public void addLogo(Logo logo) {
addProperty(logo);
}
/**
* <p>
* Adds a logo to the vCard, such as a company logo.
* </p>
* <p>
* <b>Property name:</b> {@code LOGO}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-18">RFC 2426
* p.18</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
*/
public void addLogoAlt(Logo... altRepresentations) {
addPropertyAlt(Logo.class, altRepresentations);
}
/**
* <p>
* Gets the sounds attached to the vCard, such as a pronunciation of the
* person's name.
* </p>
* <p>
* <b>Property name:</b> {@code SOUND}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the sound properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-45">RFC 6350
* p.45</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-23">RFC 2426
* p.23</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.20</a>
*/
public List<Sound> getSounds() {
return getProperties(Sound.class);
}
/**
* <p>
* Adds a sound to the vCard, such as a pronunciation of the person's name.
* </p>
* <p>
* <b>Property name:</b> {@code SOUND}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param sound the sound property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-45">RFC 6350
* p.45</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-23">RFC 2426
* p.23</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.20</a>
*/
public void addSound(Sound sound) {
addProperty(sound);
}
/**
* <p>
* Adds a sound to the vCard, such as a pronunciation of the person's name.
* </p>
* <p>
* <b>Property name:</b> {@code SOUND}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-45">RFC 6350
* p.45</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-23">RFC 2426
* p.23</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.20</a>
*/
public void addSoundAlt(Sound... altRepresentations) {
addPropertyAlt(Sound.class, altRepresentations);
}
/**
* <p>
* Gets all {@link Birthplace} property instances.
* </p>
* <p>
* There may be multiple instances if alternative representations are
* defined (see {@link #setBirthplaceAlt(Birthplace...) setBirthplaceAlt}).
* </p>
* <p>
* <b>Property name:</b> {@code BIRTHPLACE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the birthplace properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6474#page-2">RFC 6474 p.2</a>
*/
public List<Birthplace> getBirthplaces() {
return getProperties(Birthplace.class);
}
/**
* <p>
* Gets the person's birthplace.
* </p>
* <p>
* <b>Property name:</b> {@code BIRTHPLACE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the first birthplace property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6474#page-2">RFC 6474 p.2</a>
*/
public Birthplace getBirthplace() {
return getProperty(Birthplace.class);
}
/**
* <p>
* Sets the person's birthplace.
* </p>
* <p>
* <b>Property name:</b> {@code BIRTHPLACE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6474#page-2">RFC 6474 p.2</a>
*/
public void setBirthplaceAlt(Birthplace... altRepresentations) {
setPropertyAlt(Birthplace.class, altRepresentations);
}
/**
* <p>
* Sets the person's birthplace.
* </p>
* <p>
* <b>Property name:</b> {@code BIRTHPLACE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param birthplace the birthplace property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6474#page-2">RFC 6474 p.2</a>
*/
public void setBirthplace(Birthplace birthplace) {
setProperty(Birthplace.class, birthplace);
}
/**
* <p>
* Gets all {@link Deathplace} property instances.
* </p>
* <p>
* There may be multiple instances if alternative representations are
* defined (see {@link #setDeathplaceAlt(Deathplace...) setDeathplaceAlt}).
* </p>
* <p>
* <b>Property name:</b> {@code DEATHPLACE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the deathplace properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6474#page-3">RFC 6474 p.3</a>
*/
public List<Deathplace> getDeathplaces() {
return getProperties(Deathplace.class);
}
/**
* <p>
* Gets the person's place of death.
* </p>
* <p>
* <b>Property name:</b> {@code DEATHPLACE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the first deathplace property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6474#page-3">RFC 6474 p.3</a>
*/
public Deathplace getDeathplace() {
return getProperty(Deathplace.class);
}
/**
* <p>
* Sets the person's place of death.
* </p>
* <p>
* <b>Property name:</b> {@code DEATHPLACE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6474#page-3">RFC 6474 p.3</a>
*/
public void setDeathplaceAlt(Deathplace... altRepresentations) {
setPropertyAlt(Deathplace.class, altRepresentations);
}
/**
* <p>
* Sets the person's place of death.
* </p>
* <p>
* <b>Property name:</b> {@code DEATHPLACE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param deathplace the deathplace property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6474#page-3">RFC 6474 p.3</a>
*/
public void setDeathplace(Deathplace deathplace) {
setProperty(Deathplace.class, deathplace);
}
/**
* <p>
* Gets all {@link Deathdate} property instances.
* </p>
* <p>
* There may be multiple instances if alternative representations are
* defined (see {@link #setDeathdateAlt(Deathdate...) setDeathdateAlt}).
* </p>
* <p>
* <b>Property name:</b> {@code DEATHDATE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the death date properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6474#page-4">RFC 6474 p.4</a>
*/
public List<Deathdate> getDeathdates() {
return getProperties(Deathdate.class);
}
/**
* <p>
* Gets the person's time of death.
* </p>
* <p>
* <b>Property name:</b> {@code DEATHDATE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the first death date property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6474">RFC 6474</a>
* @see <a href="http://tools.ietf.org/html/rfc6474#page-4">RFC 6474 p.4</a>
*/
public Deathdate getDeathdate() {
return getProperty(Deathdate.class);
}
/**
* <p>
* Sets the person's time of death.
* </p>
* <p>
* <b>Property name:</b> {@code DEATHDATE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6474#page-4">RFC 6474 p.4</a>
*/
public void setDeathdateAlt(Deathdate... altRepresentations) {
setPropertyAlt(Deathdate.class, altRepresentations);
}
/**
* <p>
* Sets the person's time of death.
* </p>
* <p>
* <b>Property name:</b> {@code DEATHDATE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param deathdate the death date property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6474">RFC 6474</a>
* @see <a href="http://tools.ietf.org/html/rfc6474#page-4">RFC 6474 p.4</a>
*/
public void setDeathdate(Deathdate deathdate) {
setProperty(Deathdate.class, deathdate);
}
/**
* <p>
* Gets all {@link Birthday} property instances.
* </p>
* <p>
* There may be multiple instances if alternative representations are
* defined (see {@link #setBirthdayAlt(Birthday...) setBirthdayAlt}).
* </p>
* <p>
* <b>Property name:</b> {@code BDAY}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @return the birthday properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-30">RFC 6350
* p.30</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-11">RFC 2426
* p.11</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.11</a>
*/
public List<Birthday> getBirthdays() {
return getProperties(Birthday.class);
}
/**
* <p>
* Gets the person's birthday.
* </p>
* <p>
* <b>Property name:</b> {@code BDAY}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the first birthday property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-30">RFC 6350
* p.30</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-11">RFC 2426
* p.11</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.11</a>
*/
public Birthday getBirthday() {
return getProperty(Birthday.class);
}
/**
* <p>
* Sets the person's birthday.
* </p>
* <p>
* <b>Property name:</b> {@code BDAY}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-30">RFC 6350
* p.30</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-11">RFC 2426
* p.11</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.11</a>
*/
public void setBirthdayAlt(Birthday... altRepresentations) {
setPropertyAlt(Birthday.class, altRepresentations);
}
/**
* <p>
* Sets the person's birthday.
* </p>
* <p>
* <b>Property name:</b> {@code BDAY}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param birthday the birthday or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-30">RFC 6350
* p.30</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-11">RFC 2426
* p.11</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.11</a>
*/
public void setBirthday(Birthday birthday) {
setProperty(Birthday.class, birthday);
}
/**
* <p>
* Gets all {@link Anniversary} property instances.
* </p>
* <p>
* There may be multiple instances if alternative representations are
* defined (see {@link #setAnniversaryAlt(Anniversary...) setAnniversaryAlt}
* ).
* </p>
* <p>
* <b>Property name:</b> {@code ANNIVERSARY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the anniversary properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-31">RFC 6350
* p.31</a>
*/
public List<Anniversary> getAnniversaries() {
return getProperties(Anniversary.class);
}
/**
* <p>
* Gets the person's anniversary.
* </p>
* <p>
* <b>Property name:</b> {@code ANNIVERSARY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the first anniversary property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-31">RFC 6350
* p.31</a>
*/
public Anniversary getAnniversary() {
return getProperty(Anniversary.class);
}
/**
* <p>
* Sets the person's anniversary.
* </p>
* <p>
* <b>Property name:</b> {@code ANNIVERSARY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-31">RFC 6350
* p.31</a>
*/
public void setAnniversaryAlt(Anniversary... altRepresentations) {
setPropertyAlt(Anniversary.class, altRepresentations);
}
/**
* <p>
* Sets the person's anniversary.
* </p>
* <p>
* <b>Property name:</b> {@code ANNIVERSARY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param anniversary the anniversary property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-31">RFC 6350
* p.31</a>
*/
public void setAnniversary(Anniversary anniversary) {
setProperty(Anniversary.class, anniversary);
}
/**
* Gets the time that the vCard was last modified.
* <p>
* <b>Property name:</b> {@code REV}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the revision property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-45">RFC 6350
* p.45</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-22">RFC 2426
* p.22</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public Revision getRevision() {
return getProperty(Revision.class);
}
/**
* <p>
* Sets the time that the vCard was last modified.
* </p>
* <p>
* <b>Property name:</b> {@code REV}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param revision the revision property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-45">RFC 6350
* p.45</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-22">RFC 2426
* p.22</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public void setRevision(Revision revision) {
setProperty(Revision.class, revision);
}
/**
* <p>
* Sets the time that the vCard was last modified.
* </p>
* <p>
* <b>Property name:</b> {@code REV}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param rev the last modified time or null to remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-45">RFC 6350
* p.45</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-22">RFC 2426
* p.22</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public Revision setRevision(Date rev) {
Revision type = (rev == null) ? null : new Revision(rev);
setRevision(type);
return type;
}
/**
* <p>
* Gets the product ID, which identifies the software that created the
* vCard.
* </p>
* <p>
* <b>Property name:</b> {@code PRODID}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @return the product ID property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-44">RFC 6350
* p.44</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-21">RFC 2426
* p.21</a>
*/
public ProductId getProductId() {
return getProperty(ProductId.class);
}
/**
* <p>
* Sets the product ID, which identifies the software that created the
* vCard.
* </p>
* <p>
* <b>Property name:</b> {@code PRODID}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @param productId the product ID property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-44">RFC 6350
* p.44</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-21">RFC 2426
* p.21</a>
*/
public void setProductId(ProductId productId) {
setProperty(ProductId.class, productId);
}
/**
* <p>
* Sets the product ID, which identifies the software that created the
* vCard.
* </p>
* <p>
* <b>Property name:</b> {@code PRODID}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @param productId the product ID (e.g. "ez-vcard 1.0") or null to remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-44">RFC 6350
* p.44</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-21">RFC 2426
* p.21</a>
*/
public ProductId setProductId(String productId) {
ProductId type = (productId == null) ? null : new ProductId(productId);
setProductId(type);
return type;
}
/**
* <p>
* Gets the mailing addresses.
* </p>
* <p>
* <b>Property name:</b> {@code ADR}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the mailing address properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-32">RFC 6350
* p.32</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-11">RFC 2426
* p.11</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.11</a>
*/
public List<Address> getAddresses() {
return getProperties(Address.class);
}
/**
* <p>
* Adds a mailing address.
* </p>
* <p>
* <b>Property name:</b> {@code ADR}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param address the mailing address property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-32">RFC 6350
* p.32</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-11">RFC 2426
* p.11</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.11</a>
*/
public void addAddress(Address address) {
addProperty(address);
}
/**
* <p>
* Adds a mailing address.
* </p>
* <p>
* <b>Property name:</b> {@code ADR}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-32">RFC 6350
* p.32</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-11">RFC 2426
* p.11</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.11</a>
*/
public void addAddressAlt(Address... altRepresentations) {
addPropertyAlt(Address.class, altRepresentations);
}
/**
* <p>
* Gets all mailing labels that could not be assigned to an {@link Address}
* property. Use {@link Address#getLabel} to get a label that has been
* assigned to an address.
* </p>
* <p>
* <b>Property name:</b> {@code LABEL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0}
* </p>
* @return the orphaned label properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc2426#page-13">RFC 2426
* p.13</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.12</a>
*/
public List<Label> getOrphanedLabels() {
return getProperties(Label.class);
}
/**
* <p>
* Adds a mailing label which is not associated with an {@link Address}
* property.
* </p>
* <p>
* Use of this method is strongly discouraged. To add a mailing label to an
* address, use the {@link Address#setLabel} method.
* </p>
* <p>
* <b>Property name:</b> {@code LABEL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0}
* </p>
* @param label the orphaned label property to add
* @see <a href="http://tools.ietf.org/html/rfc2426#page-13">RFC 2426
* p.13</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.12</a>
*/
public void addOrphanedLabel(Label label) {
addProperty(label);
}
/**
* <p>
* Gets the email addresses.
* </p>
* <p>
* <b>Property name:</b> {@code EMAIL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the email address properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-36">RFC 6350
* p.36</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-15">RFC 2426
* p.15</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.15</a>
*/
public List<Email> getEmails() {
return getProperties(Email.class);
}
/**
* <p>
* Adds an email address.
* </p>
* <p>
* <b>Property name:</b> {@code EMAIL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param email the email address property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-36">RFC 6350
* p.36</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-15">RFC 2426
* p.15</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.15</a>
*/
public void addEmail(Email email) {
addProperty(email);
}
/**
* <p>
* Adds an email address.
* </p>
* <p>
* <b>Property name:</b> {@code EMAIL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param email the email address to add (e.g. "hzdkv@example.com")
* @param types the type(s) to assign to the email
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-36">RFC 6350
* p.36</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-15">RFC 2426
* p.15</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.15</a>
*/
public Email addEmail(String email, EmailType... types) {
Email property = new Email(email);
property.getTypes().addAll(Arrays.asList(types));
addEmail(property);
return property;
}
/**
* <p>
* Adds an email address.
* </p>
* <p>
* <b>Property name:</b> {@code EMAIL}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-36">RFC 6350
* p.36</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-15">RFC 2426
* p.15</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.15</a>
*/
public void addEmailAlt(Email... altRepresentations) {
addPropertyAlt(Email.class, altRepresentations);
}
/**
* <p>
* Gets the telephone numbers.
* </p>
* <p>
* <b>Property name:</b> {@code TEL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the telephone number properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-34">RFC 6350
* p.34</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-14">RFC 2426
* p.14</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.13</a>
*/
public List<Telephone> getTelephoneNumbers() {
return getProperties(Telephone.class);
}
/**
* <p>
* Adds a telephone number.
* </p>
* <p>
* <b>Property name:</b> {@code TEL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param telephoneNumber the telephone number property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-34">RFC 6350
* p.34</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-14">RFC 2426
* p.14</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.13</a>
*/
public void addTelephoneNumber(Telephone telephoneNumber) {
addProperty(telephoneNumber);
}
/**
* <p>
* Adds a telephone number.
* </p>
* <p>
* <b>Property name:</b> {@code TEL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param telephoneNumber the telephone number to add (e.g.
* "+1 555-555-5555")
* @param types the type(s) to assign to the telephone number (e.g. "cell",
* "work", etc)
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-34">RFC 6350
* p.34</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-14">RFC 2426
* p.14</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.13</a>
*/
public Telephone addTelephoneNumber(String telephoneNumber, TelephoneType... types) {
Telephone property = new Telephone(telephoneNumber);
property.getTypes().addAll(Arrays.asList(types));
addTelephoneNumber(property);
return property;
}
/**
* <p>
* Adds a telephone number.
* </p>
* <p>
* <b>Property name:</b> {@code TEL}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-34">RFC 6350
* p.34</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-14">RFC 2426
* p.14</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.13</a>
*/
public void addTelephoneNumberAlt(Telephone... altRepresentations) {
addPropertyAlt(Telephone.class, altRepresentations);
}
/**
* <p>
* Gets the email client that the person uses.
* </p>
* <p>
* <b>Property name:</b> {@code MAILER}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0}
* </p>
* @return the mailer property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc2426#page-15">RFC 2426
* p.15</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.15</a>
*/
public Mailer getMailer() {
return getProperty(Mailer.class);
}
/**
* <p>
* Sets the email client that the person uses.
* </p>
* <p>
* <b>Property name:</b> {@code MAILER}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0}
* </p>
* @param mailer the mailer property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc2426#page-15">RFC 2426
* p.15</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.15</a>
*/
public void setMailer(Mailer mailer) {
setProperty(Mailer.class, mailer);
}
/**
* <p>
* Sets the email client that the person uses.
* </p>
* <p>
* <b>Property name:</b> {@code MAILER}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0}
* </p>
* @param mailer the email client (e.g. "Thunderbird") or null to remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc2426#page-15">RFC 2426
* p.15</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.15</a>
*/
public Mailer setMailer(String mailer) {
Mailer type = (mailer == null) ? null : new Mailer(mailer);
setMailer(type);
return type;
}
/**
* <p>
* Gets the URLs. URLs can point to websites such as a personal homepage or
* business website.
* </p>
* <p>
* <b>Property name:</b> {@code URL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the URL properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-47">RFC 6350
* p.47</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-25">RFC 2426
* p.25</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.21</a>
*/
public List<Url> getUrls() {
return getProperties(Url.class);
}
/**
* <p>
* Adds a URL. URLs can point to websites such as a personal homepage or
* business website.
* </p>
* <p>
* <b>Property name:</b> {@code URL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param url the URL property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-47">RFC 6350
* p.47</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-25">RFC 2426
* p.25</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.21</a>
*/
public void addUrl(Url url) {
addProperty(url);
}
/**
* <p>
* Adds a URL. URLs can point to websites such as a personal homepage or
* business website.
* </p>
* <p>
* <b>Property name:</b> {@code URL}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param url the URL to add (e.g. "http://example.com")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-47">RFC 6350
* p.47</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-25">RFC 2426
* p.25</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.21</a>
*/
public Url addUrl(String url) {
Url type = new Url(url);
addUrl(type);
return type;
}
/**
* <p>
* Adds a URL. URLs can point to websites such as a personal homepage or
* business website.
* </p>
* <p>
* <b>Property name:</b> {@code URL}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-47">RFC 6350
* p.47</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-25">RFC 2426
* p.25</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.21</a>
*/
public void addUrlAlt(Url... altRepresentations) {
addPropertyAlt(Url.class, altRepresentations);
}
/**
* <p>
* Gets all instances of the {@link Timezone} property.
* </p>
* <p>
* Version 4.0 vCards may have multiple instances if alternative
* representations are defined (see {@link #setTimezoneAlt(Timezone...)
* setTimezoneAlt}) or if properties with different TYPE parameters are
* defined.
* </p>
* <p>
* <b>Property name:</b> {@code TZ}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @return the timezone properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-22">RFC 6350
* p.22</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public List<Timezone> getTimezones() {
return getProperties(Timezone.class);
}
/**
* <p>
* Gets the timezone the person lives/works in.
* </p>
* <p>
* <b>Property name:</b> {@code TZ}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the first timezone property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-22">RFC 6350
* p.22</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public Timezone getTimezone() {
return getProperty(Timezone.class);
}
/**
* <p>
* Sets the timezone the person lives/works in.
* </p>
* <p>
* <b>Property name:</b> {@code TZ}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-22">RFC 6350
* p.22</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public void setTimezoneAlt(Timezone... altRepresentations) {
setPropertyAlt(Timezone.class, altRepresentations);
}
/**
* <p>
* Adds a timezone the person lives/works in.
* </p>
* <p>
* <b>Property name:</b> {@code TZ}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-22">RFC 6350
* p.22</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public void addTimezoneAlt(Timezone... altRepresentations) {
addPropertyAlt(Timezone.class, altRepresentations);
}
/**
* <p>
* Sets the timezone the person lives/works in.
* </p>
* <p>
* <b>Property name:</b> {@code TZ}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param timezone the timezone property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-22">RFC 6350
* p.22</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public void setTimezone(Timezone timezone) {
setProperty(Timezone.class, timezone);
}
/**
* <p>
* Adds a timezone the person lives/works in.
* </p>
* <p>
* <b>Property name:</b> {@code TZ}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @param timezone the timezone property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-22">RFC 6350
* p.22</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public void addTimezone(Timezone timezone) {
addProperty(timezone);
}
/**
* <p>
* Gets all instances of the {@link Geo} property.
* </p>
* <p>
* Version 4.0 vCards may have multiple instances if alternative
* representations are defined (see {@link #setGeoAlt(Geo...) setGeoAlt}) or
* if properties with different TYPE parameters are defined.
* </p>
* <p>
* <b>Property name:</b> {@code GEO}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @return the geo properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-38">RFC 6350
* p.38</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public List<Geo> getGeos() {
return getProperties(Geo.class);
}
/**
* <p>
* Gets the geographical position of where the person lives/works.
* </p>
* <p>
* <b>Property name:</b> {@code GEO}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the first geo property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-38">RFC 6350
* p.38</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public Geo getGeo() {
return getProperty(Geo.class);
}
/**
* <p>
* Sets the geographical position of where the person lives/works.
* </p>
* <p>
* <b>Property name:</b> {@code GEO}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-38">RFC 6350
* p.38</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public void setGeoAlt(Geo... altRepresentations) {
setPropertyAlt(Geo.class, altRepresentations);
}
/**
* <p>
* Adds a geographical position of where the person lives/works.
* </p>
* <p>
* <b>Property name:</b> {@code GEO}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-38">RFC 6350
* p.38</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public void addGeoAlt(Geo... altRepresentations) {
addPropertyAlt(Geo.class, altRepresentations);
}
/**
* <p>
* Sets the geographical position of where the person lives/works.
* </p>
* <p>
* <b>Property name:</b> {@code GEO}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param geo the geo property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-38">RFC 6350
* p.38</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public void setGeo(Geo geo) {
setProperty(Geo.class, geo);
}
/**
* <p>
* Adds a geographical position of where the person lives/works. Note that
* only version 4.0 vCards support multiple instances of this property.
* </p>
* <p>
* <b>Property name:</b> {@code GEO}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @param geo the geo property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-38">RFC 6350
* p.38</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public void addGeo(Geo geo) {
addProperty(geo);
}
/**
* <p>
* Sets the geographical position of where the person lives/works.
* </p>
* <p>
* <b>Property name:</b> {@code GEO}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param latitude the latitude
* @param longitude the longitude
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-38">RFC 6350
* p.38</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
* p.16</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
*/
public Geo setGeo(double latitude, double longitude) {
Geo type = new Geo(latitude, longitude);
setGeo(type);
return type;
}
/**
* <p>
* Gets all instances of the {@link Organization} property.
* </p>
* <p>
* Version 4.0 vCards may have multiple instances if alternative
* representations are defined (see
* {@link #setOrganizationAlt(Organization...) setOrganizationAlt}) or if
* properties with different TYPE parameters are defined.
* </p>
* <p>
* <b>Property name:</b> {@code ORG}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @return the organization properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public List<Organization> getOrganizations() {
return getProperties(Organization.class);
}
/**
* <p>
* Gets the hierarchy of department(s) to which the person belongs.
* </p>
* <p>
* <b>Property name:</b> {@code ORG}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the first organization property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public Organization getOrganization() {
return getProperty(Organization.class);
}
/**
* <p>
* Sets the hierarchy of department(s) to which the person belongs.
* </p>
* <p>
* <b>Property name:</b> {@code ORG}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public void setOrganizationAlt(Organization... altRepresentations) {
setPropertyAlt(Organization.class, altRepresentations);
}
/**
* <p>
* Adds a hierarchy of department(s) to which the person belongs.
* </p>
* <p>
* <b>Property name:</b> {@code ORG}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public void addOrganizationAlt(Organization... altRepresentations) {
addPropertyAlt(Organization.class, altRepresentations);
}
/**
* <p>
* Sets the hierarchy of departments to which the person belongs.
* </p>
* <p>
* <b>Property name:</b> {@code ORG}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param organization the organization property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public void setOrganization(Organization organization) {
setProperty(Organization.class, organization);
}
/**
* <p>
* Adds a hierarchy of departments to which the person belongs. Note that
* only version 4.0 vCards support multiple instances of this property.
* </p>
* <p>
* <b>Property name:</b> {@code ORG}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @param organization the organization property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public void addOrganization(Organization organization) {
addProperty(organization);
}
/**
* <p>
* Sets the hierarchy of departments to which the person belongs.
* </p>
* <p>
* <b>Property name:</b> {@code ORG}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param departments the ordered list of department(s), starting with the
* broadest and ending with the most specific (e.g. "Google", "Gmail Team",
* "Spam Detection Squad") or an empty arguments list to remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
* p.40</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public Organization setOrganization(String... departments) {
Organization type = null;
if (departments.length > 0) {
type = new Organization();
type.getValues().addAll(Arrays.asList(departments));
}
setOrganization(type);
return type;
}
/**
* <p>
* Gets all instances of the {@link Categories} property.
* </p>
* <p>
* Version 4.0 vCards may have multiple instances if alternative
* representations are defined (see {@link #setCategoriesAlt(Categories...)
* setCategoriesAlt}) or if properties with different TYPE parameters are
* defined.
* </p>
* <p>
* <b>Property name:</b> {@code CATEGORIES}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @return the categories properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-43">RFC 6350
* p.43</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
*/
public List<Categories> getCategoriesList() {
return getProperties(Categories.class);
}
/**
* <p>
* Gets the list of "keywords" or "tags" that can be used to describe the
* person.
* </p>
* <p>
* <b>Property name:</b> {@code CATEGORIES}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @return the first categories property (can contain multiple values) or
* null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-43">RFC 6350
* p.43</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
*/
public Categories getCategories() {
return getProperty(Categories.class);
}
/**
* <p>
* Sets the list of "keywords" or "tags" that can be used to describe the
* person.
* </p>
* <p>
* <b>Property name:</b> {@code CATEGORIES}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-43">RFC 6350
* p.43</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
*/
public void setCategoriesAlt(Categories... altRepresentations) {
setPropertyAlt(Categories.class, altRepresentations);
}
/**
* <p>
* Adds a list of "keywords" or "tags" that can be used to describe the
* person.
* </p>
* <p>
* <b>Property name:</b> {@code CATEGORIES}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-43">RFC 6350
* p.43</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
*/
public void addCategoriesAlt(Categories... altRepresentations) {
addPropertyAlt(Categories.class, altRepresentations);
}
/**
* <p>
* Sets the list of "keywords" or "tags" that can be used to describe the
* person.
* </p>
* <p>
* <b>Property name:</b> {@code CATEGORIES}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @param categories the categories property (can contain multiple values)
* or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-43">RFC 6350
* p.43</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
*/
public void setCategories(Categories categories) {
setProperty(Categories.class, categories);
}
/**
* <p>
* Adds a list of "keywords" or "tags" that can be used to describe the
* person. Note that only version 4.0 vCards support multiple instances of
* this property.
* </p>
* <p>
* <b>Property name:</b> {@code CATEGORIES}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports multiple instances</i>
* </p>
* @param categories the categories property to add (can contain multiple
* values)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-43">RFC 6350
* p.43</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
*/
public void addCategories(Categories categories) {
addProperty(categories);
}
/**
* <p>
* Sets the list of "keywords" or "tags" that can be used to describe the
* person.
* </p>
* <p>
* <b>Property name:</b> {@code CATEGORIES}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @param categories the categories (e.g. "swimmer", "biker", "knitter") or
* an empty arguments list to remove
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-43">RFC 6350
* p.43</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
* p.20</a>
*/
public Categories setCategories(String... categories) {
Categories type = null;
if (categories.length > 0) {
type = new Categories();
type.getValues().addAll(Arrays.asList(categories));
}
setCategories(type);
return type;
}
/**
* <p>
* Gets information about the person's agent.
* </p>
* <p>
* <b>Property name:</b> {@code AGENT}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0}
* </p>
* @return the agent property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc2426#page-19">RFC 2426
* p.19</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.18</a>
*/
public Agent getAgent() {
return getProperty(Agent.class);
}
/**
* <p>
* Sets information about the person's agent.
* </p>
* <p>
* <b>Property name:</b> {@code AGENT}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0}
* </p>
* @param agent the agent property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc2426#page-19">RFC 2426
* p.19</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.18</a>
*/
public void setAgent(Agent agent) {
setProperty(Agent.class, agent);
}
/**
* <p>
* Gets the notes. Notes contain free-form, miscellaneous text.
* </p>
* <p>
* <b>Property name:</b> {@code NOTE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the note properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-44">RFC 6350
* p.44</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-21">RFC 2426
* p.21</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public List<Note> getNotes() {
return getProperties(Note.class);
}
/**
* <p>
* Adds a note. Notes contain free-form, miscellaneous text.
* </p>
* <p>
* <b>Property name:</b> {@code NOTE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param note the note property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-44">RFC 6350
* p.44</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-21">RFC 2426
* p.21</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public void addNote(Note note) {
addProperty(note);
}
/**
* <p>
* Adds a note. Notes contain free-form, miscellaneous text.
* </p>
* <p>
* <b>Property name:</b> {@code NOTE}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param note the note to add
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-44">RFC 6350
* p.44</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-21">RFC 2426
* p.21</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public Note addNote(String note) {
Note type = new Note(note);
addNote(type);
return type;
}
/**
* <p>
* Adds a note. Notes contain free-form, miscellaneous text.
* </p>
* <p>
* <b>Property name:</b> {@code NOTE}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-44">RFC 6350
* p.44</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-21">RFC 2426
* p.21</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
*/
public void addNoteAlt(Note... altRepresentations) {
addPropertyAlt(Note.class, altRepresentations);
}
/**
* <p>
* Gets the unique identifier of the vCard.
* </p>
* <p>
* <b>Property name:</b> {@code UID}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the unique identifier property or null if not set
* @see <a href="http://tools.ietf.org/html/rfc6350#page-46">RFC 6350
* p.46</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-24">RFC 2426
* p.24</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.21</a>
*/
public Uid getUid() {
return getProperty(Uid.class);
}
/**
* <p>
* Sets the unique identifier of the vCard.
* </p>
* <p>
* <b>Property name:</b> {@code UID}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param uid the unique identifier property or null to remove
* @see <a href="http://tools.ietf.org/html/rfc6350#page-46">RFC 6350
* p.46</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-24">RFC 2426
* p.24</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.21</a>
*/
public void setUid(Uid uid) {
setProperty(Uid.class, uid);
}
/**
* <p>
* Gets the public encryption keys.
* </p>
* <p>
* <b>Property name:</b> {@code KEY}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @return the key properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-48">RFC 6350
* p.48</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-26">RFC 2426
* p.26</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.22</a>
*/
public List<Key> getKeys() {
return getProperties(Key.class);
}
/**
* <p>
* Adds a public encryption key.
* </p>
* <p>
* <b>Property name:</b> {@code KEY}<br>
* <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
* </p>
* @param key the key property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-48">RFC 6350
* p.48</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-26">RFC 2426
* p.26</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.22</a>
*/
public void addKey(Key key) {
addProperty(key);
}
/**
* <p>
* Adds a public encryption key.
* </p>
* <p>
* <b>Property name:</b> {@code KEY}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-48">RFC 6350
* p.48</a>
* @see <a href="http://tools.ietf.org/html/rfc2426#page-26">RFC 2426
* p.26</a>
* @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.22</a>
*/
public void addKeyAlt(Key... altRepresentations) {
addPropertyAlt(Key.class, altRepresentations);
}
/**
* <p>
* Gets the instant messaging handles.
* </p>
* <p>
* <b>Property name:</b> {@code IMPP}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @return the IMPP properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-36">RFC 6350
* p.36</a>
* @see <a href="http://tools.ietf.org/html/rfc4770">RFC 4770</a>
*/
public List<Impp> getImpps() {
return getProperties(Impp.class);
}
/**
* <p>
* Adds an instant messaging handle.
* </p>
* <p>
* <b>Property name:</b> {@code IMPP}<br>
* <b>Supported versions:</b> {@code 3.0, 4.0}
* </p>
* @param impp the IMPP property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-36">RFC 6350
* p.36</a>
* @see <a href="http://tools.ietf.org/html/rfc4770">RFC 4770</a>
*/
public void addImpp(Impp impp) {
addProperty(impp);
}
/**
* <p>
* Adds an instant messaging handle.
* </p>
* <p>
* <b>Property name:</b> {@code IMPP}<br>
* <b>Supported versions:</b> {@code 4.0*}<br>
* <i>* Only 4.0 supports alternative representations</i>
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-36">RFC 6350
* p.36</a>
* @see <a href="http://tools.ietf.org/html/rfc4770">RFC 4770</a>
*/
public void addImppAlt(Impp... altRepresentations) {
addPropertyAlt(Impp.class, altRepresentations);
}
/**
* <p>
* Gets a list of people that the person is related to.
* </p>
* <p>
* <b>Property name:</b> {@code RELATED}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the relation properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-42">RFC 6350
* p.42</a>
*/
public List<Related> getRelations() {
return getProperties(Related.class);
}
/**
* <p>
* Adds someone that the person is related to.
* </p>
* <p>
* <b>Property name:</b> {@code RELATED}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param related the relation property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-42">RFC 6350
* p.42</a>
*/
public void addRelated(Related related) {
addProperty(related);
}
/**
* <p>
* Adds someone that the person is related to.
* </p>
* <p>
* <b>Property name:</b> {@code RELATED}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-42">RFC 6350
* p.42</a>
*/
public void addRelatedAlt(Related... altRepresentations) {
addPropertyAlt(Related.class, altRepresentations);
}
/**
* <p>
* Gets the languages that the person speaks.
* </p>
* <p>
* <b>Property name:</b> {@code LANG}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the language properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-37">RFC 6350
* p.37</a>
*/
public List<Language> getLanguages() {
return getProperties(Language.class);
}
/**
* <p>
* Adds a language that the person speaks.
* </p>
* <p>
* <b>Property name:</b> {@code LANG}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param language the language property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-37">RFC 6350
* p.37</a>
*/
public void addLanguage(Language language) {
addProperty(language);
}
/**
* <p>
* Adds a language that the person speaks.
* </p>
* <p>
* <b>Property name:</b> {@code LANG}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param language the language to add (e.g. "en-us")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6350#page-37">RFC 6350
* p.37</a>
*/
public Language addLanguage(String language) {
Language type = new Language(language);
addLanguage(type);
return type;
}
/**
* <p>
* Adds a language that the person speaks.
* </p>
* <p>
* <b>Property name:</b> {@code LANG}<br>
* <b>Supported versions:</b> {@code 4.0}
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-37">RFC 6350
* p.37</a>
*/
public void addLanguageAlt(Language... altRepresentations) {
addPropertyAlt(Language.class, altRepresentations);
}
/**
* <p>
* Gets the URIs that can be used to schedule a meeting with the person on
* his or her calendar.
* </p>
* <p>
* <b>Property name:</b> {@code CALADRURI}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the calendar request URI properties (any changes made this list
* will affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-50">RFC 6350
* p.50</a>
*/
public List<CalendarRequestUri> getCalendarRequestUris() {
return getProperties(CalendarRequestUri.class);
}
/**
* <p>
* Adds a URI that can be used to schedule a meeting with the person on his
* or her calendar.
* </p>
* <p>
* <b>Property name:</b> {@code CALADRURI}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param calendarRequestUri the calendar request URI property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-50">RFC 6350
* p.50</a>
*/
public void addCalendarRequestUri(CalendarRequestUri calendarRequestUri) {
addProperty(calendarRequestUri);
}
/**
* <p>
* Adds a URI that can be used to schedule a meeting with the person on his
* or her calendar.
* </p>
* <p>
* <b>Property name:</b> {@code CALADRURI}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-50">RFC 6350
* p.50</a>
*/
public void addCalendarRequestUriAlt(CalendarRequestUri... altRepresentations) {
addPropertyAlt(CalendarRequestUri.class, altRepresentations);
}
/**
* <p>
* Gets the URIs that point to the person's calendar.
* </p>
* <p>
* <b>Property name:</b> {@code CALURI}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the calendar URI properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-50">RFC 6350
* p.50</a>
*/
public List<CalendarUri> getCalendarUris() {
return getProperties(CalendarUri.class);
}
/**
* <p>
* Adds a URI that points to the person's calendar.
* </p>
* <p>
* <b>Property name:</b> {@code CALURI}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param calendarUri the calendar URI property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-50">RFC 6350
* p.50</a>
*/
public void addCalendarUri(CalendarUri calendarUri) {
addProperty(calendarUri);
}
/**
* <p>
* Adds a URI that points to the person's calendar.
* </p>
* <p>
* <b>Property name:</b> {@code CALURI}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-50">RFC 6350
* p.50</a>
*/
public void addCalendarUriAlt(CalendarUri... altRepresentations) {
addPropertyAlt(CalendarUri.class, altRepresentations);
}
/**
* <p>
* Gets the URLs that can be used to determine when the person is free or
* busy.
* </p>
* <p>
* <b>Property name:</b> {@code FBURL}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the free-busy URL properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-49">RFC 6350
* p.49</a>
*/
public List<FreeBusyUrl> getFbUrls() {
return getProperties(FreeBusyUrl.class);
}
/**
* <p>
* Adds a URL that can be used to determine when the person is free or busy.
* </p>
* <p>
* <b>Property name:</b> {@code FBURL}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param fbUrl the free-busy URL property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-49">RFC 6350
* p.49</a>
*/
public void addFbUrl(FreeBusyUrl fbUrl) {
addProperty(fbUrl);
}
/**
* <p>
* Adds a URL that can be used to determine when the person is free or busy.
* </p>
* <p>
* <b>Property name:</b> {@code FBURL}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-49">RFC 6350
* p.49</a>
*/
public void addFbUrlAlt(FreeBusyUrl... altRepresentations) {
addPropertyAlt(FreeBusyUrl.class, altRepresentations);
}
/**
* <p>
* Gets the properties that are used to assign globally-unique identifiers
* to individual property instances. They are used for merging together
* different versions of the same vCard.
* </p>
* <p>
* <b>Property name:</b> {@code CLIENTPIDMAP}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the client PID map properties (any changes made this list will
* affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-47">RFC 6350
* p.47</a>
*/
public List<ClientPidMap> getClientPidMaps() {
return getProperties(ClientPidMap.class);
}
/**
* <p>
* Adds a property that is used to assign a globally-unique identifier to an
* individual property instance. They are used for merging together
* different versions of the same vCard.
* </p>
* <p>
* <b>Property name:</b> {@code CLIENTPIDMAP}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param clientPidMap the client PID map property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-47">RFC 6350
* p.47</a>
*/
public void addClientPidMap(ClientPidMap clientPidMap) {
addProperty(clientPidMap);
}
/**
* <p>
* Gets any XML data that is attached to the vCard.
* </p>
* <p>
* These properties may be present if the vCard was encoded in XML ("xCard"
* format) and the XML document contained non-standard elements. In this
* case, the properties would contain all of the non-standard XML elements.
* </p>
* <p>
* <b>Property name:</b> {@code XML}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the XML properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6350#page-27">RFC 6350
* p.27</a>
*/
public List<Xml> getXmls() {
return getProperties(Xml.class);
}
/**
* <p>
* Adds XML data to the vCard.
* </p>
* <p>
* These properties may be present if the vCard was encoded in XML ("xCard"
* format) and the XML document contained non-standard elements. In this
* case, the properties would contain all of the non-standard XML elements.
* </p>
* <p>
* <b>Property name:</b> {@code XML}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param xml the XML property to add
* @see <a href="http://tools.ietf.org/html/rfc6350#page-27">RFC 6350
* p.27</a>
*/
public void addXml(Xml xml) {
addProperty(xml);
}
/**
* <p>
* Adds XML data to the vCard.
* </p>
* <p>
* These properties may be present if the vCard was encoded in XML ("xCard"
* format) and the XML document contained non-standard elements. In this
* case, the properties would contain all of the non-standard XML elements.
* </p>
* <p>
* <b>Property name:</b> {@code XML}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6350#page-27">RFC 6350
* p.27</a>
*/
public void addXmlAlt(Xml... altRepresentations) {
addPropertyAlt(Xml.class, altRepresentations);
}
/**
* <p>
* Gets the professional subject areas that the person is knowledgeable in.
* </p>
* <p>
* <b>Property name:</b> {@code EXPERTISE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the expertise properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6715#page-3">RFC 6715 p.3</a>
*/
public List<Expertise> getExpertise() {
return getProperties(Expertise.class);
}
/**
* <p>
* Adds a professional subject area that the person is knowledgeable in.
* </p>
* <p>
* <b>Property name:</b> {@code EXPERTISE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param expertise the expertise property to add
* @see <a href="http://tools.ietf.org/html/rfc6715#page-3">RFC 6715 p.3</a>
*/
public void addExpertise(Expertise expertise) {
addProperty(expertise);
}
/**
* <p>
* Adds a professional subject area that the person is knowledgeable in.
* </p>
* <p>
* <b>Property name:</b> {@code EXPERTISE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param expertise the professional subject area to add (e.g.
* "programming")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6715#page-3">RFC 6715 p.3</a>
*/
public Expertise addExpertise(String expertise) {
Expertise type = new Expertise(expertise);
addExpertise(type);
return type;
}
/**
* <p>
* Adds a professional subject area that the person is knowledgeable in.
* </p>
* <p>
* <b>Property name:</b> {@code EXPERTISE}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6715#page-3">RFC 6715 p.3</a>
*/
public void addExpertiseAlt(Expertise... altRepresentations) {
addPropertyAlt(Expertise.class, altRepresentations);
}
/**
* <p>
* Gets the hobbies that the person actively engages in.
* </p>
* <p>
* <b>Property name:</b> {@code HOBBY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the hobby properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6715#page-4">RFC 6715 p.4</a>
*/
public List<Hobby> getHobbies() {
return getProperties(Hobby.class);
}
/**
* <p>
* Adds a hobby that the person actively engages in.
* </p>
* <p>
* <b>Property name:</b> {@code HOBBY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param hobby the hobby property to add
* @see <a href="http://tools.ietf.org/html/rfc6715#page-4">RFC 6715 p.4</a>
*/
public void addHobby(Hobby hobby) {
addProperty(hobby);
}
/**
* <p>
* Adds a hobby that the person actively engages in.
* </p>
* <p>
* <b>Property name:</b> {@code HOBBY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param hobby the hobby to add (e.g. "photography")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6715#page-4">RFC 6715 p.4</a>
*/
public Hobby addHobby(String hobby) {
Hobby type = new Hobby(hobby);
addHobby(type);
return type;
}
/**
* <p>
* Adds a hobby that the person actively engages in.
* </p>
* <p>
* <b>Property name:</b> {@code HOBBY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6715#page-4">RFC 6715 p.4</a>
*/
public void addHobbyAlt(Hobby... altRepresentations) {
addPropertyAlt(Hobby.class, altRepresentations);
}
/**
* <p>
* Gets the person's interests.
* </p>
* <p>
* <b>Property name:</b> {@code INTEREST}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the interest properties (any changes made this list will affect
* the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6715#page-5">RFC 6715 p.5</a>
*/
public List<Interest> getInterests() {
return getProperties(Interest.class);
}
/**
* <p>
* Adds an interest.
* </p>
* <p>
* <b>Property name:</b> {@code INTEREST}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param interest the interest property to add
* @see <a href="http://tools.ietf.org/html/rfc6715#page-5">RFC 6715 p.5</a>
*/
public void addInterest(Interest interest) {
addProperty(interest);
}
/**
* <p>
* Adds an interest.
* </p>
* <p>
* <b>Property name:</b> {@code INTEREST}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param interest the interest to add (e.g. "football")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6715#page-5">RFC 6715 p.5</a>
*/
public Interest addInterest(String interest) {
Interest type = new Interest(interest);
addInterest(type);
return type;
}
/**
* <p>
* Adds an interest.
* </p>
* <p>
* <b>Property name:</b> {@code INTEREST}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6715#page-5">RFC 6715 p.5</a>
*/
public void addInterestAlt(Interest... altRepresentations) {
addPropertyAlt(Interest.class, altRepresentations);
}
/**
* <p>
* Gets the organization directories.
* </p>
* <p>
* <b>Property name:</b> {@code ORG-DIRECTORY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @return the organization directory properties (any changes made this list
* will affect the {@link VCard} object and vice versa)
* @see <a href="http://tools.ietf.org/html/rfc6715#page-6">RFC 6715 p.6</a>
*/
public List<OrgDirectory> getOrgDirectories() {
return getProperties(OrgDirectory.class);
}
/**
* <p>
* Adds an organization directory.
* </p>
* <p>
* <b>Property name:</b> {@code ORG-DIRECTORY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param orgDirectory the organization directory property to add
* @see <a href="http://tools.ietf.org/html/rfc6715#page-6">RFC 6715 p.6</a>
*/
public void addOrgDirectory(OrgDirectory orgDirectory) {
addProperty(orgDirectory);
}
/**
* <p>
* Adds an organization directory.
* </p>
* <p>
* <b>Property name:</b> {@code ORG-DIRECTORY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param orgDirectory the organization directory to add (e.g.
* "http://company.com/staff")
* @return the property object that was created
* @see <a href="http://tools.ietf.org/html/rfc6715#page-6">RFC 6715 p.6</a>
*/
public OrgDirectory addOrgDirectory(String orgDirectory) {
OrgDirectory type = new OrgDirectory(orgDirectory);
addOrgDirectory(type);
return type;
}
/**
* <p>
* Adds an organization directory.
* </p>
* <p>
* <b>Property name:</b> {@code ORG-DIRECTORY}<br>
* <b>Supported versions:</b> {@code 4.0}
* </p>
* @param altRepresentations the alternative representations of the same
* value. These properties contain the same information, but in different
* forms (such as different languages). See {@link VCardParameters#getAltId
* this description of the ALTID parameter} for more information. Note that
* this method automatically assigns an appropriate ALTID parameter to each
* property.
* @see <a href="http://tools.ietf.org/html/rfc6715#page-6">RFC 6715 p.6</a>
*/
public void addOrgDirectoryAlt(OrgDirectory... altRepresentations) {
addPropertyAlt(OrgDirectory.class, altRepresentations);
}
/**
* Iterates through each of the vCard's properties in no particular order.
* Does not include the "BEGIN", "END", or "VERSION" properties.
* @return the iterator
*/
public Iterator<VCardProperty> iterator() {
return properties.values().iterator();
}
/**
* Gets the first property of a given class.
* @param clazz the property class
* @param <T> the property class
* @return the property or null if not found
*/
public <T extends VCardProperty> T getProperty(Class<T> clazz) {
return clazz.cast(properties.first(clazz));
}
/**
* Gets all properties of a given class.
* @param clazz the property class
* @param <T> the property class
* @return the properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
*/
public <T extends VCardProperty> List<T> getProperties(Class<T> clazz) {
return new VCardPropertyList<T>(clazz);
}
/**
* Gets all properties of a given class, grouping the alternative
* representations of each property together (see:
* {@link VCardParameters#getAltId description of ALTID})
* @param clazz the property class
* @param <T> the property class
* @return the properties (this list is immutable)
*/
public <T extends VCardProperty & HasAltId> List<List<T>> getPropertiesAlt(Class<T> clazz) {
List<T> propertiesWithoutAltIds = new ArrayList<T>();
ListMultimap<String, T> propertiesWithAltIds = new ListMultimap<String, T>();
for (T property : getProperties(clazz)) {
String altId = property.getAltId();
if (altId == null) {
propertiesWithoutAltIds.add(property);
} else {
propertiesWithAltIds.put(altId, property);
}
}
int size = propertiesWithoutAltIds.size() + propertiesWithAltIds.size();
List<List<T>> listToReturn = new ArrayList<List<T>>(size);
for (Map.Entry<String, List<T>> entry : propertiesWithAltIds) {
listToReturn.add(Collections.unmodifiableList(entry.getValue()));
}
//put properties without ALTIDs at the end
for (T property : propertiesWithoutAltIds) {
List<T> list = new ArrayList<T>(1);
list.add(property);
listToReturn.add(Collections.unmodifiableList(list));
}
return Collections.unmodifiableList(listToReturn);
}
/**
* Gets all the properties in this vCard.
* @return the properties (this list is immutable)
*/
public Collection<VCardProperty> getProperties() {
return properties.values();
}
/**
* Adds a property.
* @param property the property to add
*/
public void addProperty(VCardProperty property) {
properties.put(property.getClass(), property);
}
/**
* Replaces all existing properties of the given property instance's class
* with the given property instance.
* @param property the property
* @return the properties that were replaced (this list is immutable)
*/
public List<VCardProperty> setProperty(VCardProperty property) {
return properties.replace(property.getClass(), property);
}
/**
* Replaces all existing properties of the given class with a single
* property instance. If the property instance is null, then all instances
* of that property will be removed.
* @param clazz the property class (e.g. "Note.class")
* @param property the property or null to remove
* @param <T> the property class
* @return the properties that were replaced (this list is immutable)
*/
public <T extends VCardProperty> List<T> setProperty(Class<T> clazz, T property) {
List<VCardProperty> replaced = properties.replace(clazz, property);
return castList(replaced, clazz);
}
/**
* Removes a property instance from the vCard.
* @param property the property to remove
* @return true if it was removed, false if it wasn't found
*/
public boolean removeProperty(VCardProperty property) {
return properties.remove(property.getClass(), property);
}
/**
* Removes all properties of a given class.
* @param clazz the class of the properties to remove (e.g. "Note.class")
* @param <T> the property class
* @return the properties that were removed (this list is immutable)
*/
public <T extends VCardProperty> List<T> removeProperties(Class<T> clazz) {
List<VCardProperty> removed = properties.removeAll(clazz);
return castList(removed, clazz);
}
/**
* Gets the first extended property with a given name.
* @param name the property name (e.g. "X-ALT-DESC")
* @return the property or null if none were found
*/
public RawProperty getExtendedProperty(String name) {
for (RawProperty raw : getExtendedProperties()) {
if (raw.getPropertyName().equalsIgnoreCase(name)) {
return raw;
}
}
return null;
}
/**
* Gets all extended properties with a given name.
* @param name the property name (e.g. "X-ALT-DESC")
* @return the properties (this list is immutable)
*/
public List<RawProperty> getExtendedProperties(String name) {
List<RawProperty> properties = new ArrayList<RawProperty>();
for (RawProperty raw : getExtendedProperties()) {
if (raw.getPropertyName().equalsIgnoreCase(name)) {
properties.add(raw);
}
}
return Collections.unmodifiableList(properties);
}
/**
* Gets all extended properties.
* @return the properties (any changes made this list will affect the
* {@link VCard} object and vice versa)
*/
public List<RawProperty> getExtendedProperties() {
return getProperties(RawProperty.class);
}
/**
* Adds an extended property.
* @param name the property name (e.g. "X-ALT-DESC")
* @param value the property value
* @return the property object that was created
*/
public RawProperty addExtendedProperty(String name, String value) {
RawProperty raw = new RawProperty(name, value);
addProperty(raw);
return raw;
}
/**
* Adds an extended property.
* @param name the property name (e.g. "X-ALT-DESC")
* @param value the property value
* @param dataType the property value's data type
* @return the property object that was created
*/
public RawProperty addExtendedProperty(String name, String value, VCardDataType dataType) {
RawProperty raw = new RawProperty(name, value, dataType);
addProperty(raw);
return raw;
}
/**
* Replaces all existing extended properties with the given name with a
* single property instance.
* @param name the property name (e.g. "X-ALT-DESC")
* @param value the property value
* @return the property object that was created
*/
public RawProperty setExtendedProperty(String name, String value) {
removeExtendedProperty(name);
return addExtendedProperty(name, value);
}
/**
* Replaces all existing extended properties with the given name with a
* single property instance.
* @param name the property name (e.g. "X-ALT-DESC")
* @param value the property value
* @param dataType the property value's data type
* @return the property object that was created
*/
public RawProperty setExtendedProperty(String name, String value, VCardDataType dataType) {
removeExtendedProperty(name);
return addExtendedProperty(name, value, dataType);
}
/**
* Removes all extended properties that have the given name.
* @param name the component name (e.g. "X-ALT-DESC")
* @return the properties that were removed (this list is immutable)
*/
public List<RawProperty> removeExtendedProperty(String name) {
List<RawProperty> all = getExtendedProperties();
List<RawProperty> toRemove = new ArrayList<RawProperty>();
for (RawProperty property : all) {
if (property.getPropertyName().equalsIgnoreCase(name)) {
toRemove.add(property);
}
}
all.removeAll(toRemove);
return Collections.unmodifiableList(toRemove);
}
/**
* Adds a property in the form of a collection of alternative
* representations. This method will generate a unique ALTID parameter value
* and assign it to each of the property instances (see:
* {@link VCardParameters#getAltId description of ALTID}).
* @param propertyClass the property class
* @param altRepresentations the alternative representations of the property
* to add
* @param <T> the property class
*/
public <T extends VCardProperty & HasAltId> void addPropertyAlt(Class<T> propertyClass, T... altRepresentations) {
addPropertyAlt(propertyClass, Arrays.asList(altRepresentations));
}
/**
* Adds a property in the form of a collection of alternative
* representations. This method will generate a unique ALTID parameter value
* and assign it to each of the property instances (see:
* {@link VCardParameters#getAltId description of ALTID}).
* @param propertyClass the property class
* @param altRepresentations the alternative representations of the property
* to add
* @param <T> the property class
*/
public <T extends VCardProperty & HasAltId> void addPropertyAlt(Class<T> propertyClass, Collection<T> altRepresentations) {
String altId = generateAltId(getProperties(propertyClass));
for (T property : altRepresentations) {
property.setAltId(altId);
addProperty(property);
}
}
/**
* Sets a property in the form of a collection of alternative
* representations. This method will generate a unique ALTID parameter value
* and assign it to each of the property instances (see:
* {@link VCardParameters#getAltId description of ALTID}).
* @param propertyClass the property class
* @param altRepresentations the alternative representations of the property
* to add
* @param <T> the property class
* @return the properties that were replaced (this list is immutable)
*/
public <T extends VCardProperty & HasAltId> List<T> setPropertyAlt(Class<T> propertyClass, T... altRepresentations) {
return setPropertyAlt(propertyClass, Arrays.asList(altRepresentations));
}
/**
* Sets a property in the form of a collection of alternative
* representations. This method will generate a unique ALTID parameter value
* and assign it to each of the property instances (see:
* {@link VCardParameters#getAltId description of ALTID}).
* @param propertyClass the property class
* @param altRepresentations the alternative representations of the property
* to add
* @param <T> the property class
* @return the properties that were replaced (this list is immutable)
*/
public <T extends VCardProperty & HasAltId> List<T> setPropertyAlt(Class<T> propertyClass, Collection<T> altRepresentations) {
List<T> removed = removeProperties(propertyClass);
addPropertyAlt(propertyClass, altRepresentations);
return removed;
}
/**
* Casts all objects in the given list to the given class, adding the casted
* objects to a new list.
* @param list the list to cast
* @param castTo the class to cast to
* @param <T> the class to cast to
* @return the new list (this list is immutable)
*/
private static <T> List<T> castList(List<?> list, Class<T> castTo) {
List<T> casted = new ArrayList<T>(list.size());
for (Object object : list) {
casted.add(castTo.cast(object));
}
return Collections.unmodifiableList(casted);
}
/**
* Checks this vCard for data consistency problems or deviations from the
* spec. These problems will not prevent the vCard from being written to a
* data stream, but may prevent it from being parsed correctly by the
* consuming application. These problems can largely be avoided by reading
* the Javadocs of the property classes, or by being familiar with the vCard
* standard.
* @param version the version to check the vCard against (use
* {@link VCardVersion#V4_0} for xCard and jCard)
* @return the validation warnings
*/
public ValidationWarnings validate(VCardVersion version) {
ValidationWarnings warnings = new ValidationWarnings();
//validate overall vCard object
if (getStructuredName() == null && (version == VCardVersion.V2_1 || version == VCardVersion.V3_0)) {
warnings.add(null, new ValidationWarning(0));
}
if (getFormattedName() == null && (version == VCardVersion.V3_0 || version == VCardVersion.V4_0)) {
warnings.add(null, new ValidationWarning(1));
}
//validate properties
for (VCardProperty property : this) {
List<ValidationWarning> propWarnings = property.validate(version, this);
if (!propWarnings.isEmpty()) {
warnings.add(property, propWarnings);
}
}
return warnings;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("version=").append(version);
for (VCardProperty property : properties.values()) {
sb.append(StringUtils.NEWLINE).append(property);
}
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((version == null) ? 0 : version.hashCode());
int propertiesHash = 1;
for (VCardProperty property : properties.values()) {
propertiesHash += property.hashCode();
}
result = prime * result + propertiesHash;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
VCard other = (VCard) obj;
if (version != other.version) return false;
if (properties.size() != other.properties.size()) return false;
for (Map.Entry<Class<? extends VCardProperty>, List<VCardProperty>> entry : properties) {
Class<? extends VCardProperty> key = entry.getKey();
List<VCardProperty> value = entry.getValue();
List<VCardProperty> otherValue = other.properties.get(key);
if (value.size() != otherValue.size()) {
return false;
}
List<VCardProperty> otherValueCopy = new ArrayList<VCardProperty>(otherValue);
for (VCardProperty property : value) {
if (!otherValueCopy.remove(property)) {
return false;
}
}
}
return true;
}
/**
* Generates a unique ALTID parameter value.
* @param properties the collection of properties under which the ALTID must
* be unique
* @param <T> the property class
* @return a unique ALTID
*/
static <T extends HasAltId> String generateAltId(Collection<T> properties) {
Set<String> altIds = new HashSet<String>();
for (T property : properties) {
String altId = property.getAltId();
if (altId != null) {
altIds.add(altId);
}
}
int altId = 1;
while (altIds.contains(Integer.toString(altId))) {
altId++;
}
return Integer.toString(altId);
}
/**
* <p>
* A list that automatically casts {@link VCardProperty} instances stored in
* this {@link VCard} to a given property class.
* </p>
* <p>
* This list is backed by the {@link VCard} object. Any changes made to the
* list will affect the {@link VCard} object and vice versa.
* </p>
* @param <T> the property class
*/
private class VCardPropertyList<T extends VCardProperty> extends AbstractList<T> {
protected final Class<T> propertyClass;
protected final List<VCardProperty> properties;
/**
* @param propertyClass the property class
*/
public VCardPropertyList(Class<T> propertyClass) {
this.propertyClass = propertyClass;
properties = VCard.this.properties.get(propertyClass);
}
@Override
public void add(int index, T value) {
properties.add(index, value);
}
@Override
public T remove(int index) {
VCardProperty removed = properties.remove(index);
return cast(removed);
}
@Override
public T get(int index) {
VCardProperty property = properties.get(index);
return cast(property);
}
@Override
public T set(int index, T value) {
VCardProperty replaced = properties.set(index, value);
return cast(replaced);
}
@Override
public int size() {
return properties.size();
}
private T cast(VCardProperty value) {
return propertyClass.cast(value);
}
}
}
|
3e07f5fc153cf578d0c2313de8353efa6c4bf73a | 895 | java | Java | src/main/java/cn/haohaoli/book/headfirst/factory/version6/NYPizzaIngredientFactory.java | 27392/java-notes | 3edb89d2c868ffd4b5d1a63f8a5517c1850752d0 | [
"Apache-2.0"
] | 11 | 2019-01-05T06:54:00.000Z | 2020-05-26T09:59:17.000Z | src/main/java/cn/haohaoli/book/headfirst/factory/version6/NYPizzaIngredientFactory.java | 27392/java-notes | 3edb89d2c868ffd4b5d1a63f8a5517c1850752d0 | [
"Apache-2.0"
] | null | null | null | src/main/java/cn/haohaoli/book/headfirst/factory/version6/NYPizzaIngredientFactory.java | 27392/java-notes | 3edb89d2c868ffd4b5d1a63f8a5517c1850752d0 | [
"Apache-2.0"
] | 1 | 2019-11-07T13:40:00.000Z | 2019-11-07T13:40:00.000Z | 20.813953 | 73 | 0.659218 | 3,372 | package cn.haohaoli.book.headfirst.factory.version6;
import cn.haohaoli.book.headfirst.factory.version6.ingredent.*;
import cn.haohaoli.book.headfirst.factory.version6.ingredent.impl.*;
/**
* 纽约披萨原料工厂
* @author LiWenHao
* @date 2019-04-28 21:08
*/
public class NYPizzaIngredientFactory implements PizzaIngredientFactory {
@Override
public Dough createDough() {
return new ThinCrustDough();
}
@Override
public Sauce createSauce() {
return new MarinaraSauce();
}
@Override
public Cheese createCheese() {
return new ReggianoCheese();
}
@Override
public Veggies[] createVeggies() {
return new Veggies[]{new Garlic()};
}
@Override
public Pepperoni createPepperoni() {
return new SlicedPepperoni();
}
@Override
public Clams createClams() {
return new FreshClams();
}
}
|
3e07f90f205ebe34c11171b4f38c77b172d8807b | 754 | java | Java | FormExpressionParser/src/de/xima/fc/form/expression/exception/parse/IncompatibleConditionTypeException.java | blutorange/FormExpressionParser | 0e6c352ed42bd7efc96019bc326588bee533ecad | [
"WTFPL"
] | null | null | null | FormExpressionParser/src/de/xima/fc/form/expression/exception/parse/IncompatibleConditionTypeException.java | blutorange/FormExpressionParser | 0e6c352ed42bd7efc96019bc326588bee533ecad | [
"WTFPL"
] | 1 | 2017-06-08T08:12:47.000Z | 2017-06-10T17:31:33.000Z | FormExpressionParser/src/de/xima/fc/form/expression/exception/parse/IncompatibleConditionTypeException.java | blutorange/FormExpressionParser | 0e6c352ed42bd7efc96019bc326588bee533ecad | [
"WTFPL"
] | null | null | null | 39.684211 | 91 | 0.830239 | 3,373 | package de.xima.fc.form.expression.exception.parse;
import javax.annotation.Nonnull;
import de.xima.fc.form.expression.grammar.Node;
import de.xima.fc.form.expression.iface.parse.IVariableType;
import de.xima.fc.form.expression.impl.variable.SimpleVariableType;
import de.xima.fc.form.expression.util.CmnCnst;
import de.xima.fc.form.expression.util.NullUtil;
public class IncompatibleConditionTypeException extends IncompatibleVariableTypeException {
private static final long serialVersionUID = 1L;
public IncompatibleConditionTypeException(@Nonnull final IVariableType typeCondition,
@Nonnull final Node node) {
super(NullUtil.messageFormat(CmnCnst.Error.CONDITION_MUST_BE_BOOLEAN),
SimpleVariableType.BOOLEAN, typeCondition, node);
}
} |
3e07f9121b67d55c4cf6b192940a0d364f12a2c9 | 4,835 | java | Java | app/src/main/java/jp/plen/plenconnect2/views/JoystickView.java | plenprojectcompany/plen-Scenography_Android | 1c5c33fa86a985684c7de29a6e36282803fd406c | [
"Apache-2.0"
] | 7 | 2016-06-28T03:22:58.000Z | 2018-01-29T09:06:58.000Z | app/src/main/java/jp/plen/plenconnect2/views/JoystickView.java | plenprojectcompany/plen-PLENConnect_Android | 1c5c33fa86a985684c7de29a6e36282803fd406c | [
"Apache-2.0"
] | 10 | 2017-03-01T07:31:56.000Z | 2017-03-28T07:54:11.000Z | app/src/main/java/jp/plen/plenconnect2/views/JoystickView.java | plenprojectcompany/plen-Scenography_Android | 1c5c33fa86a985684c7de29a6e36282803fd406c | [
"Apache-2.0"
] | 4 | 2017-02-13T08:38:56.000Z | 2017-06-22T10:26:36.000Z | 34.535714 | 107 | 0.628749 | 3,374 | package jp.plen.plenconnect2.views;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;
import com.eccyan.optional.Optional;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
import jp.plen.rx.binding.Property;
import jp.plen.rx.binding.ReadOnlyProperty;
import jp.plen.plenconnect2.R;
@EViewGroup(R.layout.view_joystick)
public class JoystickView extends RelativeLayout {
private static final String TAG = JoystickView.class.getSimpleName();
private final ObjectAnimator mAnimatorX = new ObjectAnimator();
private final ObjectAnimator mAnimatorY = new ObjectAnimator();
private final Property<StickPosition> mStickPosition = Property.create();
@ViewById(R.id.joystickBackground) View mBackground;
@ViewById(R.id.joystickStick) View mStick;
private boolean mInitialized = false;
private int mCenterX;
private int mCenterY;
private int mStickR;
private int mBackgroundR;
public JoystickView(Context context) {
this(context, null);
}
public JoystickView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public JoystickView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public Optional<StickPosition> getStickPosition() {
return mStickPosition.get();
}
public ReadOnlyProperty<StickPosition> stickPosition() {
return mStickPosition;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
double x = event.getX() - mCenterX;
double y = event.getY() - mCenterY;
double t = Math.atan2(y, x);
double r = Math.hypot(x, y);
double rMax = mBackgroundR - mStickR;
r = Math.min(r, rMax);
x = mCenterX - mStickR + r * Math.cos(t);
y = mCenterY - mStickR + r * Math.sin(t);
if (mStick.getX() != (int) x || mStick.getY() != (int) y) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
animateStick(x, y);
} else {
mStick.setX((int) x);
mStick.setY((int) y);
}
mStickPosition.set(new StickPosition(r / rMax, t));
}
} else {
animateStick(mCenterX - mStickR, mCenterY - mStickR);
mStickPosition.set(new StickPosition(0, 0));
}
return true;
}
@Override
protected void dispatchDraw(@NonNull Canvas canvas) {
if (!mInitialized) {
mInitialized = true;
mCenterX = canvas.getWidth() / 2;
mCenterY = canvas.getHeight() / 2;
mBackgroundR = (int) Math.min(
Math.min(mCenterX, mCenterY) * 0.8,
getResources().getDimension(R.dimen.joystick_background_size) / 2);
mBackground.setLayoutParams(new LayoutParams(2 * mBackgroundR, 2 * mBackgroundR));
mBackground.setX(mCenterX - mBackgroundR);
mBackground.setY(mCenterY - mBackgroundR);
mStickR = (int) (mBackgroundR * 0.6);
mStick.setLayoutParams(new LayoutParams(2 * mStickR, 2 * mStickR));
mStick.setX(mCenterX - mStickR);
mStick.setY(mCenterY - mStickR);
}
super.dispatchDraw(canvas);
}
@AfterViews
void afterViews() {
mBackground.setLayoutParams(new LayoutParams(0, 0));
mStick.setLayoutParams(new LayoutParams(0, 0));
mBackground.getBackground().setLevel(1);
mAnimatorX.setPropertyName("x");
mAnimatorY.setPropertyName("y");
mAnimatorX.setTarget(mStick);
mAnimatorY.setTarget(mStick);
}
private void animateStick(double x, double y) {
double r = Math.hypot(
mStick.getX() - x,
mStick.getY() - y);
int duration = (int) r / 2;
mAnimatorX.setDuration(duration);
mAnimatorX.setFloatValues((float) x);
mAnimatorY.setDuration(duration);
mAnimatorY.setFloatValues((float) y);
mAnimatorX.start();
mAnimatorY.start();
}
public static class StickPosition {
public final double gain;
public final double direction;
public StickPosition(double gain, double direction) {
this.gain = gain;
this.direction = direction;
}
}
}
|
3e07f9215ad744306a3a77af26b54d5b5bde3e57 | 1,146 | java | Java | Netty-Base/src/main/java/cn/xiuminglee/netty/sa_DoubleEndedCommunication/FirstServerHandler.java | XiumingLee/NettyLearn | 26216b37e253c4c8fe4d0be91e6a12da54d9f708 | [
"Apache-2.0"
] | null | null | null | Netty-Base/src/main/java/cn/xiuminglee/netty/sa_DoubleEndedCommunication/FirstServerHandler.java | XiumingLee/NettyLearn | 26216b37e253c4c8fe4d0be91e6a12da54d9f708 | [
"Apache-2.0"
] | null | null | null | Netty-Base/src/main/java/cn/xiuminglee/netty/sa_DoubleEndedCommunication/FirstServerHandler.java | XiumingLee/NettyLearn | 26216b37e253c4c8fe4d0be91e6a12da54d9f708 | [
"Apache-2.0"
] | null | null | null | 29.384615 | 115 | 0.688482 | 3,375 | package cn.xiuminglee.netty.sa_DoubleEndedCommunication;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import java.nio.charset.Charset;
import java.time.LocalDateTime;
/**
* @Author: Xiuming Lee
* @Date: 2019/8/8 16:33
* @Version 1.0
* @Describe: 服务端逻辑处理器
*/
public class FirstServerHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
// 收数据的逻辑
ByteBuf byteBuf = (ByteBuf) msg;
System.out.println(LocalDateTime.now() + ": 服务端读到客户端的数据 -> " + byteBuf.toString(Charset.forName("utf-8")));
// 回复数据到客户端
System.out.println(LocalDateTime.now() + ": 服务端写出数据");
ByteBuf out = getByteBuf(ctx);
ctx.channel().writeAndFlush(out);
}
private ByteBuf getByteBuf(ChannelHandlerContext ctx) {
byte[] bytes = "你好,欢迎访问我的个人博客网站->https://mrain22.cn/!".getBytes(Charset.forName("utf-8"));
ByteBuf buffer = ctx.alloc().buffer();
buffer.writeBytes(bytes);
return buffer;
}
}
|
3e07f99b541de4972d773f9169fb848aac84a477 | 4,200 | java | Java | modules/MusicBrainz/src/main/java/it/tidalwave/bluemarine2/metadata/musicbrainz/MusicBrainzMetadataProvider.java | fabriziogiudici/bluemarine2-src | 5bd725d04573598f4b02f3f055217c9bebe07fd5 | [
"Apache-2.0"
] | 3 | 2018-10-29T15:41:00.000Z | 2020-06-21T04:15:10.000Z | modules/MusicBrainz/src/main/java/it/tidalwave/bluemarine2/metadata/musicbrainz/MusicBrainzMetadataProvider.java | fabriziogiudici/bluemarine2-src | 5bd725d04573598f4b02f3f055217c9bebe07fd5 | [
"Apache-2.0"
] | 1 | 2021-04-09T14:56:29.000Z | 2021-04-09T14:56:29.000Z | modules/MusicBrainz/src/main/java/it/tidalwave/bluemarine2/metadata/musicbrainz/MusicBrainzMetadataProvider.java | tidalwave-it/bluemarine2-src | 5bd725d04573598f4b02f3f055217c9bebe07fd5 | [
"Apache-2.0"
] | null | null | null | 44.680851 | 120 | 0.465 | 3,376 | /*
* *********************************************************************************************************************
*
* blueMarine II: Semantic Media Centre
* http://tidalwave.it/projects/bluemarine2
*
* Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
*
* *********************************************************************************************************************
*
* 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.
*
* *********************************************************************************************************************
*
* git clone https://bitbucket.org/tidalwave/bluemarine2-src
* git clone https://github.com/tidalwave-it/bluemarine2-src
*
* *********************************************************************************************************************
*/
package it.tidalwave.bluemarine2.metadata.musicbrainz;
import javax.annotation.Nonnull;
import java.util.function.Function;
import java.io.IOException;
import org.musicbrainz.ns.mmd_2.Metadata;
import org.musicbrainz.ns.mmd_2.Recording;
import org.musicbrainz.ns.mmd_2.Release;
import org.musicbrainz.ns.mmd_2.ReleaseGroupList;
import org.musicbrainz.ns.mmd_2.ReleaseList;
import it.tidalwave.bluemarine2.rest.RestResponse;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
*
**********************************************************************************************************************/
public interface MusicBrainzMetadataProvider
{
@RequiredArgsConstructor @Getter @ToString(of = "name")
public static class ResourceType<TYPE>
{
@Nonnull
private final String name;
@Nonnull
private final Function<Metadata, TYPE> resultProvider;
}
public static final ResourceType<Release> RELEASE = new ResourceType<>("release", Metadata::getRelease);
public static final ResourceType<Recording> RECORDING = new ResourceType<>("recording", Metadata::getRecording);
public static final ResourceType<ReleaseList> DISC_ID = new ResourceType<>("discId", Metadata::getReleaseList);
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
@Nonnull
public RestResponse<ReleaseGroupList> findReleaseGroupByTitle (@Nonnull String title, @Nonnull String ... includes)
throws IOException, InterruptedException;
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
@Nonnull
public RestResponse<ReleaseList> findReleaseListByToc (@Nonnull String toc, @Nonnull String ... includes)
throws IOException, InterruptedException;
/*******************************************************************************************************************
*
*
*
******************************************************************************************************************/
@Nonnull
public <T> RestResponse<T> getResource (@Nonnull ResourceType<T> resourceType,
@Nonnull String id,
@Nonnull String ... includes)
throws IOException, InterruptedException;
}
|
3e07fa823943197e19366ed5c25a168997ab371e | 2,320 | java | Java | constellation-training-solutions/TrainingSolutions/src/au/gov/asd/tac/constellation/training/solutions/chapter9/HowManyOutbreaksQuestion.java | cygnus-x-1/constellation-training | 876dda5c3fea31b63ea30d534a72a45dddbee3f1 | [
"Apache-2.0"
] | 14 | 2019-08-15T06:26:47.000Z | 2022-03-23T21:54:10.000Z | constellation-training-solutions/TrainingSolutions/src/au/gov/asd/tac/constellation/training/solutions/chapter9/HowManyOutbreaksQuestion.java | cygnus-x-1/constellation-training | 876dda5c3fea31b63ea30d534a72a45dddbee3f1 | [
"Apache-2.0"
] | 2 | 2019-08-19T16:46:40.000Z | 2021-08-20T07:27:53.000Z | constellation-training-solutions/TrainingSolutions/src/au/gov/asd/tac/constellation/training/solutions/chapter9/HowManyOutbreaksQuestion.java | cygnus-x-1/constellation-training | 876dda5c3fea31b63ea30d534a72a45dddbee3f1 | [
"Apache-2.0"
] | 6 | 2019-08-15T09:23:32.000Z | 2021-11-22T06:58:23.000Z | 35.151515 | 102 | 0.7625 | 3,377 | /*
* Copyright 2010-2019 Australian Signals Directorate
*
* 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 au.gov.asd.tac.constellation.training.solutions.chapter9;
import au.gov.asd.tac.constellation.plugins.parameters.PluginParameters;
import au.gov.asd.tac.constellation.views.analyticview.aggregators.AnalyticAggregator;
import au.gov.asd.tac.constellation.views.analyticview.aggregators.SumScoreAggregator;
import au.gov.asd.tac.constellation.views.analyticview.analytics.AnalyticPlugin;
import au.gov.asd.tac.constellation.views.analyticview.questions.AnalyticQuestionDescription;
import au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult;
import au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult;
import java.util.Arrays;
import java.util.List;
import org.openide.util.lookup.ServiceProvider;
/**
* How Many Outbreaks Question.
*
* @author cygnus_x-1
*/
@ServiceProvider(service = AnalyticQuestionDescription.class)
public class HowManyOutbreaksQuestion implements AnalyticQuestionDescription {
@Override
public String getName() {
return "How many outbreaks?";
}
@Override
public String getDescription() {
return "Counts the number of outbreaks per city";
}
@Override
public List<Class<? extends AnalyticPlugin<ScoreResult>>> getPluginClasses() {
return Arrays.asList(OutbreakCountAnalytic.class);
}
@Override
public Class<? extends AnalyticAggregator<ScoreResult>> getAggregatorType() {
return SumScoreAggregator.class;
}
@Override
public Class<? extends AnalyticResult> getResultType() {
return ScoreResult.class;
}
@Override
public void initialiseParameters(final AnalyticPlugin plugin, final PluginParameters parameters) {
}
}
|
3e07fc518a8cfd56b530668a161d2881bd332078 | 1,148 | java | Java | Cadastro_Clientes/src/main/java/com/cadastro/cliente/api/application/util/DateUtil.java | pedrofortini/Sistema_Cadastro_Conta_Cartao | 32f859f03ba8487733dd2423cbeaa73e4853b517 | [
"MIT"
] | null | null | null | Cadastro_Clientes/src/main/java/com/cadastro/cliente/api/application/util/DateUtil.java | pedrofortini/Sistema_Cadastro_Conta_Cartao | 32f859f03ba8487733dd2423cbeaa73e4853b517 | [
"MIT"
] | 7 | 2020-06-18T17:26:41.000Z | 2021-01-21T01:08:11.000Z | Cadastro_Clientes/src/main/java/com/cadastro/cliente/api/application/util/DateUtil.java | pedrofortini/Sistema_Cadastro_Conta_Cartao | 32f859f03ba8487733dd2423cbeaa73e4853b517 | [
"MIT"
] | null | null | null | 27.333333 | 96 | 0.689895 | 3,378 | package com.cadastro.cliente.api.application.util;
import com.cadastro.cliente.api.application.MessageConstants;
import com.cadastro.cliente.api.application.exception.DataFormatoInvalidoException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtil {
public static Date stringToDate(String dateString){
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
try {
Date date = formatter.parse(dateString);
return date;
} catch (ParseException e) {
throw new DataFormatoInvalidoException(
String.format(MessageConstants.MENSAGEM_DATA_FORMATO_INVALIDO, dateString));
}
catch (Exception e) {
throw new DataFormatoInvalidoException(
String.format(MessageConstants.MENSAGEM_DATA_FORMATO_INVALIDO, dateString));
}
}
public static String dateToString(Date date){
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String dateString = formatter.format(date);
return dateString;
}
}
|
3e07fda0cfd05f313687975c7166d4daf621a243 | 2,721 | java | Java | corpus/class/eclipse.pde.ui/4044.java | masud-technope/ACER-Replication-Package-ASE2017 | cb7318a729eb1403004d451a164c851af2d81f7a | [
"MIT"
] | 15 | 2018-07-10T09:38:31.000Z | 2021-11-29T08:28:07.000Z | corpus/class/eclipse.pde.ui/4044.java | masud-technope/ACER-Replication-Package-ASE2017 | cb7318a729eb1403004d451a164c851af2d81f7a | [
"MIT"
] | 3 | 2018-11-16T02:58:59.000Z | 2021-01-20T16:03:51.000Z | corpus/class/eclipse.pde.ui/4044.java | masud-technope/ACER-Replication-Package-ASE2017 | cb7318a729eb1403004d451a164c851af2d81f7a | [
"MIT"
] | 6 | 2018-06-27T20:19:00.000Z | 2022-02-19T02:29:53.000Z | 43.190476 | 113 | 0.710401 | 3,379 | /*******************************************************************************
* Copyright (c) 2006, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.pde.internal.ui.editor.text;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.pde.internal.ui.editor.PDESourcePage;
import org.eclipse.pde.internal.ui.editor.contentassist.XMLContentAssistProcessor;
public class PluginXMLConfiguration extends XMLConfiguration {
private ContentAssistant fContentAssistant;
private XMLContentAssistProcessor fContentAssistProcessor;
private PluginXMLTextHover fTextHover;
public PluginXMLConfiguration(IColorManager colorManager, PDESourcePage page) {
super(colorManager, page);
}
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
if (sourceViewer.isEditable() && fContentAssistant == null) {
fContentAssistProcessor = new XMLContentAssistProcessor(fSourcePage);
fContentAssistant = new ContentAssistant();
fContentAssistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
fContentAssistant.setContentAssistProcessor(fContentAssistProcessor, IDocument.DEFAULT_CONTENT_TYPE);
fContentAssistant.setContentAssistProcessor(fContentAssistProcessor, XMLPartitionScanner.XML_TAG);
fContentAssistant.setInformationControlCreator(getInformationControlCreator(true));
fContentAssistant.setShowEmptyList(false);
fContentAssistant.addCompletionListener(fContentAssistProcessor);
fContentAssistant.enableAutoInsert(true);
}
return fContentAssistant;
}
@Override
public void dispose() {
if (fContentAssistProcessor != null)
fContentAssistProcessor.dispose();
super.dispose();
}
@Override
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
if (fTextHover == null && fSourcePage != null)
fTextHover = new PluginXMLTextHover(fSourcePage);
return fTextHover;
}
}
|
3e07fe871cd8b4c9b0324f1961d929957ff65e09 | 10,903 | java | Java | octopusconsortium/src/main/java/OctopusConsortium/Models/RCSGB/COCDTP146246GB01Section3.java | 111Online/ITK-MessagingEngine | 011e8cbe0bcb982eedc2204318d94e2bb5d4adb2 | [
"Apache-2.0"
] | null | null | null | octopusconsortium/src/main/java/OctopusConsortium/Models/RCSGB/COCDTP146246GB01Section3.java | 111Online/ITK-MessagingEngine | 011e8cbe0bcb982eedc2204318d94e2bb5d4adb2 | [
"Apache-2.0"
] | null | null | null | octopusconsortium/src/main/java/OctopusConsortium/Models/RCSGB/COCDTP146246GB01Section3.java | 111Online/ITK-MessagingEngine | 011e8cbe0bcb982eedc2204318d94e2bb5d4adb2 | [
"Apache-2.0"
] | 1 | 2021-04-10T17:21:14.000Z | 2021-04-10T17:21:14.000Z | 27.121891 | 130 | 0.554251 | 3,380 | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-257
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.10.24 at 11:01:41 AM BST
//
package OctopusConsortium.Models.RCSGB;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* <p>Java class for COCD_TP146246GB01.Section3 complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="COCD_TP146246GB01.Section3">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <group ref="{urn:hl7-org:v3}InfrastructureRootElements"/>
* <element name="code" type="{urn:hl7-org:v3}CV" minOccurs="0"/>
* <element name="id" type="{urn:hl7-org:v3}II.NPfIT.uuid.mandatory"/>
* <element name="templateId">
* <complexType>
* <complexContent>
* <restriction base="{urn:hl7-org:v3}II">
* <attribute name="root" use="required">
* <simpleType>
* <restriction base="{urn:hl7-org:v3}uid">
* <enumeration value="2.16.840.1.113883.2.1.3.2.4.18.2"/>
* </restriction>
* </simpleType>
* </attribute>
* <attribute name="extension" use="required">
* <simpleType>
* <restriction base="{urn:hl7-org:v3}st">
* <enumeration value="COCD_TP146246GB01#section3"/>
* </restriction>
* </simpleType>
* </attribute>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* <element name="text" type="{urn:hl7-org:v3}StrucDoc.Text" minOccurs="0"/>
* <element name="title" type="{urn:hl7-org:v3}ST" minOccurs="0"/>
* <element name="component3" type="{urn:hl7-org:v3}COCD_TP146246GB01.Component5" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* <attGroup ref="{urn:hl7-org:v3}InfrastructureRootAttributes"/>
* <attribute name="classCode" use="required" type="{urn:hl7-org:v3}cs" fixed="DOCSECT" />
* <attribute name="moodCode" use="required" type="{urn:hl7-org:v3}cs" fixed="EVN" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "COCD_TP146246GB01.Section3", propOrder = {
"code",
"id",
"templateId",
"text",
"title",
"component3"
})
public class COCDTP146246GB01Section3 {
protected CV code;
@XmlElement(required = true)
protected IINPfITUuidMandatory id;
@XmlElement(required = true)
protected COCDTP146246GB01Section3 .TemplateId templateId;
protected StrucDocText text;
protected ST title;
@XmlElement(nillable = true)
protected List<COCDTP146246GB01Component5> component3;
@XmlAttribute(required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String classCode;
@XmlAttribute(required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String moodCode;
@XmlAttribute
protected List<String> nullFlavor;
@XmlAttribute
protected CsUpdateMode updateMode;
/**
* Gets the value of the code property.
*
* @return
* possible object is
* {@link CV }
*
*/
public CV getCode() {
return code;
}
/**
* Sets the value of the code property.
*
* @param value
* allowed object is
* {@link CV }
*
*/
public void setCode(CV value) {
this.code = value;
}
/**
* Gets the value of the id property.
*
* @return
* possible object is
* {@link IINPfITUuidMandatory }
*
*/
public IINPfITUuidMandatory getId() {
return id;
}
/**
* Sets the value of the id property.
*
* @param value
* allowed object is
* {@link IINPfITUuidMandatory }
*
*/
public void setId(IINPfITUuidMandatory value) {
this.id = value;
}
/**
* Gets the value of the templateId property.
*
* @return
* possible object is
* {@link COCDTP146246GB01Section3 .TemplateId }
*
*/
public COCDTP146246GB01Section3 .TemplateId getTemplateId() {
return templateId;
}
/**
* Sets the value of the templateId property.
*
* @param value
* allowed object is
* {@link COCDTP146246GB01Section3 .TemplateId }
*
*/
public void setTemplateId(COCDTP146246GB01Section3 .TemplateId value) {
this.templateId = value;
}
/**
* Gets the value of the text property.
*
* @return
* possible object is
* {@link StrucDocText }
*
*/
public StrucDocText getText() {
return text;
}
/**
* Sets the value of the text property.
*
* @param value
* allowed object is
* {@link StrucDocText }
*
*/
public void setText(StrucDocText value) {
this.text = value;
}
/**
* Gets the value of the title property.
*
* @return
* possible object is
* {@link ST }
*
*/
public ST getTitle() {
return title;
}
/**
* Sets the value of the title property.
*
* @param value
* allowed object is
* {@link ST }
*
*/
public void setTitle(ST value) {
this.title = value;
}
/**
* Gets the value of the component3 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 component3 property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getComponent3().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link COCDTP146246GB01Component5 }
*
*
*/
public List<COCDTP146246GB01Component5> getComponent3() {
if (component3 == null) {
component3 = new ArrayList<COCDTP146246GB01Component5>();
}
return this.component3;
}
/**
* Gets the value of the classCode property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getClassCode() {
if (classCode == null) {
return "DOCSECT";
} else {
return classCode;
}
}
/**
* Sets the value of the classCode property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setClassCode(String value) {
this.classCode = value;
}
/**
* Gets the value of the moodCode property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMoodCode() {
if (moodCode == null) {
return "EVN";
} else {
return moodCode;
}
}
/**
* Sets the value of the moodCode property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMoodCode(String value) {
this.moodCode = value;
}
/**
* Gets the value of the nullFlavor 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 nullFlavor property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getNullFlavor().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link String }
*
*
*/
public List<String> getNullFlavor() {
if (nullFlavor == null) {
nullFlavor = new ArrayList<String>();
}
return this.nullFlavor;
}
/**
* Gets the value of the updateMode property.
*
* @return
* possible object is
* {@link CsUpdateMode }
*
*/
public CsUpdateMode getUpdateMode() {
return updateMode;
}
/**
* Sets the value of the updateMode property.
*
* @param value
* allowed object is
* {@link CsUpdateMode }
*
*/
public void setUpdateMode(CsUpdateMode value) {
this.updateMode = value;
}
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{urn:hl7-org:v3}II">
* <attribute name="root" use="required">
* <simpleType>
* <restriction base="{urn:hl7-org:v3}uid">
* <enumeration value="2.16.840.1.113883.2.1.3.2.4.18.2"/>
* </restriction>
* </simpleType>
* </attribute>
* <attribute name="extension" use="required">
* <simpleType>
* <restriction base="{urn:hl7-org:v3}st">
* <enumeration value="COCD_TP146246GB01#section3"/>
* </restriction>
* </simpleType>
* </attribute>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
public static class TemplateId
extends II
{
}
}
|
3e07feb4691842968f1c5a16c5d630994a00dab1 | 2,966 | java | Java | activemq-client/src/main/java/org/apache/activemq/util/ServiceStopper.java | doddi/activemq | 232ace82bc9cfeea7ffbce2d7e420a4c6aea1ef2 | [
"Apache-2.0"
] | 2,073 | 2015-01-01T15:27:57.000Z | 2022-03-31T09:08:51.000Z | activemq-client/src/main/java/org/apache/activemq/util/ServiceStopper.java | doddi/activemq | 232ace82bc9cfeea7ffbce2d7e420a4c6aea1ef2 | [
"Apache-2.0"
] | 338 | 2015-01-05T17:50:20.000Z | 2022-03-31T17:46:12.000Z | activemq-client/src/main/java/org/apache/activemq/util/ServiceStopper.java | ygubernatorov/activemq | a4c3fe90fab6b0b57f17d3b29c08f2e2d930c04e | [
"Apache-2.0"
] | 1,498 | 2015-01-03T10:58:42.000Z | 2022-03-28T05:11:21.000Z | 30.57732 | 107 | 0.630479 | 3,381 | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.activemq.util;
import java.util.Iterator;
import java.util.List;
import org.apache.activemq.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A helper class used to stop a bunch of services, catching and logging any
* exceptions and then throwing the first exception when everything is stoped.
*
*
*/
public class ServiceStopper {
private Throwable firstException;
/**
* Stops the given service, catching any exceptions that are thrown.
*/
public void stop(Service service) {
try {
if (service != null) {
service.stop();
}
} catch (Exception e) {
onException(service, e);
}
}
/**
* Performs the given code to stop some service handling the exceptions
* which may be thrown properly
*/
public void run(Callback stopClosure) {
try {
stopClosure.execute();
} catch (Throwable e) {
onException(stopClosure, e);
}
}
/**
* Stops a list of services
*/
public void stopServices(List services) {
for (Iterator iter = services.iterator(); iter.hasNext();) {
Service service = (Service)iter.next();
stop(service);
}
}
public void onException(Object owner, Throwable e) {
logError(owner, e);
if (firstException == null) {
firstException = e;
}
}
/**
* Throws the first exception that was thrown if there was one.
*/
public void throwFirstException() throws Exception {
if (firstException != null) {
if (firstException instanceof Exception) {
Exception e = (Exception)firstException;
throw e;
} else {
throw new RuntimeException("Unknown type of exception: " + firstException, firstException);
}
}
}
protected void logError(Object service, Throwable e) {
Logger log = LoggerFactory.getLogger(service.getClass());
log.error("Could not stop service: " + service + ". Reason: " + e, e);
}
}
|
3e07ffb2c72719c8b7ac57eaeeadac66c054b137 | 1,977 | java | Java | tests/src/test/java/io/openshift/booster/messaging/OpenShiftIT.java | ssorj/wfswarm-shared-work-queue | d745fa60c307bc6e740a66ece2f44f9cc7ac02c7 | [
"Apache-2.0"
] | null | null | null | tests/src/test/java/io/openshift/booster/messaging/OpenShiftIT.java | ssorj/wfswarm-shared-work-queue | d745fa60c307bc6e740a66ece2f44f9cc7ac02c7 | [
"Apache-2.0"
] | null | null | null | tests/src/test/java/io/openshift/booster/messaging/OpenShiftIT.java | ssorj/wfswarm-shared-work-queue | d745fa60c307bc6e740a66ece2f44f9cc7ac02c7 | [
"Apache-2.0"
] | 1 | 2018-06-26T14:29:37.000Z | 2018-06-26T14:29:37.000Z | 32.95 | 75 | 0.710167 | 3,382 | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 io.openshift.booster.messaging;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.UUID;
import org.arquillian.cube.openshift.impl.enricher.AwaitRoute;
import org.arquillian.cube.openshift.impl.enricher.RouteURL;
import org.jboss.arquillian.junit.Arquillian;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.jayway.restassured.RestAssured.given;
@RunWith(Arquillian.class)
public class OpenShiftIT {
@RouteURL("frontend")
@AwaitRoute(path = "/health")
private URL frontendUrl;
private URL dataUrl;
private URL requestUrl;
@Before
public void before() throws MalformedURLException {
dataUrl = new URL(frontendUrl, "api/data");
requestUrl = new URL(frontendUrl, "api/send-request");
}
@Test
public void testRequestProcessing() {
String text = UUID.randomUUID().toString();
String json = String.format("{'text': '%s'}", text);
given().body(text)
.contentType("application/json")
.post(requestUrl)
.then()
.assertThat()
.statusCode(200);
}
}
|
3e0800cfdd5bc450289ec65cb6e4f3569a00977e | 8,809 | java | Java | spring-bootstrap/src/main/java/org/springframework/bootstrap/context/embedded/FilterRegistrationBean.java | RunKeep/spring-boot | a038e870f6bbad1ee430b2742a672fbd44679cc5 | [
"Apache-2.0"
] | null | null | null | spring-bootstrap/src/main/java/org/springframework/bootstrap/context/embedded/FilterRegistrationBean.java | RunKeep/spring-boot | a038e870f6bbad1ee430b2742a672fbd44679cc5 | [
"Apache-2.0"
] | null | null | null | spring-bootstrap/src/main/java/org/springframework/bootstrap/context/embedded/FilterRegistrationBean.java | RunKeep/spring-boot | a038e870f6bbad1ee430b2742a672fbd44679cc5 | [
"Apache-2.0"
] | null | null | null | 34.410156 | 110 | 0.762402 | 3,383 | /*
* Copyright 2002-2013 the original author or authors.
*
* 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 org.springframework.bootstrap.context.embedded;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.springframework.util.Assert;
import org.springframework.web.ServletContextInitializer;
/**
* A {@link ServletContextInitializer} to register {@link Filter}s in a Servlet 3.0+
* container. Similar to the {@link ServletContext#addFilter(String, Filter) registration}
* features provided by {@link ServletContext} but with a Spring Bean friendly design.
*
* <p>
* The {@link #setFilter(Filter) Filter} must be specified before calling
* {@link #onStartup(ServletContext)}. Registrations can be associated with
* {@link #setUrlPatterns URL patterns} and/or servlets (either by
* {@link #setServletNames name} or via a {@link #setServletRegistrationBeans
* ServletRegistrationBean}s. When no URL pattern or servlets are specified the filter
* will be associated to '/*'. The filter name will be deduced if not specified.
*
* @author Phillip Webb
* @since 4.0
* @see ServletContextInitializer
* @see ServletContext#addFilter(String, Filter)
*/
public class FilterRegistrationBean extends RegistrationBean {
static final EnumSet<DispatcherType> ASYNC_DISPATCHER_TYPES = EnumSet.of(
DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST,
DispatcherType.ASYNC);
static final EnumSet<DispatcherType> NON_ASYNC_DISPATCHER_TYPES = EnumSet.of(
DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST);
private static final String[] DEFAULT_URL_MAPPINGS = { "/*" };
private Filter filter;
private Set<ServletRegistrationBean> servletRegistrationBeans = new LinkedHashSet<ServletRegistrationBean>();
private Set<String> servletNames = new LinkedHashSet<String>();
private Set<String> urlPatterns = new LinkedHashSet<String>();
private EnumSet<DispatcherType> dispatcherTypes;
private boolean matchAfter = false;
/**
* Create a new {@link FilterRegistrationBean} instance.
*/
public FilterRegistrationBean() {
}
/**
* Create a new {@link FilterRegistrationBean} instance to be registered with the
* specified {@link ServletRegistrationBean}s.
* @param filter the filter to register
* @param servletRegistrationBeans associate {@link ServletRegistrationBean}s
*/
public FilterRegistrationBean(Filter filter,
ServletRegistrationBean... servletRegistrationBeans) {
setFilter(filter);
addServletRegistrationBeans(servletRegistrationBeans);
}
/**
* Set the filter to be registered.
*/
public void setFilter(Filter filter) {
Assert.notNull(filter, "Filter must not be null");
this.filter = filter;
}
/**
* Set {@link ServletRegistrationBean}s that the filter will be registered against.
* @param servletRegistrationBeans the Servlet registration beans
*/
public void setServletRegistrationBeans(
Collection<? extends ServletRegistrationBean> servletRegistrationBeans) {
Assert.notNull(servletRegistrationBeans,
"ServletRegistrationBeans must not be null");
this.servletRegistrationBeans = new LinkedHashSet<ServletRegistrationBean>(
servletRegistrationBeans);
}
/**
* Return a mutable collection of the {@link ServletRegistrationBean} that the filter
* will be registered against. {@link ServletRegistrationBean}s.
* @return the Servlet registration beans
* @see #setServletNames
* @see #setUrlPatterns
*/
public Collection<ServletRegistrationBean> getServletRegistrationBeans() {
return this.servletRegistrationBeans;
}
/**
* Add {@link ServletRegistrationBean}s for the filter.
* @param servletRegistrationBeans the servlet registration beans to add
* @see #setServletRegistrationBeans
*/
public void addServletRegistrationBeans(
ServletRegistrationBean... servletRegistrationBeans) {
Assert.notNull(servletRegistrationBeans,
"ServletRegistrationBeans must not be null");
for (ServletRegistrationBean servletRegistrationBean : servletRegistrationBeans) {
this.servletRegistrationBeans.add(servletRegistrationBean);
}
}
/**
* Set servlet names that the filter will be registered against. This will replace any
* previously specified servlet names.
* @param servletNames the servlet names
* @see #setServletRegistrationBeans
* @see #setUrlPatterns
*/
public void setServletNames(Collection<String> servletNames) {
Assert.notNull(servletNames, "ServletNames must not be null");
this.servletNames = new LinkedHashSet<String>(servletNames);
}
/**
* Return a mutable collection of servlet names that the filter will be registered
* against.
* @return the servlet names
*/
public Collection<String> getServletNames() {
return this.servletNames;
}
/**
* Add servlet names for the filter.
* @param servletNames the servlet names to add
*/
public void addServletNames(String... servletNames) {
Assert.notNull(servletNames, "ServletNames must not be null");
this.servletNames.addAll(Arrays.asList(servletNames));
}
/**
* Set the URL patterns that the filter will be registered against. This will replace
* any previously specified URL patterns.
* @param urlPatterns the URL patterns
* @see #setServletRegistrationBeans
* @see #setServletNames
*/
public void setUrlPatterns(Collection<String> urlPatterns) {
Assert.notNull(urlPatterns, "UrlPatterns must not be null");
this.urlPatterns = new LinkedHashSet<String>(urlPatterns);
}
/**
* Return a mutable collection of URL patterns that the filter will be registered
* against.
* @return the URL patterns
*/
public Collection<String> getUrlPatterns() {
return this.urlPatterns;
}
/**
* Add URL patterns that the filter will be registered against.
* @param urlPatterns the URL patterns
*/
public void addUrlPatterns(String... urlPatterns) {
Assert.notNull(urlPatterns, "UrlPatterns must not be null");
for (String urlPattern : urlPatterns) {
this.urlPatterns.add(urlPattern);
}
}
/**
* Set if the filter mappings should be matched after any declared filter mappings of
* the ServletContext. Defaults to {@code false} indicating the filters are supposed
* to be matched before any declared filter mappings of the ServletContext.
*/
public void setMatchAfter(boolean matchAfter) {
this.matchAfter = matchAfter;
}
/**
* Return if filter mappings should be matched after any declared Filter mappings of
* the ServletContext.
*/
public boolean isMatchAfter() {
return this.matchAfter;
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
Assert.notNull(this.filter, "Filter must not be null");
configure(servletContext.addFilter(getOrDeduceName(this.filter), this.filter));
}
/**
* Configure registration settings. Subclasses can override this method to perform
* additional configuration if required.
*/
protected void configure(FilterRegistration.Dynamic registration) {
super.configure(registration);
EnumSet<DispatcherType> dispatcherTypes = this.dispatcherTypes;
if (dispatcherTypes == null) {
dispatcherTypes = (isAsyncSupported() ? ASYNC_DISPATCHER_TYPES
: NON_ASYNC_DISPATCHER_TYPES);
}
Set<String> servletNames = new LinkedHashSet<String>();
for (ServletRegistrationBean servletRegistrationBean : this.servletRegistrationBeans) {
servletNames.add(servletRegistrationBean.getServletName());
}
servletNames.addAll(this.servletNames);
if (servletNames.isEmpty() && this.urlPatterns.isEmpty()) {
registration.addMappingForUrlPatterns(dispatcherTypes, this.matchAfter,
DEFAULT_URL_MAPPINGS);
} else {
if (servletNames.size() > 0) {
registration.addMappingForServletNames(dispatcherTypes, this.matchAfter,
servletNames.toArray(new String[servletNames.size()]));
}
if (this.urlPatterns.size() > 0) {
registration.addMappingForUrlPatterns(dispatcherTypes, this.matchAfter,
this.urlPatterns.toArray(new String[this.urlPatterns.size()]));
}
}
}
}
|
3e08013a7388eeb38facb16e4457a5f92443cf06 | 1,939 | java | Java | src/com/twu/biblioteca/BibliotecaApp.java | jvomarquestw/twu-biblioteca-joaovictor | 81e0017743e6563682e4feaab3283b46990ea0d0 | [
"Apache-2.0"
] | null | null | null | src/com/twu/biblioteca/BibliotecaApp.java | jvomarquestw/twu-biblioteca-joaovictor | 81e0017743e6563682e4feaab3283b46990ea0d0 | [
"Apache-2.0"
] | null | null | null | src/com/twu/biblioteca/BibliotecaApp.java | jvomarquestw/twu-biblioteca-joaovictor | 81e0017743e6563682e4feaab3283b46990ea0d0 | [
"Apache-2.0"
] | null | null | null | 28.514706 | 76 | 0.65343 | 3,384 | package com.twu.biblioteca;
import com.twu.biblioteca.domain.Book;
import com.twu.biblioteca.domain.Library;
import com.twu.biblioteca.domain.Menu;
import com.twu.biblioteca.domain.MenuItem;
import com.twu.biblioteca.helper.Message;
import com.twu.biblioteca.helper.Util;
import java.util.ArrayList;
import java.util.List;
public class BibliotecaApp {
private static Menu menu;
private static Library library;
public static void main(String[] args) {
System.out.println(Message.WELCOME);
library = new Library(generateDefaultBookList());
generateMenu();
System.out.println(menu.getContent());
String returnChooseMenuItem = menu.chooseMenuItem(Util.readInput());
System.out.println(returnChooseMenuItem);
while(returnChooseMenuItem != Message.QUIT){
System.out.println(menu.getContent());
returnChooseMenuItem = menu.chooseMenuItem(Util.readInput());
System.out.println(returnChooseMenuItem);
}
}
private static List<Book> generateDefaultBookList(){
Book book1 = new Book("1", "Book 1", "Joao", 1996);
Book book2 = new Book("2", "Book 2", "Lucas", 1993);
Book book3 = new Book("3", "Book 3", "Jamille", 1996);
List<Book> bookList = new ArrayList<Book>();
bookList.add(book1);
bookList.add(book2);
bookList.add(book3);
return bookList;
}
private static void generateMenu(){
menu = new Menu(library);
MenuItem menuItem1 = new MenuItem("List of books", "1");
MenuItem menuItem2 = new MenuItem("Checkout a book", "2");
MenuItem menuItem3 = new MenuItem("Return a book", "3");
MenuItem menuItem4 = new MenuItem("Quit application", "0");
menu.addMenuItem(menuItem1);
menu.addMenuItem(menuItem2);
menu.addMenuItem(menuItem3);
menu.addMenuItem(menuItem4);
}
}
|
3e0801cff22cd0566f8e4c5c30af9ed6d9ea1bee | 4,901 | java | Java | src/GameModel.java | PedroCardouzo/SimonSays | 955ab6242e51b4f6aeb2ef07c7065f0d1c3b55ea | [
"MIT"
] | null | null | null | src/GameModel.java | PedroCardouzo/SimonSays | 955ab6242e51b4f6aeb2ef07c7065f0d1c3b55ea | [
"MIT"
] | null | null | null | src/GameModel.java | PedroCardouzo/SimonSays | 955ab6242e51b4f6aeb2ef07c7065f0d1c3b55ea | [
"MIT"
] | null | null | null | 28.494186 | 122 | 0.618853 | 3,385 | import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class GameModel implements IGameLogic{
private List<Integer> sequence;
private int sequenceValueRange; // number of states an element of que sequence can be
private int points;
private int index;
private int difficulty;
private String playerName;
private IGamePresenter view;
// function for printing and such, will be eliminated later
private void test(){
System.out.println("Name: "+this.getPlayerName());
System.out.println("Difficulty: "+this.getDifficulty());
}
public GameModel(IGamePresenter view){
this.view = view;
this.setVolume(1.0);
this.newGame();
}
private void newGame(){
this.sequenceValueRange = GameView.NUMBER_OF_BUTTONS; // only relevant if using pushRandomRecord
this.setSequence(new ArrayList<Integer>());
this.setPoints(0);
this.setIndex(0);
}
public GameModel(IGamePresenter view, Integer n){
this.view = view;
this.setVolume(1.0);
this.newGame(n);
}
private void newGame(Integer n){
this.sequenceValueRange = n; // only relevant if using pushRandomRecord
this.setSequence(new ArrayList<Integer>());
this.setPoints(0);
this.setIndex(0);
}
@Override
public void startGame(){
this.pushRandomRecord();
this.view.setDifficulty(this.getDifficulty());
this.view.setTimeSpan(1000/this.getDifficulty());
this.view.showNewSequence(this.getSequence());
this.view.showNewPoints(this.getPoints());
}
@Override
public void setPlayerName(String playerName){ this.playerName = playerName; }
private String getPlayerName(){ return this.playerName; }
private void setDifficulty(int dif){ this.difficulty = dif > 0? dif : 2; }
@Override
public void setDifficulty(String dif){
int difficulty;
switch (dif){
case "easy": difficulty = 1;
break;
case "medium": difficulty = 2;
break;
case "hard": difficulty = 3;
break;
default: difficulty = 2;
}
this.setDifficulty(difficulty);
}
private int getDifficulty(){ return this.difficulty; }
private void incIndex(){ this.index++; }
private void setIndex(int i){ this.index = i; }
private int getIndex(){ return this.index; }
private void setPoints(int pts){ this.points = pts; }
private void addPoints(int x){ this.points += x; }
@Override
public void setSoundFX(Integer buttonNumber, String soundURI) {
this.view.getColoredButton(buttonNumber).setClickSound(soundURI);
}
@Override
public void setVolume(double x){
if(x > 1.0)
x = 1.0;
else if(x < 0)
x = 0.0;
this.view.setVolume(x);
}
private Integer popRecord(){
return sequence.remove(sequence.size()-1);
}
private void pushRecord(Integer n){
sequence.add(n);
}
private void pushRandomRecord(){
Random rand = new Random();
Integer i = rand.nextInt(this.sequenceValueRange);
this.pushRecord(i);
System.out.println("Sequence: " + this.sequence.toString());
}
@Override
public void checkNewTry(Integer theTry){
Integer nextSequenceElement = sequence.get(this.getIndex());
if(theTry.equals(nextSequenceElement)) {
this.incIndex();
if(this.index == this.getSequenceLength()) {
this.setIndex(0);
this.addNextElement();
this.addPoints(this.getDifficulty());
this.view.showNewSequence(this.getSequence());
this.view.showNewPoints(this.getPoints());
}
}else
this.gameOver();
}
@Override
// API: you may inherit this class and then override this method to implement your own "next round, new element" logic
public void addNextElement(){
this.pushRandomRecord();
}
@Override
public void clickedFeedback(Integer clickedButton){
this.view.showClickedButton(clickedButton);
}
private void gameOver(){
// todo: save if top 10 (a method in model)
this.sequence = new ArrayList<>();
this.setIndex(0);
this.view.gameOver();
}
@Override
public void closeGame(){
// todo: save if top 10 (a method in model)
}
private int getSequenceLength(){ return this.sequence.size(); }
private int getPoints(){ return this.points; }
private void setSequence(ArrayList<Integer> ns){ this.sequence = ns; }
// returns a copy so that the model state is not changed
private List<Integer> getSequence() { return new ArrayList<>(this.sequence); }
}
|
3e0803d9e19b2dd0047641db0e625cd119c5738f | 663 | java | Java | ProblemSolving/src/makingAnagram/Strinchild.java | raviranjan1996/Java14 | 1d692969cc9aaf53d06e08e27bf9ff8211525337 | [
"MIT"
] | null | null | null | ProblemSolving/src/makingAnagram/Strinchild.java | raviranjan1996/Java14 | 1d692969cc9aaf53d06e08e27bf9ff8211525337 | [
"MIT"
] | null | null | null | ProblemSolving/src/makingAnagram/Strinchild.java | raviranjan1996/Java14 | 1d692969cc9aaf53d06e08e27bf9ff8211525337 | [
"MIT"
] | null | null | null | 14.733333 | 41 | 0.518854 | 3,386 | package makingAnagram;
import java.util.Scanner;
public class Strinchild {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s1 = sc.nextLine();
String s2 = sc.nextLine();
char[] c1 = s1.toCharArray();
char[] c2 = s2.toCharArray();
int[] array = new int[26];
int index=0;
int count=0;
for(int i=0 ; i < c1.length ; i++) {
for(int j=0 ; j<=i ; j++) {
if(c1[i] == c2[j]) {
index = c1[i] -'A';
array[index]++;
break;
}
}
}
for(int k=0 ; k<array.length ;k++) {
if(array[k]>0) {
count++;
}
}
System.out.println(count);
}
}
|
3e08044a12229e8f2e2548fb10c31558a7f474d5 | 6,539 | java | Java | src/main/java/net/minecraft/entity/monster/EntityCreeper.java | AspireWorld-Project/AspireCore | 61dfc4f6cc7bca4ed7fd4de1413b7c8030a72042 | [
"WTFPL"
] | null | null | null | src/main/java/net/minecraft/entity/monster/EntityCreeper.java | AspireWorld-Project/AspireCore | 61dfc4f6cc7bca4ed7fd4de1413b7c8030a72042 | [
"WTFPL"
] | null | null | null | src/main/java/net/minecraft/entity/monster/EntityCreeper.java | AspireWorld-Project/AspireCore | 61dfc4f6cc7bca4ed7fd4de1413b7c8030a72042 | [
"WTFPL"
] | null | null | null | 26.366935 | 97 | 0.72427 | 3,387 | package net.minecraft.entity.monster;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import org.bukkit.craftbukkit.event.CraftEventFactory;
public class EntityCreeper extends EntityMob {
private int lastActiveTime;
private int timeSinceIgnited;
private int fuseTime = 30;
private int explosionRadius = 3;
private static final String __OBFID = "CL_00001684";
public void setPowered(boolean powered) {
if (!powered) {
dataWatcher.updateObject(17, Byte.valueOf((byte) 0));
} else {
dataWatcher.updateObject(17, Byte.valueOf((byte) 1));
}
}
public EntityCreeper(World p_i1733_1_) {
super(p_i1733_1_);
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(2, new EntityAICreeperSwell(this));
tasks.addTask(3, new EntityAIAvoidEntity(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D));
tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, false));
tasks.addTask(5, new EntityAIWander(this, 0.8D));
tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
tasks.addTask(6, new EntityAILookIdle(this));
targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D);
}
@Override
public boolean isAIEnabled() {
return true;
}
@Override
public int getMaxSafePointTries() {
return getAttackTarget() == null ? 3 : 3 + (int) (getHealth() - 1.0F);
}
@Override
protected void fall(float p_70069_1_) {
super.fall(p_70069_1_);
timeSinceIgnited = (int) (timeSinceIgnited + p_70069_1_ * 1.5F);
if (timeSinceIgnited > fuseTime - 5) {
timeSinceIgnited = fuseTime - 5;
}
}
@Override
protected void entityInit() {
super.entityInit();
dataWatcher.addObject(16, Byte.valueOf((byte) -1));
dataWatcher.addObject(17, Byte.valueOf((byte) 0));
dataWatcher.addObject(18, Byte.valueOf((byte) 0));
}
@Override
public void writeEntityToNBT(NBTTagCompound p_70014_1_) {
super.writeEntityToNBT(p_70014_1_);
if (dataWatcher.getWatchableObjectByte(17) == 1) {
p_70014_1_.setBoolean("powered", true);
}
p_70014_1_.setShort("Fuse", (short) fuseTime);
p_70014_1_.setByte("ExplosionRadius", (byte) explosionRadius);
p_70014_1_.setBoolean("ignited", func_146078_ca());
}
@Override
public void readEntityFromNBT(NBTTagCompound p_70037_1_) {
super.readEntityFromNBT(p_70037_1_);
dataWatcher.updateObject(17, Byte.valueOf((byte) (p_70037_1_.getBoolean("powered") ? 1 : 0)));
if (p_70037_1_.hasKey("Fuse", 99)) {
fuseTime = p_70037_1_.getShort("Fuse");
}
if (p_70037_1_.hasKey("ExplosionRadius", 99)) {
explosionRadius = p_70037_1_.getByte("ExplosionRadius");
}
if (p_70037_1_.getBoolean("ignited")) {
func_146079_cb();
}
}
@Override
public void onUpdate() {
if (isEntityAlive()) {
lastActiveTime = timeSinceIgnited;
if (func_146078_ca()) {
setCreeperState(1);
}
int i = getCreeperState();
if (i > 0 && timeSinceIgnited == 0) {
playSound("creeper.primed", 1.0F, 0.5F);
}
timeSinceIgnited += i;
if (timeSinceIgnited < 0) {
timeSinceIgnited = 0;
}
if (timeSinceIgnited >= fuseTime) {
timeSinceIgnited = fuseTime;
func_146077_cc();
}
}
super.onUpdate();
}
@Override
protected String getHurtSound() {
return "mob.creeper.say";
}
@Override
protected String getDeathSound() {
return "mob.creeper.death";
}
@Override
public void onDeath(DamageSource p_70645_1_) {
super.onDeath(p_70645_1_);
if (p_70645_1_.getEntity() instanceof EntitySkeleton) {
int i = Item.getIdFromItem(Items.record_13);
int j = Item.getIdFromItem(Items.record_wait);
int k = i + rand.nextInt(j - i + 1);
dropItem(Item.getItemById(k), 1);
}
}
@Override
public boolean attackEntityAsMob(Entity p_70652_1_) {
return true;
}
public boolean getPowered() {
return dataWatcher.getWatchableObjectByte(17) == 1;
}
@SideOnly(Side.CLIENT)
public float getCreeperFlashIntensity(float p_70831_1_) {
return (lastActiveTime + (timeSinceIgnited - lastActiveTime) * p_70831_1_) / (fuseTime - 2);
}
@Override
protected Item getDropItem() {
return Items.gunpowder;
}
public int getCreeperState() {
return dataWatcher.getWatchableObjectByte(16);
}
public void setCreeperState(int p_70829_1_) {
dataWatcher.updateObject(16, Byte.valueOf((byte) p_70829_1_));
}
@Override
public void onStruckByLightning(EntityLightningBolt ligtning) {
boolean lastPowered = getPowered();
super.onStruckByLightning(ligtning);
if (ligtning != null) {
setPowered(lastPowered);
// CraftBukkit start
if (CraftEventFactory.callCreeperPowerEvent(this, ligtning,
org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled())
return;
}
setPowered(true);
}
@Override
protected boolean interact(EntityPlayer p_70085_1_) {
ItemStack itemstack = p_70085_1_.inventory.getCurrentItem();
if (itemstack != null && itemstack.getItem() == Items.flint_and_steel) {
worldObj.playSoundEffect(posX + 0.5D, posY + 0.5D, posZ + 0.5D, "fire.ignite", 1.0F,
rand.nextFloat() * 0.4F + 0.8F);
p_70085_1_.swingItem();
if (!worldObj.isRemote) {
func_146079_cb();
itemstack.damageItem(1, p_70085_1_);
return true;
}
}
return super.interact(p_70085_1_);
}
private void func_146077_cc() {
if (!worldObj.isRemote) {
boolean flag = worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing");
if (getPowered()) {
worldObj.createExplosion(this, posX, posY, posZ, explosionRadius * 2, flag);
} else {
worldObj.createExplosion(this, posX, posY, posZ, explosionRadius, flag);
}
setDead();
}
}
public boolean func_146078_ca() {
return dataWatcher.getWatchableObjectByte(18) != 0;
}
public void func_146079_cb() {
dataWatcher.updateObject(18, Byte.valueOf((byte) 1));
}
} |
3e0804c993df5c7a1ecf3b378923b0a7dfdcd262 | 218 | java | Java | gulimall-order/src/test/java/com/lyf/gulimall/order/GulimallOrderApplicationTests.java | yufan-lu/gulimall | b4d46b7445047b43f022a3ac1cb2880a1fc3b07c | [
"Apache-2.0"
] | null | null | null | gulimall-order/src/test/java/com/lyf/gulimall/order/GulimallOrderApplicationTests.java | yufan-lu/gulimall | b4d46b7445047b43f022a3ac1cb2880a1fc3b07c | [
"Apache-2.0"
] | null | null | null | gulimall-order/src/test/java/com/lyf/gulimall/order/GulimallOrderApplicationTests.java | yufan-lu/gulimall | b4d46b7445047b43f022a3ac1cb2880a1fc3b07c | [
"Apache-2.0"
] | null | null | null | 15.571429 | 60 | 0.756881 | 3,388 | package com.lyf.gulimall.order;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class GulimallOrderApplicationTests {
@Test
void contextLoads() {
}
}
|
3e08067a146d47d6002f169074c59b2ac9e3d32a | 1,767 | java | Java | server/management/src/main/java/com/tianlihu/management/service/LogService.java | tianlihu/vue-management-springboot | 669445b9b1f191dfe897714523249a0a4482a9bd | [
"MIT"
] | null | null | null | server/management/src/main/java/com/tianlihu/management/service/LogService.java | tianlihu/vue-management-springboot | 669445b9b1f191dfe897714523249a0a4482a9bd | [
"MIT"
] | 4 | 2021-03-10T14:24:50.000Z | 2022-02-19T00:34:08.000Z | server/management/src/main/java/com/tianlihu/management/service/LogService.java | tianlihu/vue-management-springboot | 669445b9b1f191dfe897714523249a0a4482a9bd | [
"MIT"
] | 1 | 2020-04-12T10:19:03.000Z | 2020-04-12T10:19:03.000Z | 32.127273 | 67 | 0.662705 | 3,389 | package com.tianlihu.management.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tianlihu.management.entity.Log;
import com.tianlihu.management.mapper.LogMapper;
import com.tianlihu.management.query.LogQuery;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* <p>日志 服务实现类</p>
*
* @author tianlihu
* @since 2020-04-14
*/
@Service
@Transactional
public class LogService extends ServiceImpl<LogMapper, Log> {
public IPage<Log> page(LogQuery query) {
QueryWrapper<Log> wrapper = new QueryWrapper<>();
if (query.getUserId() != null) {
wrapper.eq("user_id", query.getUserId());
}
if (StringUtils.isNotBlank(query.getType())) {
wrapper.like("type", query.getType());
}
if (query.getCreateTime() != null) {
wrapper.eq("create_time", query.getCreateTime());
}
if (StringUtils.isNotBlank(query.getContent())) {
wrapper.like("content", query.getContent());
}
if (StringUtils.isNotBlank(query.getIp())) {
wrapper.like("ip", query.getIp());
}
return super.page(query, wrapper);
}
@Override
public boolean updateById(Log log) {
Log dbLog = getById(log.getLogId());
dbLog.setUserId(log.getUserId());
dbLog.setType(log.getType());
dbLog.setCreateTime(log.getCreateTime());
dbLog.setContent(log.getContent());
dbLog.setIp(log.getIp());
return super.updateById(log);
}
}
|
3e0808a9fa6cd16a75ef49de871f16291d74ffca | 995 | java | Java | im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliApp.java | yub1ng/easemob-im-server-sdk | 9196720266c562bb40d4abfac3a2f854b23a4815 | [
"Apache-2.0"
] | 9 | 2021-01-16T07:16:01.000Z | 2021-11-22T13:43:10.000Z | im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliApp.java | yub1ng/easemob-im-server-sdk | 9196720266c562bb40d4abfac3a2f854b23a4815 | [
"Apache-2.0"
] | 3 | 2021-03-16T07:19:08.000Z | 2022-03-08T10:43:19.000Z | im-sdk-cli/src/main/java/com/easemob/im/cli/IMCliApp.java | yub1ng/easemob-im-server-sdk | 9196720266c562bb40d4abfac3a2f854b23a4815 | [
"Apache-2.0"
] | 27 | 2021-01-31T12:20:13.000Z | 2021-12-16T07:51:18.000Z | 26.184211 | 78 | 0.751759 | 3,390 | package com.easemob.im.cli;
import com.easemob.im.server.EMService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import picocli.CommandLine;
@SpringBootApplication
public class IMCliApp implements CommandLineRunner, ExitCodeGenerator {
@Autowired
private CommandLine.IFactory factory;
@Autowired
private IMCliCmd cmd;
@Autowired
private EMService service;
private int exitCode;
public static void main(String[] args) {
SpringApplication.run(IMCliApp.class, args);
}
@Override
public void run(String... args) throws Exception {
this.exitCode = new CommandLine(this.cmd, this.factory).execute(args);
}
@Override
public int getExitCode() {
return this.exitCode;
}
}
|
3e080a065557a986e661e5102609430a0691069d | 107 | java | Java | hafta-1-java-temelleri-ve-oop/src/com/java/temelleriSoru7/PersonalReport.java | kodluyoruz-java-101-31102020-odevler/hafta-1-java-temelleri-ve-oop-AkcayHasan | d6221fa4f084cc7c8a3b43fde0aebc0cec91980b | [
"MIT"
] | null | null | null | hafta-1-java-temelleri-ve-oop/src/com/java/temelleriSoru7/PersonalReport.java | kodluyoruz-java-101-31102020-odevler/hafta-1-java-temelleri-ve-oop-AkcayHasan | d6221fa4f084cc7c8a3b43fde0aebc0cec91980b | [
"MIT"
] | null | null | null | hafta-1-java-temelleri-ve-oop/src/com/java/temelleriSoru7/PersonalReport.java | kodluyoruz-java-101-31102020-odevler/hafta-1-java-temelleri-ve-oop-AkcayHasan | d6221fa4f084cc7c8a3b43fde0aebc0cec91980b | [
"MIT"
] | 1 | 2021-01-06T13:56:21.000Z | 2021-01-06T13:56:21.000Z | 13.375 | 37 | 0.757009 | 3,391 | package com.java.temelleriSoru7;
public class PersonalReport{
String hashMD5Result = new String();
}
|
3e080a09cad1b5b38c7ced53818e8270f06c2009 | 944 | java | Java | mykit-weixin-sdk-mp/src/main/java/io/mykit/weixin/sdk/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java | sunshinelyz/mykit-weixin-sdk | 434101d73545f8511c67ab2e4e956bdfcf5f1876 | [
"Apache-2.0"
] | 2 | 2018-07-15T12:02:14.000Z | 2019-01-17T11:49:39.000Z | mykit-weixin-sdk-mp/src/main/java/io/mykit/weixin/sdk/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java | sunshinelyz/mykit-weixin-sdk | 434101d73545f8511c67ab2e4e956bdfcf5f1876 | [
"Apache-2.0"
] | null | null | null | mykit-weixin-sdk-mp/src/main/java/io/mykit/weixin/sdk/mp/bean/kefu/result/WxMpKfSessionWaitCaseList.java | sunshinelyz/mykit-weixin-sdk | 434101d73545f8511c67ab2e4e956bdfcf5f1876 | [
"Apache-2.0"
] | null | null | null | 23.02439 | 68 | 0.758475 | 3,392 | package io.mykit.weixin.sdk.mp.bean.kefu.result;
import com.google.gson.annotations.SerializedName;
import io.mykit.weixin.sdk.common.utils.ToStringUtils;
import io.mykit.weixin.sdk.mp.utils.json.WxMpGsonBuilder;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author liuyazhuang
*/
@Data
public class WxMpKfSessionWaitCaseList implements Serializable {
private static final long serialVersionUID = 2432132626631361922L;
/**
* count 未接入会话数量
*/
@SerializedName("count")
private Long count;
/**
* waitcaselist 未接入会话列表,最多返回100条数据
*/
@SerializedName("waitcaselist")
private List<WxMpKfSession> kfSessionWaitCaseList;
public static WxMpKfSessionWaitCaseList fromJson(String json) {
return WxMpGsonBuilder.INSTANCE.create().fromJson(json,
WxMpKfSessionWaitCaseList.class);
}
@Override
public String toString() {
return ToStringUtils.toSimpleString(this);
}
}
|
3e080ac6c62025278aef0b2fd7887240704d827c | 255 | java | Java | UwUWare/src/minecraft/net/shadersmod/common/SMCVersion.java | 14ms/Minecraft-Disclosed-Source-Modifications | d3729ab0fb20c36da1732b2070d1cb5d1409ffbc | [
"Unlicense"
] | 3 | 2022-02-28T17:34:51.000Z | 2022-03-06T21:55:16.000Z | UwUWare/src/minecraft/net/shadersmod/common/SMCVersion.java | 14ms/Minecraft-Disclosed-Source-Modifications | d3729ab0fb20c36da1732b2070d1cb5d1409ffbc | [
"Unlicense"
] | 2 | 2022-02-25T20:10:14.000Z | 2022-03-03T14:25:03.000Z | UwUWare/src/minecraft/net/shadersmod/common/SMCVersion.java | 14ms/Minecraft-Disclosed-Source-Modifications | d3729ab0fb20c36da1732b2070d1cb5d1409ffbc | [
"Unlicense"
] | null | null | null | 28.333333 | 53 | 0.760784 | 3,393 | package net.shadersmod.common;
public class SMCVersion {
public static final String mcVersion = "1.8.8";
public static final String versionString = "2.4.12";
public static final int versionNumber = 132108;
public static final int buildNumber = 83;
}
|
3e080b5c5e442485322cb6ba2c8843b1e1d7938b | 1,155 | java | Java | src/main/java/com/sdf/core/service/system/ISysUserService.java | sdf921110/SDF-FRAME | cbef91a643db2e5bd44701bb284ffc564a0e5f1d | [
"Apache-2.0"
] | 2 | 2017-10-16T02:37:05.000Z | 2017-10-21T06:32:47.000Z | src/main/java/com/sdf/core/service/system/ISysUserService.java | sdf921110/SDF-FRAME | cbef91a643db2e5bd44701bb284ffc564a0e5f1d | [
"Apache-2.0"
] | 5 | 2020-03-04T21:57:58.000Z | 2022-02-09T22:54:46.000Z | src/main/java/com/sdf/core/service/system/ISysUserService.java | sdf921110/SDF-FRAME | cbef91a643db2e5bd44701bb284ffc564a0e5f1d | [
"Apache-2.0"
] | null | null | null | 25.666667 | 117 | 0.754978 | 3,394 | package com.sdf.core.service.system;
import com.sdf.common.pojo.MSG;
import com.sdf.common.pojo.SessionUser;
import com.sdf.core.pojo.system.SysFileUrl;
import com.sdf.core.pojo.system.SysUser;
import com.sdf.core.service.BaseService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
/**
* 后台用户接口
*
* @Date: 2017/10/21 16:43
* @Author: SDF
* @Version: 1.0
*/
public interface ISysUserService {
/*public Integer insert(SysUser sysUser);*/
public Integer update(SysUser sysUser);
public Integer deleteById(int id);
public SysUser selectById(int id);
public SysUser selectByPhone(String phone);
public SysUser selectByCode(String code);
public List<SysUser> selectList();
public SessionUser login_submit(String code, String password, HttpServletRequest request);
public SysUser getInfo(Integer userId);
public void submit(HashMap<String, Object> result, SysUser sysUser, HttpSession session);
public void changePwdSubmit(HashMap<String, Object> result, String oldPwd, SysUser sysUser, HttpSession session);
}
|
3e080c9b4657f2512150b73cf9256469f9d0d1d0 | 1,481 | java | Java | app/src/main/java/com/yundian/blackcard/android/model/TribeMemberModel.java | tmtbb/blackad | 613fe3fc88863f8fa19225dce7ef79fadcb75fa5 | [
"Apache-2.0"
] | 1 | 2019-03-21T15:54:18.000Z | 2019-03-21T15:54:18.000Z | app/src/main/java/com/yundian/blackcard/android/model/TribeMemberModel.java | tmtbb/blackad | 613fe3fc88863f8fa19225dce7ef79fadcb75fa5 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/yundian/blackcard/android/model/TribeMemberModel.java | tmtbb/blackad | 613fe3fc88863f8fa19225dce7ef79fadcb75fa5 | [
"Apache-2.0"
] | null | null | null | 19.038462 | 49 | 0.606734 | 3,395 | package com.yundian.blackcard.android.model;
/**
* @author : created by chuangWu
* @version : 0.01
* @email : hzdkv@example.com
* @created time : 2017-06-21 14:11
* @description : none
* @for your attention : none
* @revise : none
*/
public class TribeMemberModel extends BaseModel {
private int status;
private int userId;
private int identity;
private String nickName;
private String id;
private String headUrl;
private long createTime;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public int getIdentity() {
return identity;
}
public void setIdentity(int identity) {
this.identity = identity;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getHeadUrl() {
return headUrl;
}
public void setHeadUrl(String headUrl) {
this.headUrl = headUrl;
}
public long getCreateTime() {
return createTime;
}
public void setCreateTime(long createTime) {
this.createTime = createTime;
}
}
|
3e080cd4e4bfe2ff1574255a9cc79eec8c8de265 | 586 | java | Java | src/de/kuriositaet/pomerator/GPGSigner.java | a2800276/pomerator | e0dc79ce4d05bc07c885d646181d27cbe3bbd5c7 | [
"MIT"
] | null | null | null | src/de/kuriositaet/pomerator/GPGSigner.java | a2800276/pomerator | e0dc79ce4d05bc07c885d646181d27cbe3bbd5c7 | [
"MIT"
] | null | null | null | src/de/kuriositaet/pomerator/GPGSigner.java | a2800276/pomerator | e0dc79ce4d05bc07c885d646181d27cbe3bbd5c7 | [
"MIT"
] | null | null | null | 25.478261 | 93 | 0.665529 | 3,396 | package de.kuriositaet.pomerator;
import static de.kuriositaet.pomerator.Stuff.exec;
/**
* Created by a2800276 on 2017-01-25.
*/
public class GPGSigner {
public static String DEFAULT = "A4B924E5";
public static void sign (String filename, String key) {
//p("signing: "+filename);
//String gpgCommand = String.format("gpg2 -ab --no-tty --local-user %s %s", key, filename);
String [] gpgCommand = {"gpg2", "-ab", "--no-tty", "--local-user", key, filename};
//p(gpgCommand);
exec(gpgCommand);
}
public static void main (String [] args) {
sign(args[0], DEFAULT);
}
}
|
3e080cfcd0613ea36163390bbb0cfc9185403908 | 987 | java | Java | lesson17Thematic/src/main/java/org/walkgis/learngis/lesson17/basicclasses/GISThematic.java | polixiaohai/learn_gis | 293847056dc965d5063155a61d5971cb25ccb15d | [
"Apache-2.0"
] | 7 | 2019-12-02T16:39:31.000Z | 2021-05-25T01:54:43.000Z | lesson17Thematic/src/main/java/org/walkgis/learngis/lesson17/basicclasses/GISThematic.java | polixiaohai/learn_gis | 293847056dc965d5063155a61d5971cb25ccb15d | [
"Apache-2.0"
] | null | null | null | lesson17Thematic/src/main/java/org/walkgis/learngis/lesson17/basicclasses/GISThematic.java | polixiaohai/learn_gis | 293847056dc965d5063155a61d5971cb25ccb15d | [
"Apache-2.0"
] | 3 | 2021-02-02T12:33:35.000Z | 2022-03-31T06:11:20.000Z | 34.034483 | 104 | 0.694022 | 3,397 | package org.walkgis.learngis.lesson17.basicclasses;
import java.awt.*;
public class GISThematic {
public Color outsideColor;
public int size;
public Color insideColor;
public GISThematic(Color outsideColor, int size, Color insideColor) {
update(outsideColor, size, insideColor);
}
public GISThematic(SHAPETYPE shapeType) {
if (shapeType == SHAPETYPE.point)
update(GISTools.getRandomColor(), GISConst.pointSize, GISTools.getRandomColor());
else if(shapeType==SHAPETYPE.polyline)
update(GISTools.getRandomColor(), GISConst.lineWidth, GISTools.getRandomColor());
else if (shapeType==SHAPETYPE.polygon)
update(GISTools.getRandomColor(), GISConst.polygonBoundaryWidth, GISTools.getRandomColor());
}
public void update(Color outsideColor, int size, Color insideColor) {
this.outsideColor = outsideColor;
this.size = size;
this.insideColor = insideColor;
}
}
|
3e080d1ae49f59831c724759e7a65944de73d841 | 704 | java | Java | src/pobj/expr/test/TestQ2.java | paulolvsq/Expr | a20f0bbb36f5ae26f095ea5165e8b84ea90cff1f | [
"Xnet",
"X11"
] | null | null | null | src/pobj/expr/test/TestQ2.java | paulolvsq/Expr | a20f0bbb36f5ae26f095ea5165e8b84ea90cff1f | [
"Xnet",
"X11"
] | null | null | null | src/pobj/expr/test/TestQ2.java | paulolvsq/Expr | a20f0bbb36f5ae26f095ea5165e8b84ea90cff1f | [
"Xnet",
"X11"
] | null | null | null | 18.526316 | 42 | 0.650568 | 3,398 | package pobj.expr.test;
import static org.junit.Assert.*;
import org.junit.Test;
import pobj.expr.Expression;
import pobj.expr.Var;
public class TestQ2 {
@Test
public void testVar() {
Var var = new Var("a");
Var var2 = new Var("a");
Var var3 = new Var("b");
// test definition equals
assertTrue(var2.equals( var) );
assertTrue(var2.equals( (Object) var) );
assertFalse(var3.equals( var) );
assertFalse(var3.equals( var2) );
assertEquals("a", var.getName() );
assertEquals("b", var3.getName() );
assertEquals("a", var.toString() );
assertEquals("a", var2.toString() );
assertEquals("b", var3.toString() );
assertTrue(var instanceof Expression);
}
}
|
3e080d36d858ee77eb8bdc547b8c1319c71a6599 | 2,793 | java | Java | store-implementation/accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/utils/IteratorOptionsBuilder.java | j8934893/Gaffer | ba5bfb336a5ca5761c7707a8e6944805fa6442ce | [
"Apache-2.0"
] | 587 | 2016-10-01T17:08:29.000Z | 2022-03-29T16:44:45.000Z | store-implementation/accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/utils/IteratorOptionsBuilder.java | j8934893/Gaffer | ba5bfb336a5ca5761c7707a8e6944805fa6442ce | [
"Apache-2.0"
] | 2,049 | 2016-09-28T06:42:21.000Z | 2022-03-30T17:20:03.000Z | store-implementation/accumulo-store/src/main/java/uk/gov/gchq/gaffer/accumulostore/utils/IteratorOptionsBuilder.java | j8934893/Gaffer | ba5bfb336a5ca5761c7707a8e6944805fa6442ce | [
"Apache-2.0"
] | 183 | 2016-09-29T20:27:08.000Z | 2022-03-24T18:47:16.000Z | 36.272727 | 155 | 0.746151 | 3,399 | /*
* Copyright 2016-2020 Crown Copyright
*
* 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 uk.gov.gchq.gaffer.accumulostore.utils;
import org.apache.accumulo.core.iterators.OptionDescriber.IteratorOptions;
import java.util.HashMap;
import java.util.Map;
public class IteratorOptionsBuilder {
private static final String VIEW_DESCRIPTION = "Required: The json serialised form of a view";
private static final String SCHEMA_DESCRIPTION = "Required: The json serialised form of the schema";
private static final String ACCUMULO_ELEMENT_CONVERTER_CLASS_DESCRIPTION = "Required: The element converter class to be used for key/value conversion";
private IteratorOptions options;
private Map<String, String> namedOptions = new HashMap<>();
public IteratorOptionsBuilder(final IteratorOptions options) {
this.options = options;
this.namedOptions = options.getNamedOptions();
}
public IteratorOptionsBuilder(final String name, final String description) {
this.options = new IteratorOptions(name, description, null, null);
}
public IteratorOptionsBuilder addNamedOption(final String optionName, final String optionDescription) {
namedOptions.put(optionName, optionDescription);
return this;
}
public IteratorOptionsBuilder addViewNamedOption() {
return addNamedOption(AccumuloStoreConstants.VIEW, VIEW_DESCRIPTION);
}
public IteratorOptionsBuilder addSchemaNamedOption() {
return addNamedOption(AccumuloStoreConstants.SCHEMA, SCHEMA_DESCRIPTION);
}
public IteratorOptionsBuilder addElementConverterClassNamedOption() {
return addNamedOption(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ACCUMULO_ELEMENT_CONVERTER_CLASS_DESCRIPTION);
}
public IteratorOptionsBuilder setIteratorName(final String iteratorName) {
options.setName(iteratorName);
return this;
}
public IteratorOptionsBuilder setIteratorDescription(final String iteratorDescription) {
options.setDescription(iteratorDescription);
return this;
}
public IteratorOptions build() {
if (!namedOptions.isEmpty()) {
options.setNamedOptions(namedOptions);
}
return options;
}
}
|
3e080e1b45a6bf85690673ff41b68db81bf1fc40 | 7,678 | java | Java | src/test/java/com/endava/cats/args/FilterArgumentsTest.java | Endava/cats | 55b4d86621ac195f92461793aa6c00b6885a5904 | [
"Apache-2.0"
] | 558 | 2020-04-03T07:38:28.000Z | 2022-03-30T03:43:09.000Z | src/test/java/com/endava/cats/args/FilterArgumentsTest.java | Endava/cats | 55b4d86621ac195f92461793aa6c00b6885a5904 | [
"Apache-2.0"
] | 32 | 2020-04-17T15:26:36.000Z | 2022-03-31T12:14:30.000Z | src/test/java/com/endava/cats/args/FilterArgumentsTest.java | Endava/cats | 55b4d86621ac195f92461793aa6c00b6885a5904 | [
"Apache-2.0"
] | 33 | 2020-04-03T12:59:43.000Z | 2022-03-30T18:07:33.000Z | 47.104294 | 208 | 0.761136 | 3,400 | package com.endava.cats.args;
import com.endava.cats.http.HttpMethod;
import io.quarkus.test.junit.QuarkusTest;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.springframework.test.util.ReflectionTestUtils;
import javax.inject.Inject;
import java.util.Collections;
import java.util.List;
@QuarkusTest
class FilterArgumentsTest {
@Inject
FilterArguments filterArguments;
IgnoreArguments ignoreArguments;
CheckArguments checkArguments;
ProcessingArguments processingArguments;
@BeforeEach
void setup() {
checkArguments = new CheckArguments();
ignoreArguments = new IgnoreArguments();
processingArguments = new ProcessingArguments();
ReflectionTestUtils.setField(filterArguments, "checkArguments", checkArguments);
ReflectionTestUtils.setField(filterArguments, "ignoreArguments", ignoreArguments);
ReflectionTestUtils.setField(filterArguments, "processingArguments", processingArguments);
ReflectionTestUtils.setField(filterArguments, "skipFuzzers", Collections.emptyList());
ReflectionTestUtils.setField(filterArguments, "suppliedFuzzers", Collections.emptyList());
FilterArguments.ALL_CATS_FUZZERS.clear();
FilterArguments.FUZZERS_TO_BE_RUN.clear();
}
@ParameterizedTest
@CsvSource({"checkHeaders,CheckSecurityHeadersFuzzer,RemoveFieldsFuzzer",
"checkFields,RemoveFieldsFuzzer,CheckSecurityHeadersFuzzer",
"checkHttp,HappyFuzzer,CheckSecurityHeadersFuzzer",
"checkContract,TopLevelElementsContractInfoFuzzer,CheckSecurityHeadersFuzzer"})
void shouldReturnCheckHeadersFuzzers(String argument, String matching, String notMatching) {
ReflectionTestUtils.setField(checkArguments, argument, true);
ReflectionTestUtils.setField(filterArguments, "skipFuzzersForPaths", Collections.emptyList());
List<String> fuzzers = filterArguments.getFuzzersForPath();
Assertions.assertThat(fuzzers).contains(matching).doesNotContain(notMatching);
}
@ParameterizedTest
@CsvSource({"includeControlChars,LeadingControlCharsInHeadersFuzzer,LeadingWhitespacesInHeadersFuzzer",
"includeEmojis,LeadingMultiCodePointEmojisInFieldsTrimValidateFuzzer,LeadingControlCharsInHeadersFuzzer",
"includeWhitespaces,LeadingWhitespacesInFieldsTrimValidateFuzzer,LeadingControlCharsInHeadersFuzzer"})
void shouldIncludeLengthyFuzzers(String argument, String matching, String notMatching) {
ReflectionTestUtils.setField(filterArguments, "skipFuzzersForPaths", Collections.emptyList());
ReflectionTestUtils.setField(checkArguments, argument, true);
List<String> fuzzers = filterArguments.getFuzzersForPath();
Assertions.assertThat(fuzzers).contains(matching).doesNotContain(notMatching);
}
@Test
void shouldIncludeAllFuzzers() {
ReflectionTestUtils.setField(filterArguments, "skipFuzzersForPaths", Collections.emptyList());
ReflectionTestUtils.setField(checkArguments, "includeControlChars", true);
ReflectionTestUtils.setField(checkArguments, "includeEmojis", true);
ReflectionTestUtils.setField(checkArguments, "includeWhitespaces", true);
List<String> fuzzers = filterArguments.getFuzzersForPath();
Assertions.assertThat(fuzzers).contains("LeadingControlCharsInHeadersFuzzer", "LeadingWhitespacesInHeadersFuzzer", "LeadingMultiCodePointEmojisInFieldsTrimValidateFuzzer"
, "RemoveFieldsFuzzer", "CheckSecurityHeadersFuzzer").hasSize(84);
}
@Test
void shouldReturnAllFuzzersWhenNoCheckSupplied() {
ReflectionTestUtils.setField(filterArguments, "skipFuzzersForPaths", Collections.emptyList());
List<String> fuzzers = filterArguments.getFuzzersForPath();
Assertions.assertThat(fuzzers).contains("TopLevelElementsContractInfoFuzzer", "CheckSecurityHeadersFuzzer", "HappyFuzzer", "RemoveFieldsFuzzer");
}
@Test
void shouldNotReturnContractFuzzersWhenIgnoredSupplied() {
ReflectionTestUtils.setField(filterArguments, "skipFuzzersForPaths", Collections.emptyList());
ReflectionTestUtils.setField(ignoreArguments, "ignoreResponseCodes", List.of("2xx"));
List<String> fuzzers = filterArguments.getFuzzersForPath();
Assertions.assertThat(fuzzers).contains("CheckSecurityHeadersFuzzer", "HappyFuzzer", "RemoveFieldsFuzzer")
.doesNotContain("TopLevelElementsContractInfoFuzzer");
}
@Test
void shouldNotReturnContractFuzzersWhenBlackbox() {
ReflectionTestUtils.setField(filterArguments, "skipFuzzersForPaths", Collections.emptyList());
ReflectionTestUtils.setField(ignoreArguments, "blackbox", true);
List<String> fuzzers = filterArguments.getFuzzersForPath();
Assertions.assertThat(fuzzers).contains("CheckSecurityHeadersFuzzer", "HappyFuzzer", "RemoveFieldsFuzzer")
.doesNotContain("TopLevelElementsContractInfoFuzzer");
}
@Test
void shouldRemoveSkippedFuzzers() {
ReflectionTestUtils.setField(filterArguments, "skipFuzzers", List.of("VeryLarge", "SecurityHeaders", "Jumbo"));
List<String> fuzzers = filterArguments.getFuzzersForPath();
Assertions.assertThat(fuzzers).contains("TopLevelElementsContractInfoFuzzer", "HappyFuzzer", "RemoveFieldsFuzzer")
.doesNotContain("CheckSecurityHeadersFuzzer", "VeryLargeValuesInFieldsFuzzer", "Jumbo");
}
@Test
void shouldOnlyIncludeSuppliedFuzzers() {
ReflectionTestUtils.setField(filterArguments, "suppliedFuzzers", List.of("VeryLarge", "SecurityHeaders", "Jumbo"));
List<String> fuzzers = filterArguments.getFuzzersForPath();
Assertions.assertThat(fuzzers).doesNotContain("TopLevelElementsContractInfoFuzzer", "HappyFuzzer", "RemoveFieldsFuzzer", "Jumbo")
.containsOnly("CheckSecurityHeadersFuzzer", "VeryLargeValuesInFieldsFuzzer", "VeryLargeUnicodeValuesInFieldsFuzzer", "VeryLargeUnicodeValuesInHeadersFuzzer", "VeryLargeValuesInHeadersFuzzer");
}
@Test
void shouldReturnAllHttpMethodsWhenNotHttpMethodSupplied() {
List<HttpMethod> httpMethods = filterArguments.getHttpMethods();
Assertions.assertThat(httpMethods).containsExactlyElementsOf(HttpMethod.restMethods());
}
@Test
void shouldReturnGetAndDeleteWhenNotHttpMethodSupplied() {
ReflectionTestUtils.setField(filterArguments, "httpMethods", List.of(HttpMethod.GET, HttpMethod.DELETE));
List<HttpMethod> httpMethods = filterArguments.getHttpMethods();
Assertions.assertThat(httpMethods).containsOnly(HttpMethod.GET, HttpMethod.DELETE);
}
@Test
void shouldReturnAllRegisteredFuzzers() {
Assertions.assertThat(filterArguments.getAllRegisteredFuzzers()).hasSize(84);
}
@Test
void shouldSetAllFuzzersToCustomFuzzer() {
ReflectionTestUtils.setField(filterArguments, "suppliedFuzzers", List.of("VeryLarge", "SecurityHeaders", "Jumbo"));
ReflectionTestUtils.setField(filterArguments, "suppliedFuzzers", List.of("VeryLarge", "SecurityHeaders", "Jumbo"));
Assertions.assertThat(filterArguments.getFuzzersForPath()).contains("VeryLargeUnicodeValuesInFieldsFuzzer");
FilterArguments.FUZZERS_TO_BE_RUN.clear();
filterArguments.customFilter("CustomFuzzer");
Assertions.assertThat(filterArguments.getFuzzersForPath()).doesNotContain("VeryLargeUnicodeValuesInFieldsFuzzer");
}
}
|
3e080e4a877b41c4708f8adad0dcd578a8334969 | 1,559 | java | Java | processing/src/main/java/io/druid/segment/incremental/TimeAndDimsHolder.java | acdn-ekeddy/druid | b9b3be6965f86aded444ae9a0a2ef47da9d10fac | [
"Apache-2.0"
] | 142 | 2015-01-03T14:03:14.000Z | 2022-03-07T18:17:13.000Z | processing/src/main/java/io/druid/segment/incremental/TimeAndDimsHolder.java | acdn-ekeddy/druid | b9b3be6965f86aded444ae9a0a2ef47da9d10fac | [
"Apache-2.0"
] | 17 | 2015-07-01T16:38:59.000Z | 2019-06-28T14:46:02.000Z | processing/src/main/java/io/druid/segment/incremental/TimeAndDimsHolder.java | acdn-ekeddy/druid | b9b3be6965f86aded444ae9a0a2ef47da9d10fac | [
"Apache-2.0"
] | 34 | 2015-01-11T06:55:07.000Z | 2021-06-10T03:54:27.000Z | 31.816327 | 118 | 0.739577 | 3,401 | /*
* Licensed to Metamarkets Group Inc. (Metamarkets) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Metamarkets licenses this file
* to you 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 io.druid.segment.incremental;
/**
* This interface is the core "pointer" interface that is used to create {@link io.druid.segment.ColumnValueSelector}s
* over incremental index. It's counterpart for historical segments is {@link io.druid.segment.data.Offset}.
*/
public class TimeAndDimsHolder
{
IncrementalIndex.TimeAndDims currEntry = null;
public IncrementalIndex.TimeAndDims get()
{
return currEntry;
}
public void set(IncrementalIndex.TimeAndDims currEntry)
{
this.currEntry = currEntry;
}
/**
* This method doesn't have well-defined semantics ("value" of what?), should be removed in favor of chaining
* get().getRowIndex().
*/
public int getValue()
{
return currEntry.getRowIndex();
}
}
|
3e080e5cd9eefc09702b2822c0aeb83f2d419d5b | 2,688 | java | Java | java/palitsa/lib/H2/main/org/h2/index/NonUniqueHashIndex.java | exhu/Palitsa | c3b555e408bc82a590b6d1f23f2ffbd809350546 | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2018-08-09T03:30:46.000Z | 2018-08-09T03:30:46.000Z | java/palitsa/lib/H2/main/org/h2/index/NonUniqueHashIndex.java | exhu/Palitsa | c3b555e408bc82a590b6d1f23f2ffbd809350546 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | java/palitsa/lib/H2/main/org/h2/index/NonUniqueHashIndex.java | exhu/Palitsa | c3b555e408bc82a590b6d1f23f2ffbd809350546 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | 28 | 121 | 0.605655 | 3,402 | /*
* Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.index;
import java.util.ArrayList;
import org.h2.engine.Session;
import org.h2.message.DbException;
import org.h2.result.Row;
import org.h2.result.SearchRow;
import org.h2.table.IndexColumn;
import org.h2.table.RegularTable;
import org.h2.util.New;
import org.h2.util.ValueHashMap;
import org.h2.value.Value;
/**
* A non-unique index based on an in-memory hash map.
*
* @author Sergi Vladykin
*/
public class NonUniqueHashIndex extends HashIndex {
private ValueHashMap<ArrayList<Long>> rows;
private RegularTable tableData;
private long rowCount;
public NonUniqueHashIndex(RegularTable table, int id, String indexName, IndexColumn[] columns, IndexType indexType) {
super(table, id, indexName, columns, indexType);
this.tableData = table;
reset();
}
private void reset() {
rows = ValueHashMap.newInstance();
rowCount = 0;
}
public void truncate(Session session) {
reset();
}
public void add(Session session, Row row) {
Value key = row.getValue(indexColumn);
ArrayList<Long> positions = rows.get(key);
if (positions == null) {
positions = New.arrayList();
rows.put(key, positions);
}
positions.add(row.getKey());
rowCount++;
}
public void remove(Session session, Row row) {
if (rowCount == 1) {
// last row in table
reset();
} else {
Value key = row.getValue(indexColumn);
ArrayList<Long> positions = rows.get(key);
if (positions.size() == 1) {
// last row with such key
rows.remove(key);
} else {
positions.remove(row.getKey());
}
rowCount--;
}
}
public Cursor find(Session session, SearchRow first, SearchRow last) {
if (first == null || last == null) {
throw DbException.throwInternalError();
}
if (first != last) {
if (compareKeys(first, last) != 0) {
throw DbException.throwInternalError();
}
}
ArrayList<Long> positions = rows.get(first.getValue(indexColumn));
return new NonUniqueHashCursor(session, tableData, positions);
}
public long getRowCount(Session session) {
return rowCount;
}
public long getRowCountApproximation() {
return rowCount;
}
}
|
3e080e6fe63ebbf149aba1f986bf03fdf1d25e1d | 356 | java | Java | src/main/java/com/cursospringavanzado/springbusiness/bfpostprocessors/BFPostProcessorAppConfig.java | idiazt/SpringBeanDeclarationExample | 12e6b4290e8710ec5f10e37c7fd4a098559b3b70 | [
"MIT"
] | null | null | null | src/main/java/com/cursospringavanzado/springbusiness/bfpostprocessors/BFPostProcessorAppConfig.java | idiazt/SpringBeanDeclarationExample | 12e6b4290e8710ec5f10e37c7fd4a098559b3b70 | [
"MIT"
] | null | null | null | src/main/java/com/cursospringavanzado/springbusiness/bfpostprocessors/BFPostProcessorAppConfig.java | idiazt/SpringBeanDeclarationExample | 12e6b4290e8710ec5f10e37c7fd4a098559b3b70 | [
"MIT"
] | null | null | null | 27.384615 | 64 | 0.811798 | 3,403 | package com.cursospringavanzado.springbusiness.bfpostprocessors;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class BFPostProcessorAppConfig {
@Bean
MailConfigFactoryPostProcessor mailConfig() {
return new MailConfigFactoryPostProcessor();
}
}
|
3e08104a09daa2d13dcaebf03fda102b315f3858 | 1,462 | java | Java | src/test/java/io/fabric8/elasticsearch/plugin/acl/BaseRolesSyncStrategyTest.java | rohankumardubey/openshift-elasticsearch-plugin | 2d17bafd8a79fc4d4611d12801b88e7d7146a1fd | [
"Apache-2.0"
] | 31 | 2016-02-15T14:58:32.000Z | 2022-01-01T06:36:54.000Z | src/test/java/io/fabric8/elasticsearch/plugin/acl/BaseRolesSyncStrategyTest.java | rohankumardubey/openshift-elasticsearch-plugin | 2d17bafd8a79fc4d4611d12801b88e7d7146a1fd | [
"Apache-2.0"
] | 174 | 2015-09-28T17:04:28.000Z | 2020-12-23T12:55:35.000Z | src/test/java/io/fabric8/elasticsearch/plugin/acl/BaseRolesSyncStrategyTest.java | rohankumardubey/openshift-elasticsearch-plugin | 2d17bafd8a79fc4d4611d12801b88e7d7146a1fd | [
"Apache-2.0"
] | 23 | 2015-09-28T16:46:43.000Z | 2021-11-30T08:21:44.000Z | 33.860465 | 112 | 0.73489 | 3,404 | /**
* Copyright (C) 2015 Red Hat, Inc.
*
* 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 io.fabric8.elasticsearch.plugin.acl;
import static io.fabric8.elasticsearch.plugin.acl.BaseRolesSyncStrategy.formatUserRoleName;
import static org.junit.Assert.assertEquals;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;
public class BaseRolesSyncStrategyTest {
@Test
public void testFormatUserNameRoleFromEmail() {
assertEquals("gen_user_" + DigestUtils.sha1Hex("kenaa@example.com"), formatUserRoleName("kenaa@example.com"));
}
@Test
public void testFormatUserNameRoleThatHasSlash() {
assertEquals("gen_user_" + DigestUtils.sha1Hex("test\\\\user"), formatUserRoleName("test\\\\user"));
}
@Test
public void testFormatUserNameRoleThatHasForwardSlash() {
assertEquals("gen_user_" + DigestUtils.sha1Hex("test/user"), formatUserRoleName("test/user"));
}
}
|
3e0810c804c074355147575f121c05c1f07ead8d | 8,578 | java | Java | src/util/MathUtils.java | wlin12/JNN | 96676a1d01064fa3473007af757739d7a7c5aace | [
"Apache-2.0"
] | 102 | 2015-08-14T08:15:26.000Z | 2021-09-26T20:37:07.000Z | src/util/MathUtils.java | wlin12/JNN | 96676a1d01064fa3473007af757739d7a7c5aace | [
"Apache-2.0"
] | 1 | 2017-06-14T11:40:56.000Z | 2017-06-14T12:38:14.000Z | src/util/MathUtils.java | wlin12/JNN | 96676a1d01064fa3473007af757739d7a7c5aace | [
"Apache-2.0"
] | 36 | 2015-08-20T02:07:10.000Z | 2020-05-03T17:14:13.000Z | 22.874667 | 163 | 0.620075 | 3,405 | package util;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Set;
import org.nd4j.linalg.api.ndarray.INDArray;
public class MathUtils {
public static double[] normVector(double[] vector) {
double[] norm = new double[vector.length];
double len = 0;
for(int j = 0; j < vector.length; j++){
len += vector[j] * vector[j];
}
len = Math.sqrt(len);
for(int j = 0; j < vector.length; j++){
norm[j] = vector[j]/len;
}
return norm;
}
public static double[] normVectorTo1(double[] vector) {
double[] norm = new double[vector.length];
double len = 0;
for(int j = 0; j < vector.length; j++){
len += vector[j];
}
for(int j = 0; j < vector.length; j++){
norm[j] = vector[j]/len;
}
return norm;
}
public static int maxIndex(double[] vector) {
int maxIndex = 0;
for(int i = 1; i < vector.length; i++){
if (vector[i] > vector[maxIndex]){
maxIndex = i;
}
}
return maxIndex;
}
public static int maxIndex(int[] vector) {
int maxIndex = 0;
for(int i = 1; i < vector.length; i++){
if (vector[i] > vector[maxIndex]){
maxIndex = i;
}
}
return maxIndex;
}
public static int maxIndex(int[] vector, int start, int end) {
int maxIndex = start;
for(int i = start+1; i <= end; i++){
if (vector[i] > vector[maxIndex]){
maxIndex = i;
}
}
return maxIndex;
}
public static int max(int[] vector){
return vector[maxIndex(vector)];
}
public static int max(int[] vector, int start, int end){
return vector[maxIndex(vector,start,end)];
}
public static int minIndex(int[] vector) {
int maxIndex = 0;
for(int i = 1; i < vector.length; i++){
if (vector[i] < vector[maxIndex]){
maxIndex = i;
}
}
return maxIndex;
}
public static int minIndex(int[] vector, int start, int end) {
int maxIndex = start;
for(int i = start+1; i <= end; i++){
if (vector[i] < vector[maxIndex]){
maxIndex = i;
}
}
return maxIndex;
}
public static int min(int[] vector){
return vector[minIndex(vector)];
}
public static int min(int[] vector, int start, int end){
return vector[minIndex(vector,start,end)];
}
public static int maxIndex(double[] vector, int start, int end) {
int maxIndex = start;
for(int i = start+1; i <= end; i++){
if (vector[i] > vector[maxIndex]){
maxIndex = i;
}
}
return maxIndex;
}
public static double max(double[] vector){
return vector[maxIndex(vector)];
}
public static double max(double[] vector, int start, int end){
return vector[maxIndex(vector,start,end)];
}
public static double arraySum(double[] vector) {
double ret = 0;
for(double d : vector){
ret+=d;
}
return ret;
}
public static int sum(int[] vector){
int ret = 0;
for(int d : vector){
ret+=d;
}
return ret;
}
public static double arraySumAbs(double[] vector) {
double ret = 0;
for(double d : vector){
ret+=Math.abs(d);
}
return ret;
}
public static void copyArray(double[] from, int fromStart, int fromEnd,
double[] to, int offset) {
for(int i = 0; i <= fromEnd - fromStart; i++){
to[i + offset] = from[i + fromStart];
}
}
public static double[] addVectors(double[] a, double[] b) {
double[] ret = new double[a.length];
for(int i = 0; i < a.length; i++){
ret[i] = a[i] + b[i];
}
return ret;
}
public static double[] subVectors(double[] a, double[] b) {
double[] ret = new double[a.length];
for(int i = 0; i < a.length; i++){
ret[i] = a[i] - b[i];
}
return ret;
}
public static void addVectors(double[] a, double[] b, double[] out) {
if(a==null){
throw new RuntimeException("a is null");
}
if(b==null){
throw new RuntimeException("b is null");
}
if(out==null){
throw new RuntimeException("out is null");
}
for(int i = 0; i < a.length; i++){
out[i] = a[i] + b[i];
}
}
public static void subVectors(double[] a, double[] b, double[] out) {
for(int i = 0; i < a.length; i++){
out[i] = a[i] - b[i];
}
}
public static int drawFromCategorical(double[] categoricalDist) {
double[] normalized = normVectorTo1(categoricalDist);
double rand = Math.random();
double sum = 0;
for(int i = 0; i < normalized.length - 1; i++){
sum += normalized[i];
if(rand < sum){
return i;
}
}
return normalized.length - 1;
}
public static String drawFromCategorical(HashMap<String, Double> categoricalDist) {
double rand = Math.random();
double sum = 0;
String last = "";
for(Entry<String, Double> entry : categoricalDist.entrySet()){
sum += entry.getValue();
if(rand < sum){
return entry.getKey();
}
last = entry.getKey();
}
return last;
}
public static String drawFromUniform(Set<String> outputs) {
double rand = Math.random();
double sum = 0;
double val = 1.0/outputs.size();
String last = "";
for(String key : outputs){
sum += val;
if(rand < sum){
return key;
}
last = key;
}
return last;
}
public static double sum(double[] ds) {
double sum = 0;
for(double d:ds){
sum+=d;
}
return sum;
}
public static double sumSquared(double[] ds) {
double sum = 0;
for(double d:ds){
sum+=d*d;
}
return Math.sqrt(sum);
}
public static void zero(double[] output, int start, int end) {
for(int i = start; i <= end;i++ ){
output[i] = 0;
}
}
public static double[] scale(double[] subVectors, double alpha) {
double[] ret = new double[subVectors.length];
for(int i = 0; i < ret.length; i++){
ret[i] = subVectors[i]*alpha;
}
return ret;
}
public static double[] concatVectors(LinkedList<double[]> vectors) {
int size = 0;
for(double[] vector : vectors){
size+=vector.length;
}
double[] ret = new double[size];
concatVectors(vectors, ret);
return ret;
}
public static double[] concatVectors(LinkedList<double[]> vectors, double[] ret) {
int i = 0;
for(double[] vector : vectors){
for(double d : vector){
ret[i++] = d;
}
}
return ret;
}
public static double[] collapse(double[][] map) {
double[] ret = new double[map.length * map[0].length];
for(int i = 0; i < map.length; i++){
for(int j = 0; j < map[0].length; j++){
ret[i*map[0].length + j] = map[i][j];
}
}
return ret;
}
public static double[] collapse(LinkedList<double[]> previousInput) {
double[] ret = new double[previousInput.size() * previousInput.getFirst().length];
for(int i = 0; i < previousInput.size(); i++){
for(int j = 0; j < previousInput.getFirst().length; j++){
ret[i*previousInput.getFirst().length + j] = previousInput.get(i)[j];
}
}
return ret;
}
public static double[][] arrayToMatrix(double[] vector, int col){
if(vector.length % col != 0){
throw new RuntimeException("incorrect vector size");
}
int dimY = vector.length / col;
double[][] matrix = new double[col][dimY];
for(int i = 0; i < col; i++){
for(int j = 0; j < dimY; j++){
matrix[i][j] = vector[i*dimY+j];
}
}
return matrix;
}
public static double getLearningRate(double initAlpha, double finalAlpha, double currentIteration, double currentSample, double lastIteration, double lastSample){
double progression = (currentIteration*lastSample+currentSample)/(lastIteration*lastSample);
return initAlpha - (initAlpha - finalAlpha)*progression;
}
public static void checkArraySize(double[] input, int dim){
if(input.length != dim){
throw new RuntimeException("incorrect input dim size: input = " + input.length + " expected = " + dim);
}
}
public static int minIndex(Iterator<Entry<Integer, Double>> iterator) {
double minVal = Double.MAX_VALUE;
int minIndex = -1;
while(iterator.hasNext()){
Entry<Integer, Double> next = iterator.next();
if(next.getValue()<minVal){
minIndex = next.getKey();
minVal = next.getValue();
}
}
return minIndex;
}
public static int maxIndex(INDArray outputs) {
double minVal = -Double.MAX_VALUE;
int minIndex = -1;
for(int i = 0; i < outputs.columns(); i++){
double val = outputs.getDouble(i);
if(minVal<val){
minIndex = i;
minVal = val;
}
}
return minIndex;
}
public static double max(INDArray outputs) {
return outputs.getDouble(maxIndex(outputs));
}
public static void cap(INDArray outputs, double max){
INDArray linear = outputs.linearView();
for(int i = 0; i < linear.size(0); i++){
double val = linear.getDouble(i);
if(val > max){
linear.putScalar(i, max);
continue;
}
if(val < -max){
linear.putScalar(i, -max);
}
}
}
}
|
3e0810e02a9a2dc00115a5ba15d756661901ead0 | 1,122 | java | Java | src/main/java/com/leetcode/sync/SyncTest.java | caozhen1937/beautyCode | 1bf64d15a59afb42a6fad45cced0ea5b23efb69e | [
"Apache-2.0"
] | null | null | null | src/main/java/com/leetcode/sync/SyncTest.java | caozhen1937/beautyCode | 1bf64d15a59afb42a6fad45cced0ea5b23efb69e | [
"Apache-2.0"
] | null | null | null | src/main/java/com/leetcode/sync/SyncTest.java | caozhen1937/beautyCode | 1bf64d15a59afb42a6fad45cced0ea5b23efb69e | [
"Apache-2.0"
] | null | null | null | 21.576923 | 72 | 0.548128 | 3,406 | package com.leetcode.sync;
/**
* Created by caozhen on 2020/12/3
*/
public class SyncTest implements Runnable {
private static int count;
private static int count1;
private static int count2;
// 对象锁
public synchronized void add() {
count++;
}
// 类锁(对类加锁有两种方式,这是第一种,修饰静态方法)
public synchronized static void add1() {
count1++;
}
// 类锁(对类加锁有两种方式,这是第二种,修饰代码块,以类.class为锁)
public void add2() {
synchronized (SyncTest.class) {
count2++;
}
}
@Override
public void run() {
for (int i = 0; i < 100000; i++) {
add();
add1();
add2();
}
}
public static void main(String[] args) throws InterruptedException {
Thread thread1 = new Thread(new SyncTest());
Thread thread2 = new Thread(new SyncTest());
thread1.start();
thread2.start();
thread1.join();
thread2.join();
System.out.println("count: " + count);
System.out.println("count1: " + count1);
System.out.println("count2: " + count2);
}
}
|
3e0810f24c9dfc944277f6e3f69f82b64ae5b6ab | 1,276 | java | Java | src/main/java/io/github/bhuwanupadhyay/eg1/sale/application/SaleService.java | BhuwanUpadhyay/eg-1-hibernate-session-filters-with-spring-data-and-aop | 4eff03c349c39f817a9a19b883f3c2cf8d70f27e | [
"Apache-2.0"
] | 2 | 2021-09-11T16:26:10.000Z | 2022-01-30T19:55:06.000Z | src/main/java/io/github/bhuwanupadhyay/eg1/sale/application/SaleService.java | bhuwanupadhyay/hibernate-session-filters-with-spring-data-and-aop | 4eff03c349c39f817a9a19b883f3c2cf8d70f27e | [
"Apache-2.0"
] | null | null | null | src/main/java/io/github/bhuwanupadhyay/eg1/sale/application/SaleService.java | bhuwanupadhyay/hibernate-session-filters-with-spring-data-and-aop | 4eff03c349c39f817a9a19b883f3c2cf8d70f27e | [
"Apache-2.0"
] | null | null | null | 27.148936 | 94 | 0.775078 | 3,407 | package io.github.bhuwanupadhyay.eg1.sale.application;
import io.github.bhuwanupadhyay.eg1.core.LoggedInUser;
import io.github.bhuwanupadhyay.eg1.sale.domain.Sale;
import io.github.bhuwanupadhyay.eg1.sale.domain.Sale.Status;
import io.github.bhuwanupadhyay.eg1.sale.domain.SaleRepository;
import org.springframework.stereotype.Service;
@Service
public class SaleService {
private final SaleRepository repository;
private final LoggedInUser loggedInUser;
public SaleService(SaleRepository repository, LoggedInUser loggedInUser) {
this.repository = repository;
this.loggedInUser = loggedInUser;
}
public Sale placeOrder(String itemId, Integer quantity) {
Sale sale = new Sale();
sale.setItemId(itemId);
sale.setQuantity(quantity);
sale.setStatus(Status.INITIAL);
sale.setCreatedBy(loggedInUser.userId());
return repository.save(sale);
}
public void cancelOrder(Long id) {
Sale sale = findByIdOrFail(id);
sale.setStatus(Status.CANCELLED);
repository.save(sale);
}
public void deliverOrder(Long id) {
Sale sale = findByIdOrFail(id);
sale.setStatus(Status.DELIVERED);
repository.save(sale);
}
private Sale findByIdOrFail(Long id) {
return repository.findOne(id).orElseThrow(() -> new IllegalArgumentException("not fount!"));
}
}
|
3e081185bbf9b7b54eec3d2c8caad65d6494fa20 | 860 | java | Java | order-server01/src/main/java/com/mujio/orderserver/entity/Order.java | Mujio-killer/mall | 63684a96a9a814ac10b12c13371b6c331c5afc85 | [
"MIT"
] | 3 | 2020-03-21T09:31:53.000Z | 2020-04-25T04:03:57.000Z | order-server01/src/main/java/com/mujio/orderserver/entity/Order.java | Mujio-killer/mall | 63684a96a9a814ac10b12c13371b6c331c5afc85 | [
"MIT"
] | null | null | null | order-server01/src/main/java/com/mujio/orderserver/entity/Order.java | Mujio-killer/mall | 63684a96a9a814ac10b12c13371b6c331c5afc85 | [
"MIT"
] | null | null | null | 18.297872 | 53 | 0.554651 | 3,408 | package com.mujio.orderserver.entity;
import java.util.Date;
import java.util.List;
public class Order {
private int id;
private List<Goods> goodsList;
private Date createdate;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<Goods> getGoodsList() {
return goodsList;
}
public void setGoodsList(List<Goods> goodsList) {
this.goodsList = goodsList;
}
public Date getCreatedate() {
return createdate;
}
public void setCreatedate(Date createdate) {
this.createdate = createdate;
}
@Override
public String toString() {
return "Order{" +
"id=" + id +
", goodsList=" + goodsList +
", createdate=" + createdate +
'}';
}
}
|
3e0813352f4dcc947e124397b97ce595d045fbbe | 2,560 | java | Java | app/src/main/java/com/example/xzh/hmanagerclient/general/base/BaseActivity.java | xzh1223/HManager | 158ec9e3487436d89abec0441fb5be467a51fdd7 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/example/xzh/hmanagerclient/general/base/BaseActivity.java | xzh1223/HManager | 158ec9e3487436d89abec0441fb5be467a51fdd7 | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/example/xzh/hmanagerclient/general/base/BaseActivity.java | xzh1223/HManager | 158ec9e3487436d89abec0441fb5be467a51fdd7 | [
"Apache-2.0"
] | null | null | null | 24.854369 | 78 | 0.622266 | 3,409 | package com.example.xzh.hmanagerclient.general.base;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.example.xzh.hmanagerclient.R;
import com.example.xzh.hmanagerclient.general.bean.User;
import static com.example.xzh.hmanagerclient.general.utils.Constants.ACCOUNT;
import static com.example.xzh.hmanagerclient.general.utils.Constants.ID;
/**
* Created by xzh on 2017/10/28.
* <p>
* activity 基类
*/
public abstract class BaseActivity extends AppCompatActivity {
public final String TAG = "HManager";
public SharedPreferences prefs;
public Context mContext;
// 初始化布局文件
public abstract int initLayout();
// 初始化控件
public abstract void initView();
// 设置事件
protected abstract void initEvent();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
prefs = PreferenceManager.getDefaultSharedPreferences(this);
setContentView(initLayout());
initView();
initEvent();
}
/**
* 跳转页面
*
* @param c 转向的页面
*/
public void toActivity(Class<?> c) {
Intent intent = new Intent(this, c);
startActivity(intent);
finish();
}
/**
* 保存用户信息
*/
public void saveUser(User user) {
SharedPreferences.Editor editor = prefs.edit();
editor.putString(ACCOUNT, user.getAccount());
editor.putInt(ID, user.getId());
editor.apply();
}
/**
* 自定义toolbar
*/
public void initToolBar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//隐藏默认标题
getSupportActionBar().setDisplayShowTitleEnabled(false);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
/**
* 设置返回按钮
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return true;
}
}
|
3e08144fb5d527194240c598ffc0024b2e5c2fc1 | 10,707 | java | Java | src/main/java/org/apache/datasketches/hll/ToByteArrayImpl.java | kfaraz/datasketches-java | 95a712ae62142b8bfba4e5f541c1d35e54dd6f30 | [
"Apache-2.0"
] | 625 | 2015-08-06T16:24:11.000Z | 2019-05-17T10:07:43.000Z | src/main/java/org/apache/datasketches/hll/ToByteArrayImpl.java | kfaraz/datasketches-java | 95a712ae62142b8bfba4e5f541c1d35e54dd6f30 | [
"Apache-2.0"
] | 206 | 2015-08-12T01:39:07.000Z | 2019-04-10T01:36:07.000Z | src/main/java/org/apache/datasketches/hll/ToByteArrayImpl.java | kfaraz/datasketches-java | 95a712ae62142b8bfba4e5f541c1d35e54dd6f30 | [
"Apache-2.0"
] | 171 | 2015-08-06T16:24:15.000Z | 2019-05-14T18:21:13.000Z | 42.153543 | 99 | 0.699075 | 3,410 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.datasketches.hll;
import static org.apache.datasketches.hll.AbstractCoupons.find;
import static org.apache.datasketches.hll.HllUtil.LG_AUX_ARR_INTS;
import static org.apache.datasketches.hll.PreambleUtil.AUX_COUNT_INT;
import static org.apache.datasketches.hll.PreambleUtil.HLL_BYTE_ARR_START;
import static org.apache.datasketches.hll.PreambleUtil.insertAuxCount;
import static org.apache.datasketches.hll.PreambleUtil.insertCompactFlag;
import static org.apache.datasketches.hll.PreambleUtil.insertCurMin;
import static org.apache.datasketches.hll.PreambleUtil.insertCurMode;
import static org.apache.datasketches.hll.PreambleUtil.insertEmptyFlag;
import static org.apache.datasketches.hll.PreambleUtil.insertFamilyId;
import static org.apache.datasketches.hll.PreambleUtil.insertHashSetCount;
import static org.apache.datasketches.hll.PreambleUtil.insertHipAccum;
import static org.apache.datasketches.hll.PreambleUtil.insertInt;
import static org.apache.datasketches.hll.PreambleUtil.insertKxQ0;
import static org.apache.datasketches.hll.PreambleUtil.insertKxQ1;
import static org.apache.datasketches.hll.PreambleUtil.insertLgArr;
import static org.apache.datasketches.hll.PreambleUtil.insertLgK;
import static org.apache.datasketches.hll.PreambleUtil.insertListCount;
import static org.apache.datasketches.hll.PreambleUtil.insertNumAtCurMin;
import static org.apache.datasketches.hll.PreambleUtil.insertOooFlag;
import static org.apache.datasketches.hll.PreambleUtil.insertPreInts;
import static org.apache.datasketches.hll.PreambleUtil.insertRebuildCurMinNumKxQFlag;
import static org.apache.datasketches.hll.PreambleUtil.insertSerVer;
import static org.apache.datasketches.hll.PreambleUtil.insertTgtHllType;
import org.apache.datasketches.SketchesStateException;
import org.apache.datasketches.memory.Memory;
import org.apache.datasketches.memory.WritableMemory;
/**
* @author Lee Rhodes
*/
class ToByteArrayImpl {
// To byte array used by the heap HLL modes.
static final byte[] toHllByteArray(final AbstractHllArray impl, final boolean compact) {
int auxBytes = 0;
if (impl.tgtHllType == TgtHllType.HLL_4) {
final AuxHashMap auxHashMap = impl.getAuxHashMap();
if (auxHashMap != null) {
auxBytes = (compact)
? auxHashMap.getCompactSizeBytes()
: auxHashMap.getUpdatableSizeBytes();
} else {
auxBytes = (compact) ? 0 : 4 << LG_AUX_ARR_INTS[impl.lgConfigK];
}
}
final int totBytes = HLL_BYTE_ARR_START + impl.getHllByteArrBytes() + auxBytes;
final byte[] byteArr = new byte[totBytes];
final WritableMemory wmem = WritableMemory.writableWrap(byteArr);
insertHll(impl, wmem, compact);
return byteArr;
}
private static final void insertHll(final AbstractHllArray impl, final WritableMemory wmem,
final boolean compact) {
insertCommonHll(impl, wmem, compact);
final byte[] hllByteArr = ((HllArray)impl).hllByteArr;
wmem.putByteArray(HLL_BYTE_ARR_START, hllByteArr, 0, hllByteArr.length);
if (impl.getAuxHashMap() != null) {
insertAux(impl, wmem, compact);
} else {
wmem.putInt(AUX_COUNT_INT, 0);
}
}
private static final void insertCommonHll(final AbstractHllArray srcImpl,
final WritableMemory tgtWmem, final boolean compact) {
insertPreInts(tgtWmem, srcImpl.getPreInts());
insertSerVer(tgtWmem);
insertFamilyId(tgtWmem);
insertLgK(tgtWmem, srcImpl.getLgConfigK());
insertEmptyFlag(tgtWmem, srcImpl.isEmpty());
insertCompactFlag(tgtWmem, compact);
insertOooFlag(tgtWmem, srcImpl.isOutOfOrder());
insertCurMin(tgtWmem, srcImpl.getCurMin());
insertCurMode(tgtWmem, srcImpl.getCurMode());
insertTgtHllType(tgtWmem, srcImpl.getTgtHllType());
insertHipAccum(tgtWmem, srcImpl.getHipAccum());
insertKxQ0(tgtWmem, srcImpl.getKxQ0());
insertKxQ1(tgtWmem, srcImpl.getKxQ1());
insertNumAtCurMin(tgtWmem, srcImpl.getNumAtCurMin());
insertRebuildCurMinNumKxQFlag(tgtWmem, srcImpl.isRebuildCurMinNumKxQFlag());
}
private static final void insertAux(final AbstractHllArray srcImpl, final WritableMemory tgtWmem,
final boolean tgtCompact) {
final AuxHashMap auxHashMap = srcImpl.getAuxHashMap();
final int auxCount = auxHashMap.getAuxCount();
insertAuxCount(tgtWmem, auxCount);
insertLgArr(tgtWmem, auxHashMap.getLgAuxArrInts()); //only used for direct HLL
final long auxStart = srcImpl.auxStart;
if (tgtCompact) {
final PairIterator itr = auxHashMap.getIterator();
int cnt = 0;
while (itr.nextValid()) { //works whether src has compact memory or not
insertInt(tgtWmem, auxStart + (cnt++ << 2), itr.getPair());
}
assert cnt == auxCount;
} else { //updatable
final int auxInts = 1 << auxHashMap.getLgAuxArrInts();
final int[] auxArr = auxHashMap.getAuxIntArr();
tgtWmem.putIntArray(auxStart, auxArr, 0, auxInts);
}
}
//To byte array for coupons
static final byte[] toCouponByteArray(final AbstractCoupons impl, final boolean dstCompact) {
final int srcCouponCount = impl.getCouponCount();
final int srcLgCouponArrInts = impl.getLgCouponArrInts();
final int srcCouponArrInts = 1 << srcLgCouponArrInts;
final byte[] byteArrOut;
final boolean list = impl.getCurMode() == CurMode.LIST;
//prepare switch
final int sw = (impl.isMemory() ? 0 : 4) | (impl.isCompact() ? 0 : 2) | (dstCompact ? 0 : 1);
switch (sw) {
case 0: { //Src Memory, Src Compact, Dst Compact
final Memory srcMem = impl.getMemory();
final int bytesOut = impl.getMemDataStart() + (srcCouponCount << 2);
byteArrOut = new byte[bytesOut];
srcMem.getByteArray(0, byteArrOut, 0, bytesOut);
break;
}
case 1: { //Src Memory, Src Compact, Dst Updatable
final int dataStart = impl.getMemDataStart();
final int bytesOut = dataStart + (srcCouponArrInts << 2);
byteArrOut = new byte[bytesOut];
final WritableMemory memOut = WritableMemory.writableWrap(byteArrOut);
copyCommonListAndSet(impl, memOut);
insertCompactFlag(memOut, dstCompact);
final int[] tgtCouponIntArr = new int[srcCouponArrInts];
final PairIterator itr = impl.iterator();
while (itr.nextValid()) {
final int pair = itr.getPair();
final int idx = find(tgtCouponIntArr, srcLgCouponArrInts, pair);
if (idx < 0) { //found EMPTY
tgtCouponIntArr[~idx] = pair; //insert
continue;
}
throw new SketchesStateException("Error: found duplicate.");
}
memOut.putIntArray(dataStart, tgtCouponIntArr, 0, srcCouponArrInts);
if (list) {
insertListCount(memOut, srcCouponCount);
} else {
insertHashSetCount(memOut, srcCouponCount);
}
break;
}
case 2: { //Src Memory, Src Updatable, Dst Compact
final int dataStart = impl.getMemDataStart();
final int bytesOut = dataStart + (srcCouponCount << 2);
byteArrOut = new byte[bytesOut];
final WritableMemory memOut = WritableMemory.writableWrap(byteArrOut);
copyCommonListAndSet(impl, memOut);
insertCompactFlag(memOut, dstCompact);
final PairIterator itr = impl.iterator();
int cnt = 0;
while (itr.nextValid()) {
insertInt(memOut, dataStart + (cnt++ << 2), itr.getPair());
}
if (list) {
insertListCount(memOut, srcCouponCount);
} else {
insertHashSetCount(memOut, srcCouponCount);
}
break;
}
case 3: { //Src Memory, Src Updatable, Dst Updatable
final Memory srcMem = impl.getMemory();
final int bytesOut = impl.getMemDataStart() + (srcCouponArrInts << 2);
byteArrOut = new byte[bytesOut];
srcMem.getByteArray(0, byteArrOut, 0, bytesOut);
break;
}
case 6: { //Src Heap, Src Updatable, Dst Compact
final int dataStart = impl.getMemDataStart();
final int bytesOut = dataStart + (srcCouponCount << 2);
byteArrOut = new byte[bytesOut];
final WritableMemory memOut = WritableMemory.writableWrap(byteArrOut);
copyCommonListAndSet(impl, memOut);
insertCompactFlag(memOut, dstCompact);
final PairIterator itr = impl.iterator();
int cnt = 0;
while (itr.nextValid()) {
insertInt(memOut, dataStart + (cnt++ << 2), itr.getPair());
}
if (list) {
insertListCount(memOut, srcCouponCount);
} else {
insertHashSetCount(memOut, srcCouponCount);
}
break;
}
case 7: { //Src Heap, Src Updatable, Dst Updatable
final int dataStart = impl.getMemDataStart();
final int bytesOut = dataStart + (srcCouponArrInts << 2);
byteArrOut = new byte[bytesOut];
final WritableMemory memOut = WritableMemory.writableWrap(byteArrOut);
copyCommonListAndSet(impl, memOut);
memOut.putIntArray(dataStart, impl.getCouponIntArr(), 0, srcCouponArrInts);
if (list) {
insertListCount(memOut, srcCouponCount);
} else {
insertHashSetCount(memOut, srcCouponCount);
}
break;
}
default: throw new SketchesStateException("Corruption, should not happen: " + sw);
}
return byteArrOut;
}
private static final void copyCommonListAndSet(final AbstractCoupons impl,
final WritableMemory wmem) {
insertPreInts(wmem, impl.getPreInts());
insertSerVer(wmem);
insertFamilyId(wmem);
insertLgK(wmem, impl.getLgConfigK());
insertLgArr(wmem, impl.getLgCouponArrInts());
insertEmptyFlag(wmem, impl.isEmpty());
insertOooFlag(wmem, impl.isOutOfOrder());
insertCurMode(wmem, impl.getCurMode());
insertTgtHllType(wmem, impl.getTgtHllType());
}
}
|
3e081489fee656c4514113c23357dd6ff99ad189 | 68 | java | Java | blockcv-client/src/main/java/com/blockcv/events/ChangedUserEvent.java | mustafahafidi/BlockCV | fe5030ec822ac1fddabfd0b5ac0367495951b55f | [
"Apache-2.0"
] | null | null | null | blockcv-client/src/main/java/com/blockcv/events/ChangedUserEvent.java | mustafahafidi/BlockCV | fe5030ec822ac1fddabfd0b5ac0367495951b55f | [
"Apache-2.0"
] | 3 | 2020-07-19T11:33:59.000Z | 2021-05-11T02:31:03.000Z | blockcv-client/src/main/java/com/blockcv/events/ChangedUserEvent.java | mustafahafidi/BlockCV | fe5030ec822ac1fddabfd0b5ac0367495951b55f | [
"Apache-2.0"
] | 1 | 2020-08-03T10:48:38.000Z | 2020-08-03T10:48:38.000Z | 11.333333 | 35 | 0.794118 | 3,411 | package com.blockcv.events;
public interface ChangedUserEvent {
}
|
3e0815f29c2bbffe77b039fbfc3623f3ee613ece | 2,748 | java | Java | src/main/java/com/mantledillusion/vaadin/cotton/component/EntityBuilder.java | MantledIllusion/cotton-flow | 335960d8fa409d11216d911bae809ea88e89adb6 | [
"Apache-2.0"
] | null | null | null | src/main/java/com/mantledillusion/vaadin/cotton/component/EntityBuilder.java | MantledIllusion/cotton-flow | 335960d8fa409d11216d911bae809ea88e89adb6 | [
"Apache-2.0"
] | 1 | 2021-05-14T15:34:35.000Z | 2021-05-14T15:34:35.000Z | src/main/java/com/mantledillusion/vaadin/cotton/component/EntityBuilder.java | MantledIllusion/cotton-flow | 335960d8fa409d11216d911bae809ea88e89adb6 | [
"Apache-2.0"
] | null | null | null | 33.512195 | 113 | 0.678311 | 3,412 | package com.mantledillusion.vaadin.cotton.component;
import com.vaadin.flow.component.Component;
import java.util.List;
/**
* Interface for {@link Component} builders.
*
* @param <C>
* The {@link Component} type this builder builds. Not an extension
* of {@link Component} on purpose, since Vaadin handles shared
* {@link Component} behavior using interfaces that are not
* necessarily bound to {@link Component}s.
* @param <B>
* The final implementation type of this {@link EntityBuilder}.
* Necessary to allow builder methods of non-final implementations to
* return the builder instance in the correct type.
*/
public interface EntityBuilder<C, B extends EntityBuilder<C, B>> {
/**
* Returns whether there is a value of the given type contained in the currently running configuration context.
*
* @param <V> The type of the value.
* @param valueType The class of the value's type; might be null.
* @return True if the configuration context contains a value of the type, false otherwise
*/
<V> boolean contains(Class<V> valueType);
/**
* Retrieves the set value of the given type.
*
* @param <V> The type of the value.
* @param valueType The class of the value's type; might be null.
* @return The set value, might be null if explicitly set to null for the type
*/
<V> V get(Class<V> valueType);
/**
* Sets the value for the given value type.
*
* @param <V> The retrieval type of the value.
* @param <VC> The concrete type of the value.
* @param valueType The value type to set a value for; might be null.
* @param value The value to set; might be null.
*/
<V, VC extends V> void set(Class<V> valueType, VC value);
/**
* Adds a new {@link Configurer} to this builder.
*
* @param configurer A new {@link Configurer} to execute when the builder is executed.
* @return this
*/
default B configure(Configurer<C> configurer) {
return configure(configurer, false);
}
/**
* Adds a new {@link Configurer} to this builder.
*
* @param configurer A new {@link Configurer} to execute when the builder is executed; might <b>not</b> be null.
* @param prepend Whether or not to prepend the configurer, so it gets executed before all others.
* @return this
*/
B configure(Configurer<C> configurer, boolean prepend);
/**
* Returns the {@link Configurer}s currently contained by this {@link EntityBuilder}.
*
* @return The current {@link Configurer} list, never null
*/
List<Configurer<C>> getConfigurers();
/**
* Returns <code>this</code> in the type of this {@link Object}'s final {@link EntityBuilder} implementation.
*
* @return <code>this</code>
*/
B getThis();
} |
3e08177c1ab67781788707d0511f586acbe1e694 | 3,078 | java | Java | src/main/java/com/khipu/api/client/PaymentMethodsApi.java | khipu/khipu-api-java-client | f522d89570706447c379ae165a04769c3c1c40da | [
"Apache-2.0"
] | 2 | 2015-12-07T18:10:31.000Z | 2016-03-08T18:03:42.000Z | src/main/java/com/khipu/api/client/PaymentMethodsApi.java | khipu/khipu-api-java-client | f522d89570706447c379ae165a04769c3c1c40da | [
"Apache-2.0"
] | 6 | 2019-11-13T03:28:59.000Z | 2021-12-09T20:04:38.000Z | src/main/java/com/khipu/api/client/PaymentMethodsApi.java | khipu/khipu-api-java-client | f522d89570706447c379ae165a04769c3c1c40da | [
"Apache-2.0"
] | 2 | 2019-01-29T16:49:27.000Z | 2019-02-01T06:45:42.000Z | 26.765217 | 137 | 0.699155 | 3,413 | package com.khipu.api.client;
import com.khipu.ApiException;
import com.khipu.ApiClient;
import com.khipu.Configuration;
import com.khipu.Pair;
import com.khipu.TypeRef;
import com.khipu.api.model.ServiceError;
import com.khipu.api.model.ValidationError;
import com.khipu.api.model.PaymentMethodsResponse;
import com.khipu.api.model.AuthorizationError;
import java.util.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen")
public class PaymentMethodsApi {
private ApiClient apiClient;
public PaymentMethodsApi() {
this(Configuration.getDefaultApiClient());
}
public PaymentMethodsApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Obtener listado de medios de pago disponible para una cuenta de cobrador
* Obtiene el listado de medios de pago que pueden usarse para pagar a esta cuenta de cobro.
* @param id Identificador del merchant
* @param options Mapa de par��metros opcionales
* @return PaymentMethodsResponse
*/
public PaymentMethodsResponse merchantsIdPaymentMethodsGet (String id, Map<String, Object> options) throws ApiException {
Object postBody = null;
// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException(400, "Missing the required parameter 'id' when calling merchantsIdPaymentMethodsGet");
}
// create path and map variables
String path = "/merchants/{id}/paymentMethods".replaceAll("\\{format\\}","json")
.replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));
// query params
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
if(options != null) {
}
if(options != null) {
}
if(options != null) {
}
final String[] accepts = {
"application/json"
};
final String accept = apiClient.selectHeaderAccept(accepts);
final String[] contentTypes = {
"application/x-www-form-urlencoded"
};
final String contentType = apiClient.selectHeaderContentType(contentTypes);
String[] authNames = new String[] { "khipu" };
TypeRef returnType = new TypeRef<PaymentMethodsResponse>() {};
return apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
/**
* Obtener listado de medios de pago disponible para una cuenta de cobrador
* Obtiene el listado de medios de pago que pueden usarse para pagar a esta cuenta de cobro.
* @param id Identificador del merchant
* @return PaymentMethodsResponse
*/
public PaymentMethodsResponse merchantsIdPaymentMethodsGet (String id) throws ApiException {
return merchantsIdPaymentMethodsGet(id, null);
}
}
|
3e08180892b750887db3ec1f9788880c9f9ebd22 | 1,921 | java | Java | cardstack/src/main/java/com/daprlabs/cardstack/SwipeRelativeLayout.java | aaronbond/Swipe-Deck | edf3eab374ec3c29c59c69737e97de0ae3abe44a | [
"MIT"
] | 874 | 2015-12-27T22:03:30.000Z | 2022-03-25T12:07:01.000Z | cardstack/src/main/java/com/daprlabs/cardstack/SwipeRelativeLayout.java | FranAguilera/Swipe-Deck | edf3eab374ec3c29c59c69737e97de0ae3abe44a | [
"MIT"
] | 75 | 2016-01-07T10:32:47.000Z | 2018-08-03T11:04:23.000Z | cardstack/src/main/java/com/daprlabs/cardstack/SwipeRelativeLayout.java | FranAguilera/Swipe-Deck | edf3eab374ec3c29c59c69737e97de0ae3abe44a | [
"MIT"
] | 199 | 2015-12-28T12:20:13.000Z | 2021-04-23T18:08:36.000Z | 29.106061 | 104 | 0.643935 | 3,414 | package com.daprlabs.cardstack;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import java.util.ArrayList;
/**
* Created by aaron on 23/12/2015.
*/
public class SwipeRelativeLayout extends RelativeLayout {
public SwipeRelativeLayout(Context context) {
super(context);
setClipChildren(false);
}
public SwipeRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
setClipChildren(false);
}
public SwipeRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setClipChildren(false);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public SwipeRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setClipChildren(false);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
int childCount = getChildCount();
ViewGroup.LayoutParams params = getLayoutParams();
ArrayList<View> children = new ArrayList<>();
View swipeDeck = null;
for(int i=0; i< childCount; ++i){
View child = getChildAt(i);
if(child instanceof SwipeDeck){
swipeDeck = getChildAt(i);
}else{
children.add(child);
}
}
removeAllViews();
removeAllViewsInLayout();
for(View v : children){
addViewInLayout(v, -1, v.getLayoutParams(), true);
}
if(swipeDeck != null){
addViewInLayout(swipeDeck, -1, swipeDeck.getLayoutParams(), true);
}
invalidate();
requestLayout();
}
}
|
3e08197920e92f90e2d29cff6e7bf42a79b46058 | 1,679 | java | Java | flow-samples/src/main/java/de/javagl/flow/samples/gui02/FlowGui_02_CustomVisualization.java | javagl/Flow | ea45b05e4ecf1d5bc15202ae856e8d812cb7a4b5 | [
"MIT"
] | 3 | 2019-03-22T10:22:31.000Z | 2021-02-26T06:38:54.000Z | flow-samples/src/main/java/de/javagl/flow/samples/gui02/FlowGui_02_CustomVisualization.java | javagl/Flow | ea45b05e4ecf1d5bc15202ae856e8d812cb7a4b5 | [
"MIT"
] | 2 | 2017-05-30T16:24:05.000Z | 2017-05-30T16:30:54.000Z | flow-samples/src/main/java/de/javagl/flow/samples/gui02/FlowGui_02_CustomVisualization.java | javagl/Flow | ea45b05e4ecf1d5bc15202ae856e8d812cb7a4b5 | [
"MIT"
] | 1 | 2017-07-10T11:07:32.000Z | 2017-07-10T11:07:32.000Z | 32.288462 | 75 | 0.709351 | 3,415 | package de.javagl.flow.samples.gui02;
import javax.swing.SwingUtilities;
import de.javagl.category.Categories;
import de.javagl.category.CategoriesBuilder;
import de.javagl.category.Category;
import de.javagl.flow.Flow;
import de.javagl.flow.gui.FlowEditorApplication;
import de.javagl.flow.module.creation.ModuleCreator;
import de.javagl.flow.module.creation.ModuleCreators;
import de.javagl.flow.plugin.ModuleCreatorServices;
import de.javagl.flow.samples.SampleFunctions;
import de.javagl.flow.samples.Utils;
/**
* An example showing how to create an instance of the visual-interactive
* {@link Flow} editing application, with a certain set of
* {@link ModuleCreator} instances, one containing a custom
* visualization.
*/
@SuppressWarnings("javadoc")
public class FlowGui_02_CustomVisualization
{
public static void main(String[] args)
{
Utils.defaultInitialization();
SwingUtilities.invokeLater(() -> createAndShowGui());
}
private static Category<ModuleCreator> createModuleCreators()
{
CategoriesBuilder<ModuleCreator> categoriesBuilder =
Categories.createBuilder("All modules");
ModuleCreatorServices.initialize(categoriesBuilder);
categoriesBuilder.add(ModuleCreators.createForMethod(
"Create random integers",
SampleFunctions.class, "createRandomIntegers"));
categoriesBuilder.add(new BarChartModuleCreator());
return categoriesBuilder.get();
}
public static void createAndShowGui()
{
new FlowEditorApplication(createModuleCreators());
}
}
|
3e081a07b20e9436eca1c9bfb0fc76ebaa68a681 | 288 | java | Java | src/main/java/io/github/cr3ahal0/hadl/m2/response/ResponseCode.java | Cr3aHal0/HADL | 1c171ec4cdae5ba4034e3a429e4b4df50a7b44b5 | [
"Apache-2.0"
] | null | null | null | src/main/java/io/github/cr3ahal0/hadl/m2/response/ResponseCode.java | Cr3aHal0/HADL | 1c171ec4cdae5ba4034e3a429e4b4df50a7b44b5 | [
"Apache-2.0"
] | null | null | null | src/main/java/io/github/cr3ahal0/hadl/m2/response/ResponseCode.java | Cr3aHal0/HADL | 1c171ec4cdae5ba4034e3a429e4b4df50a7b44b5 | [
"Apache-2.0"
] | null | null | null | 16 | 44 | 0.604167 | 3,416 | package io.github.cr3ahal0.hadl.m2.response;
/**
* Created by Maxime on 04/12/2015.
*/
public enum ResponseCode {
OK("200"),
BAD_REQUEST("400"),
UNAUTHORIZED("401"),
FORBIDDEN("403");
String code;
ResponseCode(String code) {
this.code = code;
}
}
|
3e081a0b91976374235c5dfe517d870229affd3d | 770 | java | Java | src/main/java/uk/oczadly/karl/jnano/rpc/request/node/RequestWorkPeersClear.java | koczadly/jNano | 0e0c75f395843e5d22c3a80bf554d435cad47ae3 | [
"MIT"
] | 25 | 2018-05-22T01:15:47.000Z | 2022-02-01T11:27:24.000Z | src/main/java/uk/oczadly/karl/jnano/rpc/request/node/RequestWorkPeersClear.java | koczadly/jNano | 0e0c75f395843e5d22c3a80bf554d435cad47ae3 | [
"MIT"
] | 13 | 2020-02-24T21:06:39.000Z | 2022-03-30T00:04:28.000Z | src/main/java/uk/oczadly/karl/jnano/rpc/request/node/RequestWorkPeersClear.java | koczadly/jNano | 0e0c75f395843e5d22c3a80bf554d435cad47ae3 | [
"MIT"
] | 6 | 2018-11-17T17:12:55.000Z | 2022-03-29T18:22:29.000Z | 32 | 110 | 0.74349 | 3,417 | /*
* Copyright (c) 2020 Karl Oczadly (lyhxr@example.com)
* Licensed under the MIT License
*/
package uk.oczadly.karl.jnano.rpc.request.node;
import uk.oczadly.karl.jnano.rpc.request.RpcRequest;
import uk.oczadly.karl.jnano.rpc.response.ResponseSuccessful;
/**
* This request class is used to remove all the configured work peers from the node.
* <br>Calls the RPC command {@code work_peers_clear}, and returns a {@link ResponseSuccessful} data object.
*
* @see <a href="https://docs.nano.org/commands/rpc-protocol/#work_peers_clear">Official RPC documentation</a>
*/
public class RequestWorkPeersClear extends RpcRequest<ResponseSuccessful> {
public RequestWorkPeersClear() {
super("work_peers_clear", ResponseSuccessful.class);
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.