java.util.Vector Java Examples

The following examples show how to use java.util.Vector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CSV.java    From tsml with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the current option settings for the OptionHandler.
 *
 * @return the list of current option settings as an array of strings
 */
public String[] getOptions() {
  Vector<String>	result;
  String[]		options;
  int			i;
  
  result = new Vector<String>();
  
  options = super.getOptions();
  for (i = 0; i < options.length; i++)
    result.add(options[i]);
  
  if (getUseTab())
    result.add("-use-tab");
  
  return result.toArray(new String[result.size()]);
}
 
Example #2
Source File: EventSupport.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add the event and vector of listeners to the queue to be delivered.
 * An event dispatcher thread dequeues events from the queue and dispatches
 * them to the registered listeners.
 * Package private; used by NamingEventNotifier to fire events
 */
synchronized void queueEvent(EventObject event,
                             Vector<? extends NamingListener> vector) {
    if (eventQueue == null)
        eventQueue = new EventQueue();

    /*
     * Copy the vector in order to freeze the state of the set
     * of EventListeners the event should be delivered to prior
     * to delivery.  This ensures that any changes made to the
     * Vector from a target listener's method during the delivery
     * of this event will not take effect until after the event is
     * delivered.
     */
    @SuppressWarnings("unchecked") // clone()
    Vector<NamingListener> v =
            (Vector<NamingListener>)vector.clone();
    eventQueue.enqueue(event, v);
}
 
Example #3
Source File: IdUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
  Return an IdList with all the duplicate ids removed
  @param l a list of ids in external form.
  @exception StandardException Oops.
  */
public static String pruneDups(String l) throws StandardException
{
	if (l == null) return null;
	String[] normal_a = parseIdList(l);
	StringReader r = new StringReader(l);
	String[] external_a = parseIdList(r,false);
	HashSet h = new HashSet();
	Vector v = new Vector();
	for(int ix=0;ix<normal_a.length;ix++)
	{
		if (!h.contains(normal_a[ix]))
		{
			h.add(normal_a[ix]);
			v.addElement(external_a[ix]);
		}
	}
	return vectorToIdList(v,false);
}
 
Example #4
Source File: DPPIsotopeGrouperTask.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Fits isotope pattern around one peak.
 * 
 * @param p Pattern is fitted around this peak
 * @param charge Charge state of the fitted pattern
 */
private void fitPattern(Vector<DataPoint> fittedPeaks, DataPoint p, int charge,
    DataPoint[] sortedPeaks, double isotopeDistance) {

  if (charge == 0) {
    return;
  }

  // Search for peaks before the start peak
  if (!monotonicShape) {
    fitHalfPattern(p, charge, -1, fittedPeaks, sortedPeaks, isotopeDistance);
  }

  // Search for peaks after the start peak
  fitHalfPattern(p, charge, 1, fittedPeaks, sortedPeaks, isotopeDistance);

}
 
Example #5
Source File: IOUtil.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Attempts to completely read data from the specified Reader, line by line.
 * The Reader is closed whether or not the read was successful.
 * 
 * @param filename
 *            the name of the file to be read
 * 
 * @return a Vector of Strings, one for each line of data
 * 
 * @throws IOException
 *             if an I/O error occurs
 */
static Vector<String> readText( Reader r ) throws IOException
{
	BufferedReader br = new BufferedReader( r );
	try
	{
		Vector<String> ret = new Vector<String>( );
		String line;
		while ( ( line = br.readLine( ) ) != null )
			ret.addElement( line.intern( ) ); // Avoid wasting space
		return ret;
	}
	finally
	{
		close( br );
	}
}
 
