下面列出了javax.servlet.http.HttpServletRequestWrapper#java.util.LinkedList 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Parses the given log file and returns a list of records contained in it.
*
* @param inputFile The file to be parsed.
* @return A list of records contained in the file.
* @throws FileNotFoundException If the given file was not found.
* @throws IOException If there was a problem reading the file.
*/
public static List<StatisticsRecord> parseLog(File inputFile)
throws FileNotFoundException, IOException {
requireNonNull(inputFile, "inputFile");
List<StatisticsRecord> result = new LinkedList<>();
try (BufferedReader inputReader = new BufferedReader(
new InputStreamReader(new FileInputStream(inputFile), Charset.forName("UTF-8")))) {
String inputLine = inputReader.readLine();
while (inputLine != null) {
StatisticsRecord record = StatisticsRecord.parseRecord(inputLine);
if (record != null) {
result.add(record);
}
inputLine = inputReader.readLine();
}
}
catch (IOException exc) {
LOG.warn("Exception parsing input file", exc);
throw exc;
}
return result;
}
private List<Device> getDetailedDevices() {
List<Device> deviceList = new LinkedList<Device>();
JsonObject result = connMan.getDigitalSTROMAPI().query2(connMan.getSessionToken(), GET_DETAILD_DEVICES);
if (result != null && result.isJsonObject()) {
if (result.getAsJsonObject().get(GeneralLibConstance.QUERY_BROADCAST_ZONE_STRING).isJsonObject()) {
result = result.getAsJsonObject().get(GeneralLibConstance.QUERY_BROADCAST_ZONE_STRING)
.getAsJsonObject();
for (Entry<String, JsonElement> entry : result.entrySet()) {
if (!(entry.getKey().equals(JSONApiResponseKeysEnum.ZONE_ID.getKey())
&& entry.getKey().equals(JSONApiResponseKeysEnum.NAME.getKey()))
&& entry.getValue().isJsonObject()) {
deviceList.add(new DeviceImpl(entry.getValue().getAsJsonObject()));
}
}
}
}
return deviceList;
}
/**
* Return a NetworkConfiguration instance.
*/
public static NetworkConfiguration probe() throws IOException {
Map<NetworkInterface, List<Inet4Address>> ip4Interfaces = new HashMap<>();
Map<NetworkInterface, List<Inet6Address>> ip6Interfaces = new HashMap<>();
List<NetworkInterface> nifs = list(getNetworkInterfaces());
for (NetworkInterface nif : nifs) {
// ignore interfaces that are down
if (!nif.isUp() || nif.isPointToPoint())
continue;
List<Inet4Address> ip4Addresses = new LinkedList<>();
List<Inet6Address> ip6Addresses = new LinkedList<>();
ip4Interfaces.put(nif, ip4Addresses);
ip6Interfaces.put(nif, ip6Addresses);
for (InetAddress addr : list(nif.getInetAddresses())) {
if (addr instanceof Inet4Address)
ip4Addresses.add((Inet4Address)addr);
else if (addr instanceof Inet6Address)
ip6Addresses.add((Inet6Address)addr);
}
}
return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
}
public MessageRecord getCurrent() {
return new SmsMessageRecord(id,
message.getMessageBody(),
message.getRecipient(),
message.getRecipient(),
1,
System.currentTimeMillis(),
System.currentTimeMillis(),
-1,
0,
message.isSecureMessage() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(),
threadId,
0,
new LinkedList<>(),
message.getSubscriptionId(),
message.getExpiresIn(),
System.currentTimeMillis(),
0,
false,
Collections.emptyList(),
false);
}
public LinkedList<Rule> generateRules(int ruleGenerationMode, Attribute label) {
LinkedList<Rule> rules = new LinkedList<>();
switch (ruleGenerationMode) {
case POSITIVE_RULE:
rules.add(getPositiveRule(label));
break;
case NEGATIVE_RULE:
rules.add(getNegativeRule(label));
break;
case PREDICTION_RULE:
rules.add(getPredictionRule(label));
break;
case POSITIVE_AND_NEGATIVE_RULES:
rules.add(getPositiveRule(label));
rules.add(getNegativeRule(label));
break;
}
return rules;
}
/**
* Writes a warning to {@code System.err} that a variant type is
* unsupported by HPSF. Such a warning is written only once for each variant
* type. Log messages can be turned on or off by
*
* @param ex The exception to log
*/
protected static void writeUnsupportedTypeMessage
(final UnsupportedVariantTypeException ex) {
if (isLogUnsupportedTypes())
{
if (unsupportedMessage == null) {
unsupportedMessage = new LinkedList<Long>();
}
Long vt = Long.valueOf(ex.getVariantType());
if (!unsupportedMessage.contains(vt))
{
logger.log( POILogger.ERROR, ex.getMessage());
unsupportedMessage.add(vt);
}
}
}
/**
* 完成用户推荐
* @return
*/
public List<UserRecommendDO> generateUsers(){
List<UserRecommendDO> recommendUsers = new LinkedList<>();
log.info("生成一次 推荐用户数据");
//List<UserDO> users = userRepository.findAll();
//for (int i = 0; i < users.size(); i++) {
// UserDO userDO = users.get(i);
// String username = userDO.getUsername();
// List<BlogVO> blogVOS = userBlogCacheService.getUserBlogs(username);
// for (int j = 0; j <blogVOS.size() ; j++) {
// Long id = blogVOS.get(i).getId();
// BlogRecommendDO blogRecommendDO = blogRecommendRepository.findOne(id);
// Double blogRate = blogRecommendDO.getRecommendRate();
// }
//}
return recommendUsers;
}
/**
* Undo/Remove entries upto and including the supplied entry from the history stack.
* This can be done if the current authenticator decides it is FALLBACK.
*
* @return The last undone history element. Null if there is no matching entry.
*/
public AuthHistory undoUpto(AuthHistory historyElement) {
LinkedList<AuthHistory> modifyingHistory = new LinkedList<>();
AuthHistory matchedEntry = null;
for (AuthHistory historyEntry : authenticationStepHistory) {
if (historyEntry.equals(historyElement)) {
matchedEntry = historyEntry;
break;
}
modifyingHistory.add(historyEntry);
}
if (matchedEntry != null) {
authenticationStepHistory = modifyingHistory;
}
return matchedEntry;
}
public static int[] hashInt(int start,int end){
LinkedList<Integer> ll = new LinkedList<>();
ArrayList<Integer> al = new ArrayList<>();
for(int i=start;i<=end;i++){
ll.add(i);
}
int start0=0;
for(int end0=end-start;end0>start0;end0--){
int rnd = RandomNumberGenerator.GenerateIntBetween(start0, end0);
int value = ll.get(rnd);
ll.remove(rnd);
al.add(value);
}
al.add(ll.get(0));
ll.remove(0);
return ArrayOperations.arrayListToIntVector(al);
}
/**
* @param args
*/
public static void main(String[] args) {
List<JedisShardInfo> list = new LinkedList<JedisShardInfo>();
JedisShardInfo jedisShardInfo1 = new JedisShardInfo(ip1, port);
jedisShardInfo1.setPassword(JedisConstant.password);
list.add(jedisShardInfo1);
JedisShardInfo jedisShardInfo2 = new JedisShardInfo(ip2, port);
jedisShardInfo2.setPassword(JedisConstant.password);
list.add(jedisShardInfo2);
ShardedJedisPool pool = new ShardedJedisPool(config, list);
for (int i = 0; i < 2000; i++) {
ShardedJedis jedis = pool.getResource();
String key = "howsun_" + i;
//jedis.set(key, UUID.randomUUID().toString());
System.out.println(key + "\t" + jedis.get(key) + "\t" + jedis.toString());
pool.returnResource(jedis);
}
}
private String getTagForMenu(MenuItem source) {
LinkedList<MenuItem> menuItems = new LinkedList<>();
while (source != null) {
menuItems.addFirst(source);
source = source.getParentMenu();
}
if (menuItems.getFirst() instanceof Menu) {
if (menuItems.size() >= 2) {
ownerNode = menuItems.get(1).getParentPopup().getOwnerNode();
return isMenuBar(ownerNode) ? "#menu" : "#contextmenu";
}
} else {
ownerNode = menuItems.getFirst().getParentPopup().getOwnerNode();
return "#contextmenu";
}
return null;
}
/**
* Constructor.
* @param kickstartFileContentsIn Contents of the kickstart file.
*/
public KickstartParser(String kickstartFileContentsIn) {
ksFileContents = kickstartFileContentsIn;
optionLines = new LinkedList<String>();
packageLines = new LinkedList<String>();
preScriptLines = new LinkedList<String>();
postScriptLines = new LinkedList<String>();
String [] ksFileLines = ksFileContents.split("\\n");
List<String> currentSectionLines = new LinkedList<String>();
for (int i = 0; i < ksFileLines.length; i++) {
String currentLine = ksFileLines[i];
if (isNewSection(currentLine)) {
storeSection(currentSectionLines);
currentSectionLines = new LinkedList<String>();
}
currentSectionLines.add(currentLine);
}
storeSection(currentSectionLines);
}
@Override
public void notifyWavelengthReservationWLAN(LinkedList<Object> sourceVertexList,LinkedList<Object> targetVertexList,LinkedList<Integer> wlans, boolean bidirectional)
{
TEDBlock.lock();
try {
for (int i=0;i<sourceVertexList.size();++i){
IntraDomainEdge edge=networkGraph.getEdge(sourceVertexList.get(i), targetVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wlans.get(i));
log.info("Reservo: "+sourceVertexList.get(i).toString() + "-"+ targetVertexList.get(i).toString() +" wavelength: "+wlans.get(i)+" bidirectional"+bidirectional);
if (bidirectional == true){
edge=networkGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
edge.getTE_info().setWavelengthReserved(wlans.get(i));
//log.info(""+edge.toString());
}
}
}finally{
TEDBlock.unlock();
}
for (int i=0;i<registeredAlgorithms.size();++i){
registeredAlgorithms.get(i).notifyWavelengthReservation(sourceVertexList, targetVertexList, wlans.get(i));
if (bidirectional == true){
registeredAlgorithms.get(i).notifyWavelengthReservation(targetVertexList, sourceVertexList, wlans.get(i));
}
}
}
private static Collection<String> collectAllInputTopics(SinkConfig sinkConfig) {
List<String> retval = new LinkedList<>();
if (sinkConfig.getInputs() != null) {
retval.addAll(sinkConfig.getInputs());
}
if (sinkConfig.getTopicToSerdeClassName() != null) {
retval.addAll(sinkConfig.getTopicToSerdeClassName().keySet());
}
if (sinkConfig.getTopicsPattern() != null) {
retval.add(sinkConfig.getTopicsPattern());
}
if (sinkConfig.getTopicToSchemaType() != null) {
retval.addAll(sinkConfig.getTopicToSchemaType().keySet());
}
if (sinkConfig.getInputSpecs() != null) {
retval.addAll(sinkConfig.getInputSpecs().keySet());
}
return retval;
}
@Test//a b c d e h m n p o i
public void exteriorBinaryTree3() throws Exception {
tree = BinaryTreeUtil.getFigureTenDotOne();
expected = new LinkedList<>(
Arrays.asList(
tree,
tree.left,
tree.left.left,
tree.left.left.left,
tree.left.left.right,
tree.left.right.right.left,
tree.right.left.right.left.right,
tree.right.left.right.right,
tree.right.right.right,
tree.right.right,
tree.right)
);
test(expected, tree);
}
@Messages("WARN_HasQueries=The selected configuration contains inspections that do not provide any transformations. " +
"No diff will be provided for code detected by such inspections. Use Source/Inspect... to perform code analysis.")
private List<MessageImpl> performSearchForPattern(final RefactoringElementsBag refactoringElements) {
ProgressHandleWrapper w = new ProgressHandleWrapper(this, 10, 90);
Iterable<? extends HintDescription> queries = filterQueries(refactoring.getPattern(), true);
BatchResult candidates = BatchSearch.findOccurrences(queries, refactoring.getScope(), w, /*XXX:*/HintsSettings.getGlobalSettings());
List<MessageImpl> problems = new LinkedList<MessageImpl>(candidates.problems);
if (queries.iterator().hasNext()) {
problems.add(new MessageImpl(MessageKind.WARNING, Bundle.WARN_HasQueries()));
}
prepareElements(candidates, w, refactoringElements, refactoring.isVerify(), problems);
w.finish();
return problems;
}
@Test
public void testCallTree() {
List<Map<String, Object>> list = new LinkedList<Map<String,Object>>();
CallTreeEntry entry1 = createCallTreeEntry(owner, true);
CallTreeEntry entry2 = createCallTreeEntry(person1, true);
CallTreeEntry entry3 = createCallTreeEntry(person2, true);
list.addAll(ImmutableList.<Map<String,Object>>of(entry1.toMap(), entry2.toMap(), entry3.toMap()));
replay();
//1. owner first and enabled
doSetAttributeForOkScenario(list, ImmutableList.<CallTreeEntry> of(entry1, entry2, entry3));
//2. owner 2nd and enabled, OK, should fail
Map<String, Object> removed = list.remove(0);
list.add(1, removed);
doSetAttributeForFailedScenario(list, "Should get an exception for account owner not first");
//3. owner first and disabled, fail
entry1.setEnabled(false);
removed = list.remove(1);
list.add(0, entry1.toMap());
doSetAttributeForFailedScenario(list, "Should get an exception for owner first and disabled");
}
@DataProvider(name="listProvider", parallel=true)
public static Object[][] listCases() {
final List<Object[]> cases = new LinkedList<>();
cases.add(new Object[] { Collections.emptyList() });
cases.add(new Object[] { new ArrayList<>() });
cases.add(new Object[] { new LinkedList<>() });
cases.add(new Object[] { new Vector<>() });
cases.add(new Object[] { new Stack<>() });
cases.add(new Object[] { new CopyOnWriteArrayList<>() });
cases.add(new Object[] { Arrays.asList() });
List<Integer> l = Arrays.asList(42);
cases.add(new Object[] { new ArrayList<>(l) });
cases.add(new Object[] { new LinkedList<>(l) });
cases.add(new Object[] { new Vector<>(l) });
Stack<Integer> s = new Stack<>(); s.addAll(l);
cases.add(new Object[]{s});
cases.add(new Object[] { new CopyOnWriteArrayList<>(l) });
cases.add(new Object[] { l });
return cases.toArray(new Object[0][cases.size()]);
}
@Override
protected List<Object> getValues(HubRegistration entity) {
List<Object> values = new LinkedList<Object>();
//Note this needs to be same order as defined in COLUMN_ORDER
values.add(entity.getLastConnected());
values.add(entity.getState()!=null?entity.getState().name():null);
values.add(entity.getUpgradeRequestTime());
values.add(entity.getFirmwareVersion());
values.add(entity.getTargetVersion());
values.add(entity.getUpgradeErrorCode());
values.add(entity.getUpgradeErrorMessage());
values.add(entity.getDownloadProgress());
values.add(entity.getUpgradeErrorTime());
log.trace("HubRegistration:Values = [{}]", values );
return values;
}
private static List<String> filterRoots (File[] roots) {
List<String> toInclude = new LinkedList<String>();
GitModuleConfig config = GitModuleConfig.getDefault();
for (File root : roots) {
String path = root.getAbsolutePath();
if (config.isExcludedFromCommit(path)) {
toInclude.add(path);
}
}
return toInclude;
}
@Override
public JPopupMenu getPopupMenu() {
JPopupMenu menu = new JPopupMenu();
List<JMenuItem> serverItems = new LinkedList<>();
// add server items
for (String serverName : remoteControllers.keySet()) {
ConfigurableController controller = remoteControllers.get(serverName);
// if the connection to the server is established
if (controller.getModel().getSource().isConnected()) {
JMenuItem newItem = new JMenuItem(I18N.getGUILabel("configurable_dialog.refresh_config.server.label",
serverName));
newItem.setActionCommand(serverName);
newItem.addActionListener(actionListener);
serverItems.add(newItem);
}
}
// add items to menu
if (serverItems.size() >= 2) {
// add the refresh all connections part only if there are at
// least
// two connected servers
menu.add(allConnectionsItem);
menu.addSeparator();
}
for (JMenuItem item : serverItems) {
menu.add(item);
}
return menu;
}
/** Create the compound stream in the specified file. The file name is the
* entire name (no extensions are added).
*/
public CompoundFileWriter(Directory dir, String name) {
if (dir == null)
throw new IllegalArgumentException("Missing directory");
if (name == null)
throw new IllegalArgumentException("Missing name");
directory = dir;
fileName = name;
ids = new HashSet();
entries = new LinkedList();
}
/**
* Returns the list of "getter" methods for the given class. The list
* is ordered so that isXXX methods appear before getXXX methods - this
* is for compatibility with the JavaBeans Introspector.
*/
static List<Method> getReadMethods(Class<?> clazz) {
// return cached result if available
List<Method> cachedResult = getCachedMethods(clazz);
if (cachedResult != null)
return cachedResult;
// get list of public methods, filtering out methods that have
// been overridden to return a more specific type.
List<Method> methods =
StandardMBeanIntrospector.getInstance().getMethods(clazz);
methods = MBeanAnalyzer.eliminateCovariantMethods(methods);
// filter out the non-getter methods
List<Method> result = new LinkedList<Method>();
for (Method m: methods) {
if (isReadMethod(m)) {
// favor isXXX over getXXX
if (m.getName().startsWith(IS_METHOD_PREFIX)) {
result.add(0, m);
} else {
result.add(m);
}
}
}
// add result to cache
cache.put(clazz, new SoftReference<List<Method>>(result));
return result;
}
@Test
public void createQueryStringOneParamForExsistingQueryString() throws JspException {
List<Param> params = new LinkedList<>();
Set<String> usedParams = new HashSet<>();
Param param = new Param();
param.setName("name");
param.setValue("value");
params.add(param);
String queryString = tag.createQueryString(params, usedParams, false);
assertEquals("&name=value", queryString);
}
private void broadcast(Object self, PacketOutExRunEvent packet) {
if (plugin.subdata != null) {
List<SubDataClient> clients = new LinkedList<SubDataClient>();
clients.addAll(plugin.subdata.getClients().values());
for (SubDataClient client : clients) {
if (client.getHandler() == null || client.getHandler() != self) { // Don't send events about yourself to yourself
if (client.getHandler() == null || client.getHandler().getSubData()[0] == client) { // Don't send events over subchannels
client.sendPacket(packet);
}
}
}
}
}
private Collection<ColumnMetaData> getEncryptColumnMetaDataList(final String tableName, final Collection<ColumnMetaData> originalColumnMetaDataList, final EncryptRule encryptRule) {
Collection<ColumnMetaData> result = new LinkedList<>();
Collection<String> derivedColumns = encryptRule.getAssistedQueryAndPlainColumns(tableName);
for (ColumnMetaData each : originalColumnMetaDataList) {
if (!derivedColumns.contains(each.getName())) {
result.add(getEncryptColumnMetaData(tableName, each, encryptRule));
}
}
return result;
}
@Test
public void testParseOptsNoThreads() {
Queue<String> opts = new LinkedList<>();
String cmdName = "sequentialWrite";
try {
PerformanceEvaluation.parseOpts(opts);
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
assertEquals("Command " + cmdName + " does not have threads number", e.getMessage());
assertTrue(e.getCause() instanceof NoSuchElementException);
}
}
public Node(OPERATOR operator, OperatorContext context)
{
this.operator = operator;
this.context = context;
executorService = Executors.newSingleThreadExecutor();
taskQueue = new LinkedList<>();
outputs = new HashMap<>();
descriptor = new PortMappingDescriptor();
Operators.describe(operator, descriptor);
endWindowDequeueTimes = new HashMap<>();
tmb = ManagementFactory.getThreadMXBean();
commandResponse = new LinkedBlockingQueue<>();
metricFields = Lists.newArrayList();
for (Field field : ReflectionUtils.getDeclaredFieldsIncludingInherited(operator.getClass())) {
if (field.isAnnotationPresent(AutoMetric.class)) {
metricFields.add(field);
field.setAccessible(true);
}
}
metricMethods = Maps.newHashMap();
try {
for (PropertyDescriptor pd : Introspector.getBeanInfo(operator.getClass()).getPropertyDescriptors()) {
Method readMethod = pd.getReadMethod();
if (readMethod != null) {
AutoMetric rfa = readMethod.getAnnotation(AutoMetric.class);
if (rfa != null) {
metricMethods.put(pd.getName(), readMethod);
}
}
}
} catch (IntrospectionException e) {
throw new RuntimeException("introspecting {}", e);
}
}
public Builder(URI serverUri) {
if (serverUri == null) {
throw new IllegalArgumentException("Connection URI may not be null");
}
this.serverUri = serverUri;
listeners = new LinkedList<>();
channels = new LinkedList<>();
final List<String> channelsFromUri = parseQueryString(serverUri.getRawQuery(), true).get("channel");
if (channelsFromUri != null) {
channels.addAll(channelsFromUri);
}
}
@Benchmark
public void testReusedLinked200K() {
LinkedList<SampleData> list = new LinkedList<SampleData>();
for (int times = 0; times < 1000; times++) {
for (int pos = 0; pos < 200000; pos++) {
list.add(new SampleData());
}
list.clear();
}
}