下面列出了java.util.LinkedList#set ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Add a Principal entry to an existing PolicyEntry at the specified index.
* A Principal entry consists of a class, and name.
*
* If the principal already exists, it is not added again.
*/
boolean addPrinEntry(PolicyEntry pe,
PolicyParser.PrincipalEntry newPrin,
int index) {
// first add the principal to the Policy Parser entry
PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
if (grantEntry.contains(newPrin) == true)
return false;
LinkedList<PolicyParser.PrincipalEntry> prinList =
grantEntry.principals;
if (index != -1)
prinList.set(index, newPrin);
else
prinList.add(newPrin);
modified = true;
return true;
}
/**
* Create a EML job in database
* @param bdaJobName
* @param bdaJobId
* @param graph
* @param account
* @param desc
* @return
* @throws Exception
*/
private BdaJob createBdaJob(String bdaJobName, String bdaJobId,
OozieGraph graph, String account, String desc) throws Exception {
if (bdaJobName == null)
bdaJobName = "Not Specified";
if (bdaJobId == null)
bdaJobId = GenerateSequenceUtil.generateSequenceNo() + "-bda";
// Create the corresponding bda job in the database
BdaJob job = new BdaJob();
job.setJobName(bdaJobName);
job.setJobId(bdaJobId);
job.setGraphxml(graph.toXML());
job.setAccount(account);
job.setDesc(desc);
job.setLastSubmitTime(TimeUtils.getTime());
//Modify the programs in the graph xml of the bda job to latest
OozieGraph tmpGraph = OozieGraphXMLParser.parse(graph.toXML());
LinkedList<OozieProgramNode> proNodes = tmpGraph.getProgramNodes();
for(int i=0 ; i < proNodes.size() ; i++)
{
OozieProgramNode proNode = proNodes.get(i);
proNode.setOozJobId("latest");
proNode.setWorkPath("${appPath}/" + proNode.getId() + "/");
proNodes.set(i, proNode );
}
job.setGraphxml(tmpGraph.toXML());
SecureDao.insert(job);
job.setOozieGraph(graph);
return job;
}
/**
* Update a EML job in the database
* @param bdaJobName
* @param bdaJobId
* @param graph
* @param account
* @param desc
* @return Bda job object
* @throws Exception
*/
private BdaJob updateBdaJob(String bdaJobName, String bdaJobId,
OozieGraph graph, String account, String desc) throws Exception {
if (bdaJobName == null)
bdaJobName = "Not Specified";
BdaJob job = new BdaJob();
job.setJobName(bdaJobName);
job.setJobId(bdaJobId);
job.setGraphxml(graph.toXML());
job.setAccount(account);
job.setDesc(desc);
job.setLastSubmitTime(TimeUtils.getTime());
String[] cond = {"job_id"};
String[] sets = {"job_name", "graphxml", "account", "description",
"last_submit_time"};
//Modify the programs in the graph xml of the bda job to latest
OozieGraph tmpGraph = OozieGraphXMLParser.parse(graph.toXML());
LinkedList<OozieProgramNode> proNodes = tmpGraph.getProgramNodes();
for(int i=0 ; i < proNodes.size() ; i++)
{
OozieProgramNode proNode = proNodes.get(i);
proNode.setOozJobId("latest");
proNodes.set(i, proNode );
}
job.setGraphxml(tmpGraph.toXML());
SecureDao.update(job, sets, cond);
job.setOozieGraph(graph);
return job;
}
private String transferThroughList(String in, int index) {
LinkedList<String> list = new LinkedList<String>();
list.add(System.getenv("")); // taints the list
list.clear(); // makes the list safe again
list.add(1, "xx");
list.addFirst(in); // can taint the list
list.addLast("yy");
list.push(in);
return list.element() + list.get(index) + list.getFirst() + list.getLast()
+ list.peek() + list.peekFirst() + list.peekLast() + list.poll()
+ list.pollFirst() + list.pollLast() + list.pop() + list.remove()
+ list.remove(index) + list.removeFirst() + list.removeLast()
+ list.set(index, "safe") + list.toString();
}
@Benchmark
public void linkedList() {
LinkedList<Object> list = new LinkedList<Object>(Collections.nCopies(20, PLACEHOLDER));
for (int i = 0; i < 100; i++) {
int oldSize = list.size();
if (i >= oldSize) {
int newSize = Math.max(oldSize * 2, i);
list.addAll(oldSize, Collections.nCopies(newSize - oldSize, PLACEHOLDER));
}
list.set(i, i);
}
}
public static Variable[] getVariablesFilteredExclusive(DataBean dataBean, Collection<String> columnsToRemove, boolean removeStart) {
LinkedList<Variable> filteredVars = new LinkedList<Variable>();
LinkedList<Variable> allVars = new LinkedList<Variable>();
allVars.addAll(Arrays.asList(getVariablesFilteredInclusive(dataBean, "", false)));
filteredVars.addAll(allVars);
String hidden = "chip.";
for (Variable var : allVars) {
for (String colToRemove : columnsToRemove) {
if (var.getName().startsWith(colToRemove)) {
filteredVars.remove(var);
}
}
if (removeStart && var.getName().startsWith(hidden)) {
String chipName = var.getName().substring(hidden.length());
filteredVars.set(filteredVars.indexOf(var), new Variable(chipName, var.getExpression()));
}
if (filteredVars.contains(var)) {
if (var.getName().equals(" ")) {
filteredVars.set(filteredVars.indexOf(var), new Variable("identifier", var.getExpression()));
}
}
}
return filteredVars.toArray(new Variable[0]);
}
@Override
public LinkedList<String> getSampleNames(LinkedList<String> sampleNames, DataUrl dataUrl) {
DataBean bean = ((BeanDataFile)dataUrl).bean;
try {
for (int i = 0; i < sampleNames.size(); i++) {
String internalName = sampleNames.get(i);
String sampleName;
sampleName = bean.queryFeatures("/phenodata/linked/describe/" + internalName).asString();
sampleNames.set(i, sampleName);
}
} catch (MicroarrayException e) {
//Use internal names
}
return sampleNames;
}
/**
*
*/
@Test
public void testLinkedListWriteUnmodifiable() {
GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
LinkedList<Object> src = Lists.newLinkedList(Arrays.asList(obj, "a", "b", "c"));
obj.foo = src;
BinaryObjectBuilderImpl mutObj = wrap(obj);
GridBinaryTestClasses.TestObjectContainer deserialized = mutObj.build().deserialize();
List<Object> res = (List<Object>)deserialized.foo;
src.set(0, deserialized);
assertEquals(src, res);
}