Example #6
Source File: PodZoneConfig.java    From cloudstack with Apache License 2.0 6 votes vote down vote up
@DB
public Vector<Long> getAllZoneIDs() {
    Vector<Long> allZoneIDs = new Vector<Long>();

    String selectSql = "SELECT id FROM data_center";
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    try {
        PreparedStatement stmt = txn.prepareAutoCloseStatement(selectSql);
        ResultSet rs = stmt.executeQuery();
        while (rs.next()) {
            Long dcId = rs.getLong("id");
            allZoneIDs.add(dcId);
        }
    } catch (SQLException ex) {
        System.out.println(ex.getMessage());
        printError("There was an issue with reading zone IDs. Please contact Cloud Support.");
        return null;
    }

    return allZoneIDs;
}
 
Example #7
Source File: Window.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void initDeserializedWindow() {
    setWarningString();
    inputContextLock = new Object();

    // Deserialized Windows are not yet visible.
    visible = false;

    weakThis = new WeakReference<>(this);

    anchor = new Object();
    disposerRecord = new WindowDisposerRecord(appContext, this);
    sun.java2d.Disposer.addRecord(anchor, disposerRecord);

    addToWindowList();
    initGC(null);
    ownedWindowList = new Vector<>();
}
 
Example #8
Source File: Catalog.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Copies the reader list from the current Catalog to a new Catalog.
 *
 * <p>This method is used internally when constructing a new catalog.
 * It copies the current reader associations over to the new catalog.
 * </p>
 *
 * @param newCatalog The new Catalog.
 */
protected void copyReaders(Catalog newCatalog) {
  // Have to copy the readers in the right order...convert hash to arr
  Vector mapArr = new Vector(readerMap.size());

  // Pad the mapArr out to the right length
  for (int count = 0; count < readerMap.size(); count++) {
    mapArr.add(null);
  }

  for (Map.Entry<String, Integer> entry : readerMap.entrySet()) {
      mapArr.set(entry.getValue(), entry.getKey());
  }

  for (int count = 0; count < mapArr.size(); count++) {
    String mimeType = (String) mapArr.get(count);
    Integer pos = readerMap.get(mimeType);
    newCatalog.addReader(mimeType,
                         (CatalogReader)
                         readerArr.get(pos));
  }
}
 
Example #9
Source File: SnmpMsg.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For SNMP Runtime private use only.
 */
public SnmpVarBind[] decodeVarBindList(BerDecoder bdec)
    throws BerException {
        bdec.openSequence() ;
        Vector<SnmpVarBind> tmp = new Vector<SnmpVarBind>() ;
        while (bdec.cannotCloseSequence()) {
            SnmpVarBind bind = new SnmpVarBind() ;
            bdec.openSequence() ;
            bind.oid = new SnmpOid(bdec.fetchOid()) ;
            bind.setSnmpValue(decodeVarBindValue(bdec)) ;
            bdec.closeSequence() ;
            tmp.addElement(bind) ;
        }
        bdec.closeSequence() ;
        SnmpVarBind[] varBindList= new SnmpVarBind[tmp.size()] ;
        tmp.copyInto(varBindList);
        return varBindList ;
    }
 
Example #10
Source File: EventSupport.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add the event and vector of listeners to the queue to be delivered.
 * An event dispatcher thread dequeues events from the queue and dispatches
 * them to the registered listeners.
 * Package private; used by NamingEventNotifier to fire events
 */
synchronized void queueEvent(EventObject event,
                             Vector<? extends NamingListener> vector) {
    if (eventQueue == null)
        eventQueue = new EventQueue();

    /*
     * Copy the vector in order to freeze the state of the set
     * of EventListeners the event should be delivered to prior
     * to delivery.  This ensures that any changes made to the
     * Vector from a target listener's method during the delivery
     * of this event will not take effect until after the event is
     * delivered.
     */
    @SuppressWarnings("unchecked") // clone()
    Vector<NamingListener> v =
            (Vector<NamingListener>)vector.clone();
    eventQueue.enqueue(event, v);
}
 
Example #11
Source File: TiffParser.java    From scifio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Gets the offsets to every IFD in the file. */
public long[] getIFDOffsets() throws IOException {
	// check TIFF header
	final int bytesPerEntry = bigTiff ? TiffConstants.BIG_TIFF_BYTES_PER_ENTRY
		: TiffConstants.BYTES_PER_ENTRY;

	final Vector<Long> offsets = new Vector<>();
	long offset = getFirstOffset();
	while (offset > 0 && offset < in.length()) {
		in.seek(offset);
		offsets.add(offset);
		final int nEntries = bigTiff ? (int) in.readLong() : in
			.readUnsignedShort();
		in.skipBytes(nEntries * bytesPerEntry);
		offset = getNextOffset(offset);
	}

	final long[] f = new long[offsets.size()];
	for (int i = 0; i < f.length; i++) {
		f[i] = offsets.get(i).longValue();
	}

	return f;
}
 
Example #12
Source File: MailDialog.java    From jplag with GNU General Public License v3.0 6 votes vote down vote up
private void init(int typ, String title, RequestData rd, AdminTool at) {
    adminTool = at;
    type = typ;
    reqData = rd;
    if(type == MAIL_ALL) {
        showSendButtons = false;
        type = MAIL_ACCEPTED;
    }
    try {
        MailTemplate[] temps = at.getJPlagStub().getMailTemplates(type).
                getItems();
        templates = new Vector<MailTemplate>(temps.length,3);
        for(int i=0;i<temps.length;i++)
            templates.add(temps[i]);
    }
    catch(Exception ex) {
        at.CheckException(ex,at);
    }
    initialize(title);
}
 
Example #13
Source File: BreakIteratorTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void TestBug4217703() {
    if (Locale.getDefault().getLanguage().equals("th")) {
        logln("This test is skipped in th locale.");
        return;
    }

    Vector<String> lineSelectionData = new Vector<String>();

    // There shouldn't be a line break between sentence-ending punctuation
    // and a closing quote
    lineSelectionData.addElement("He ");
    lineSelectionData.addElement("said ");
    lineSelectionData.addElement("\"Go!\"  ");
    lineSelectionData.addElement("I ");
    lineSelectionData.addElement("went.  ");

    lineSelectionData.addElement("Hashtable$Enumeration ");
    lineSelectionData.addElement("getText().");
    lineSelectionData.addElement("getIndex()");

    generalIteratorTest(lineBreak, lineSelectionData);
}
 
Example #14
Source File: DocumentImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in)
                    throws IOException, ClassNotFoundException {
    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = in.readFields();
    Vector<NodeIterator> it = (Vector<NodeIterator>)gf.get("iterators", null);
    Vector<Range> r = (Vector<Range>)gf.get("ranges", null);
    Hashtable<NodeImpl, Vector<LEntry>> el =
            (Hashtable<NodeImpl, Vector<LEntry>>)gf.get("eventListeners", null);

    mutationEvents = gf.get("mutationEvents", false);

    //convert Hashtables back to HashMaps and Vectors to Lists
    if (it != null) iterators = new ArrayList<>(it);
    if (r != null) ranges = new ArrayList<>(r);
    if (el != null) {
        eventListeners = new HashMap<>();
        for (Map.Entry<NodeImpl, Vector<LEntry>> e : el.entrySet()) {
             eventListeners.put(e.getKey(), new ArrayList<>(e.getValue()));
        }
    }
}
 
Example #15
Source File: PatternScannerTest.java    From beepbeep-3 with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testTokenFeederPull1() 
{
	Object o;
	QueueSource qsource = new QueueSource(1);
	Vector<Object> events = new Vector<Object>();
	events.add("|hello.|hi.");
	qsource.setEvents(events);
	FindPattern mf = new FindPattern("\\|.*?\\.");
	Connector.connect(qsource, mf);
	Pullable p = mf.getPullableOutput(0);
	o = p.pullSoft();
	assertEquals("|hello.", (String) o);
	o = p.pullSoft();
	assertEquals("|hi.", (String) o);
}
 
Example #16
Source File: TmfStatisticsTreeNodeTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test getting of children.
 */
@Test
public void testGetChildren() {
    // Getting children of the ROOT
    Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsTree.getRootNode().getChildren();
    assertEquals(1, childrenTreeNode.size());
    TmfStatisticsTreeNode treeNode = childrenTreeNode.iterator().next();
    assertEquals(fTestName, treeNode.getName());

    // Getting children of the trace
    childrenTreeNode = fStatsTree.getNode(fTestName).getChildren();
    assertEquals(1, childrenTreeNode.size());
    treeNode = childrenTreeNode.iterator().next();
    assertEquals(Messages.TmfStatisticsData_EventTypes, treeNode.getName());

    Vector<String> keyExpected = new Vector<>();
    keyExpected.add(fTypeId1);
    keyExpected.add(fTypeId2);
    keyExpected.add(fTypeId3);
    // Getting children of a category
    childrenTreeNode = treeNode.getChildren();
    assertEquals(3, childrenTreeNode.size());

    Iterator<TmfStatisticsTreeNode> iterChild = childrenTreeNode.iterator();
    TmfStatisticsTreeNode temp;
    while (iterChild.hasNext()) {
        temp = iterChild.next();
        if (keyExpected.contains(temp.getName())) {
            keyExpected.removeElement(temp.getName());
        } else {
            fail();
        }
    }

    // Get children of a specific event type
    childrenTreeNode = fStatsTree.getNode(childrenTreeNode.iterator().next().getPath()).getChildren();
    assertEquals(0, childrenTreeNode.size());
}
 
Example #17
Source File: CefFileDialogCallback_N.java    From pandomium with Apache License 2.0 5 votes vote down vote up
@Override
public void Continue(int selectedAcceptFilter, Vector<String> filePaths) {
    try {
        N_Continue(selectedAcceptFilter, filePaths);
    } catch (UnsatisfiedLinkError ule) {
        ule.printStackTrace();
    }
}
 
Example #18
Source File: ProtocolManager.java    From gsn with GNU General Public License v3.0 5 votes vote down vote up
public synchronized byte[] sendQuery(String queryName, Vector<Object> params) {
	byte[] answer = null;
	if(currentState == ProtocolStates.READY) {
		AbstractHCIQuery query = protocol.getQuery( queryName );
		
		if(query != null) {
			logger.debug( "Retrieved query " + queryName + ", trying to build raw query.");

			byte[] queryBytes = query.buildRawQuery( params );
			if(queryBytes != null) {
				try {
					logger.debug("Built query, it looks like: " + new String(queryBytes));
					outputWrapper.sendToWrapper(null,null,new Object[] {queryBytes});
					lastExecutedQuery = query;
					lastParams = params;
					answer = queryBytes;
					logger.debug("Query succesfully sent!");
					if(query.needsAnswer( params )) {
						logger.debug("Now entering wait mode for answer.");
						timer = new Timer();
						currentState = ProtocolStates.WAITING;
						timer.schedule( answerTimeout , new Date());
					}
				} catch( OperationNotSupportedException e ) {
					logger.debug("Query could not be sent ! See error message.");
					logger.error( e.getMessage( ) , e );
					currentState = ProtocolStates.READY;
				}
			}
		} else {
			logger.warn("Query " + queryName + " found but no bytes produced to send to device. Implementation may be missing.");
		}

	}
	return answer;
}
 
Example #19
Source File: fuzzyRule.java    From KEEL with GNU General Public License v3.0 5 votes vote down vote up
public float match(float[] x,Vector<fuzzyPartition> pentradas)
{
	float m=1,m1;
	for (int i=0;i<antecedent.length;i++) 
	{
		m1=pentradas.get(i).membership(antecedent[i],x[i]);
		m=tnorma(m,m1,1);
	}
	
	return m;
}
 
Example #20
Source File: ConfigParser.java    From android with GNU General Public License v3.0 5 votes vote down vote up
private void checkRedirectParameters(VpnProfile np, Vector<Vector<String>> defgw) {
    for (Vector<String> redirect : defgw)
        for (int i = 1; i < redirect.size(); i++) {
            if (redirect.get(i).equals("block-local"))
                np.mAllowLocalLAN = false;
            else if (redirect.get(i).equals("unblock-local"))
                np.mAllowLocalLAN = true;
        }
}
 
Example #21
Source File: SesameHTTPRepositoryTest.java    From cumulusrdf with Apache License 2.0 5 votes vote down vote up
/**
 * test get Graph Query.
 * @throws Exception The test would fails if Exception occurs
 */
@Test
public void testGraphQuery() throws Exception {
	//insert some statments first
	for (final String tripleAsString : _data) {
		final Statement triple = parseNX(tripleAsString).iterator().next();
		TRIPLE_STORE.addData(triple);
	}
	//test Graph Query
	String queryString = "SELECT ?x ?y WHERE { ?x ?p ?y } ";
	String uri = BASE_URI + Protocol.REPOSITORIES + "/" + REPO_ID;
	File tmp = WebTestUtils.tmpFile();
	final ServletOutputStream servletOutputStream = new StubServletOutputStream(tmp);
	final HttpServletRequest request = mockHttpRequest(uri, METHOD_POST);
	when(request.getContentType()).thenReturn(MIMETYPE_WWW_FORM);
	when(request.getParameter(Protocol.QUERY_LANGUAGE_PARAM_NAME)).thenReturn(QueryLanguage.SPARQL.toString());
	when(request.getParameter(Protocol.QUERY_PARAM_NAME)).thenReturn(queryString);
	when(request.getParameter(Protocol.ACCEPT_PARAM_NAME)).thenReturn("application/x-binary-rdf-results-table");
	Vector<String> vec = new Vector<String>();
	when(request.getParameterNames()).thenReturn(vec.elements());
	when(request.getCharacterEncoding()).thenReturn(UTF_8);
	final HttpServletResponse response = mock(HttpServletResponse.class);
	when(response.getOutputStream()).thenReturn(servletOutputStream);


	_classUnderTest.service(request, response);
	
	Set<TupleQueryResultFormat> tqrFormats = TupleQueryResultParserRegistry.getInstance().getKeys();
	TupleQueryResultFormat format = TupleQueryResultFormat.matchMIMEType("application/x-binary-rdf-results-table", tqrFormats);
	TupleQueryResultParser parser = QueryResultIO.createParser(format, valueFactory);
	FileInputStream in = new FileInputStream(tmp);
	BackgroundTupleResult tRes = new BackgroundTupleResult(parser, in, null);
	parser.setQueryResultHandler(tRes);
	parser.parseQueryResult(in);
	assertTrue(tRes.hasNext());
	verify(response).setStatus(HttpServletResponse.SC_OK);

	servletOutputStream.close();
}
 
Example #22
Source File: Mode.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Complete test sequences of a given type by adding all patterns
 * from a given group.
 */
private void completeTestSequences(int nodeType, Vector patterns) {
    if (patterns != null) {
        if (_patternGroups[nodeType] == null) {
            _patternGroups[nodeType] = patterns;
        }
        else {
            final int m = patterns.size();
            for (int j = 0; j < m; j++) {
                addPattern(nodeType,
                    (LocationPathPattern) patterns.elementAt(j));
            }
        }
    }
}
 
Example #23
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void populateSimilarityMatrix(
		OWLNamedIndividual i, OWLNamedIndividual j,
		ElementPairScores ijscores) throws UnknownOWLClassException, NoElementAttributeMapException {

	/*
	EWAHCompressedBitmap bmc = ancsBitmapCachedModifiable(i);
	EWAHCompressedBitmap bmd = ancsBitmapCachedModifiable(j);
	EWAHCompressedBitmap cad = bmc.and(bmd);
	EWAHCompressedBitmap cud = bmc.or(bmd);
	Set<Node<OWLClass>> nodes = new HashSet<Node<OWLClass>>();
	for (int ix : cad.toArray()) {
		OWLClassNode node = new OWLClassNode(classArray[ix]);
		nodes.add(node);
	}
	 */

	/*
	ijscores.simGIC = getElementGraphInformationContentSimilarity(i, j);
	ijscores.asymmetricSimGIC = getAsymmetricElementGraphInformationContentSimilarity(i, j);
	ijscores.inverseAsymmetricSimGIC = getAsymmetricElementGraphInformationContentSimilarity(j, i);
	 */

	ijscores.simjScore = getElementJaccardSimilarity(i, j);

	if (ijscores.simjScore == null || ijscores.simjScore.isNaN()) {
		//the elementattributemap probably hasn't been populated.
		//log an error and exit.
		throw new NoElementAttributeMapException();
	}


	ijscores.asymmetricSimjScore = 
			getAsymmetricElementJaccardSimilarity(i, j);
	ijscores.inverseAsymmetricSimjScore =
			getAsymmetricElementJaccardSimilarity(j, i);

	Vector<OWLClass> cs = new Vector<OWLClass>(getAttributesForElement(i));
	Vector<OWLClass> ds = new Vector<OWLClass>(getAttributesForElement(j));
	populateSimilarityMatrix(cs, ds, ijscores);
}
 
Example #24
Source File: RBTableBuilder.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private final int getCharOrder(int ch) {
    int order = mapping.elementAt(ch);

    if (order >= RBCollationTables.CONTRACTCHARINDEX) {
        Vector<EntryPair> groupList = getContractValuesImpl(order - RBCollationTables.CONTRACTCHARINDEX);
        EntryPair pair = groupList.firstElement();
        order = pair.value;
    }
    return order;
}
 
Example #25
Source File: CreateSPMLIdentity.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
public void add(AddInterceptorChain chain, Entry entry,
		LDAPConstraints constraints) throws LDAPException {
	Vector rdns = (new DN(entry.getEntry().getDN())).getRDNs();
	RDN rdn = (RDN) rdns.get(0);
	RDN newRdn = new RDN();
	
	if (rdn.getType().equalsIgnoreCase(this.idAttrib)) {
		newRdn.add(this.idType,rdn.getValue(),null);
	} else {
		newRdn.add(this.idType,entry.getEntry().getAttribute(this.idAttrib).getStringValue(),null);
	}
	
	DN newDn = new DN();
	newDn.addRDN(newRdn);
	
	for (int i=1,m=rdns.size();i<m;i++) {
		newDn.addRDNToBack((RDN)rdns.get(i));
	}
	
	entry.setDN(newDn);
	
	if (! this.keepNameAsAttribute) {
		entry.getEntry().getAttributeSet().remove(this.idAttrib);
	}
	
	chain.nextAdd(entry,constraints);


}
 
Example #26
Source File: RBTableBuilder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private final int getCharOrder(int ch) {
    int order = mapping.elementAt(ch);

    if (order >= RBCollationTables.CONTRACTCHARINDEX) {
        Vector<EntryPair> groupList = getContractValuesImpl(order - RBCollationTables.CONTRACTCHARINDEX);
        EntryPair pair = groupList.firstElement();
        order = pair.value;
    }
    return order;
}
 
Example #27
Source File: ParticipantGmsImpl.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
     * Determines whether this member is the new coordinator given a list of suspected members.  This is
     * computed as follows: the list of currently suspected members (suspected_mbrs) is removed from the current
     * membership. If the first member of the resulting list is equals to the local_addr, then it is true,
     * otherwise false. Example: own address is B, current membership is {A, B, C, D}, suspected members are {A,
     * D}. The resulting list is {B, C}. The first member of {B, C} is B, which is equal to the
     * local_addr. Therefore, true is returned.
     * @param suspects members that have crashed
     * @param departures members that have departed normally
     */
    boolean wouldIBeCoordinator(Vector suspects, Set<Address> departures) {
        Address new_coord;
        Vector mbrs=gms.members.getMembers(); // getMembers() returns a *copy* of the membership vector

        if (log.isDebugEnabled()) {
          log.debug("wouldIBeCoordinator:\nmembers = " + mbrs + "\ndeparted = " + this.departed_mbrs
              + "\nsuspected = " + this.suspected_mbrs);
        }

        if (suspects != null) {
          mbrs.removeAll(suspects);
        }
        
        if (departures != null) {
          mbrs.removeAll(departures);
        }

        if(mbrs.size() < 1) return false;
        // GemStoneAddition - revised for split-brain detection
        new_coord = new Membership(mbrs).getCoordinator();
//        log.getLogWriterI18n().info(JGroupsStrings.DEBUG, "pgms: of members " + mbrs + " the coordinator would be " + new_coord);
        if (new_coord == null) { // oops - no eligable coordinators
          return false;
        }
        return gms.local_addr.equals(new_coord);
    }
 
Example #28
Source File: XSDHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * getSchemaDocument method uses XMLInputSource to parse a schema document.
 * @param schemaNamespace
 * @param schemaSource
 * @param mustResolve
 * @param referType
 * @param referElement
 * @return A schema Element.
 */
private Element getSchemaDocument(XSInputSource schemaSource, XSDDescription desc) {

    SchemaGrammar[] grammars = schemaSource.getGrammars();
    short referType = desc.getContextType();

    if (grammars != null && grammars.length > 0) {
        Vector expandedGrammars = expandGrammars(grammars);
        // check for existing grammars in our bucket
        // and if there exist any, and namespace growth is
        // not enabled - we do nothing
        if (fNamespaceGrowth || !existingGrammars(expandedGrammars)) {
            addGrammars(expandedGrammars);
            if (referType == XSDDescription.CONTEXT_PREPARSE) {
                desc.setTargetNamespace(grammars[0].getTargetNamespace());
            }
        }
    }
    else {
        XSObject[] components = schemaSource.getComponents();
        if (components != null && components.length > 0) {
            Map<String, Vector> importDependencies = new HashMap();
            Vector expandedComponents = expandComponents(components, importDependencies);
            if (fNamespaceGrowth || canAddComponents(expandedComponents)) {
                addGlobalComponents(expandedComponents, importDependencies);
                if (referType == XSDDescription.CONTEXT_PREPARSE) {
                    desc.setTargetNamespace(components[0].getNamespace());
                }
            }
        }
    }
    return null;
}
 
Example #29
Source File: SQLGenericPrms.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static int[] getDDLs() {
  Vector ddls = TestConfig.tab().vecAt(SQLGenericPrms.ddlOperations,
      new HydraVector());
  int[] ddlArr = new int[ddls.size()];
  String[] strArr = new String[ddls.size()];
  for (int i = 0; i < ddls.size(); i++) {
    strArr[i] = (String) ddls.elementAt(i); // get what ddl ops are in the
                                            // tests
  }

  for (int i = 0; i < strArr.length; i++) {
    ddlArr[i] = DDLStmtFactory.getInt(strArr[i]); // convert to int array
  }
  return ddlArr;
}
 
Example #30
Source File: DecodeFormatManager.java    From react-native-smart-barcode with MIT License 5 votes vote down vote up
private static Vector<BarcodeFormat> parseDecodeFormats(Iterable<String> scanFormats,
                                                        String decodeMode) {
  if (scanFormats != null) {
    Vector<BarcodeFormat> formats = new Vector<BarcodeFormat>();
    try {
      for (String format : scanFormats) {
        formats.add(BarcodeFormat.valueOf(format));
      }
      return formats;
    } catch (IllegalArgumentException iae) {
      // ignore it then
    }
  }
  if (decodeMode != null) {
    if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) {
      return PRODUCT_FORMATS;
    }
    if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) {
      return QR_CODE_FORMATS;
    }
    if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) {
      return DATA_MATRIX_FORMATS;
    }
    if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) {
      return ONE_D_FORMATS;
    }
  }
  return null;
}