Search in sources :

Example 1 with Token

use of com.google.cloud.language.v1.Token in project bayou by capergroup.

the class TokenStream method pop.

// returns and removes the next token in the stream
private Token pop(boolean performHeadNullCheck) {
    if (performHeadNullCheck && _head == null)
        throw new IllegalStateException();
    Token toReturn = _head;
    _head = _next;
    if (!_tokens.hasNext()) {
        _next = null;
    } else {
        _next = _tokens.next();
        if (_next == null)
            throw new IllegalStateException("_tokens may not contain null");
    }
    return toReturn;
}
Also used : Token(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.Token)

Example 2 with Token

use of com.google.cloud.language.v1.Token in project bayou by capergroup.

the class EvidenceLLexerTests method testLexAlternating.

@Test
public void testLexAlternating() {
    EvidenceLLexer lexer = makeLexer();
    Iterator<Token> tokens = lexer.lex("ident1:ident2:ident3").iterator();
    Assert.assertTrue(tokens.hasNext());
    Token token = tokens.next();
    Assert.assertEquals("ident1", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
    token = tokens.next();
    Assert.assertEquals(":", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeColon);
    token = tokens.next();
    Assert.assertEquals("ident2", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
    token = tokens.next();
    Assert.assertEquals(":", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeColon);
    token = tokens.next();
    Assert.assertEquals("ident3", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
}
Also used : TokenTypeIdentifier(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.TokenTypeIdentifier) TokenTypeColon(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.TokenTypeColon) Token(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.Token) EvidenceLLexer(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.EvidenceLLexer) Test(org.junit.Test)

Example 3 with Token

use of com.google.cloud.language.v1.Token in project bayou by capergroup.

the class EvidenceLLexerTests method testLexMixed1.

@Test
public void testLexMixed1() {
    EvidenceLLexer lexer = makeLexer();
    Iterator<Token> tokens = lexer.lex("ident1: ident2, ident3").iterator();
    Assert.assertTrue(tokens.hasNext());
    Token token = tokens.next();
    Assert.assertEquals("ident1", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
    token = tokens.next();
    Assert.assertEquals(":", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeColon);
    token = tokens.next();
    Assert.assertEquals("ident2", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
    token = tokens.next();
    Assert.assertEquals(",", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeComma);
    token = tokens.next();
    Assert.assertEquals("ident3", token.getLexeme());
    Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
}
Also used : TokenTypeIdentifier(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.TokenTypeIdentifier) TokenTypeColon(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.TokenTypeColon) Token(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.Token) EvidenceLLexer(edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.EvidenceLLexer) Test(org.junit.Test)

Example 4 with Token

use of com.google.cloud.language.v1.Token in project platformlayer by platformlayer.

the class SmokeTest method buildFakeToken.

private KeystoneAuthenticationToken buildFakeToken(String tokenCode) {
    Access auth = new Access();
    Token tokenObject = new Token();
    tokenObject.setId(tokenCode);
    auth.setToken(tokenObject);
    return new KeystoneAuthenticationToken(auth);
}
Also used : Access(org.openstack.docs.identity.api.v2.Access) Token(org.openstack.docs.identity.api.v2.Token) KeystoneAuthenticationToken(org.openstack.keystone.auth.client.KeystoneAuthenticationToken) KeystoneAuthenticationToken(org.openstack.keystone.auth.client.KeystoneAuthenticationToken)

Example 5 with Token

use of com.google.cloud.language.v1.Token in project openstack4j by ContainX.

the class OSAuthenticator method reAuthenticate.

/**
     * Re-authenticates/renews the token for the current Session
     */
@SuppressWarnings("rawtypes")
public static void reAuthenticate() {
    LOG.debug("Re-Authenticating session due to expired Token or invalid response");
    OSClientSession session = OSClientSession.getCurrent();
    switch(session.getAuthVersion()) {
        case V2:
            KeystoneAccess access = ((OSClientSessionV2) session).getAccess().unwrap();
            SessionInfo info = new SessionInfo(access.getEndpoint(), session.getPerspective(), true, session.getProvider());
            Auth auth = (Auth) ((access.isCredentialType()) ? access.getCredentials() : access.getTokenAuth());
            authenticateV2((org.openstack4j.openstack.identity.v2.domain.Auth) auth, info, session.getConfig());
            break;
        case V3:
        default:
            Token token = ((OSClientSessionV3) session).getToken();
            info = new SessionInfo(token.getEndpoint(), session.getPerspective(), true, session.getProvider());
            authenticateV3((KeystoneAuth) token.getCredentials(), info, session.getConfig());
            break;
    }
}
Also used : OSClientSessionV3(org.openstack4j.openstack.internal.OSClientSession.OSClientSessionV3) Auth(org.openstack4j.openstack.common.Auth) TokenAuth(org.openstack4j.openstack.identity.v3.domain.TokenAuth) KeystoneAuth(org.openstack4j.openstack.identity.v3.domain.KeystoneAuth) KeystoneToken(org.openstack4j.openstack.identity.v3.domain.KeystoneToken) Token(org.openstack4j.model.identity.v3.Token) KeystoneAccess(org.openstack4j.openstack.identity.v2.domain.KeystoneAccess)

Aggregations

Token (edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.Token)7 EvidenceLLexer (edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.EvidenceLLexer)6 Test (org.junit.Test)6 TokenTypeIdentifier (edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.TokenTypeIdentifier)4 TokenTypeColon (edu.rice.cs.caper.bayou.core.lexer.evidencel._1_0.TokenTypeColon)3 Token (org.openstack4j.model.identity.v3.Token)3 AnalyzeSyntaxRequest (com.google.cloud.language.v1.AnalyzeSyntaxRequest)2 AnalyzeSyntaxResponse (com.google.cloud.language.v1.AnalyzeSyntaxResponse)2 Document (com.google.cloud.language.v1.Document)2 LanguageServiceClient (com.google.cloud.language.v1.LanguageServiceClient)2 Token (com.google.cloud.language.v1.Token)2 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)2 Access (org.openstack4j.model.identity.v2.Access)2 Token (com.lingtuan.firefly.custom.contact.HanziToPinyin3.Token)1 HashSet (java.util.HashSet)1 Access (org.openstack.docs.identity.api.v2.Access)1 Token (org.openstack.docs.identity.api.v2.Token)1 KeystoneAuthenticationToken (org.openstack.keystone.auth.client.KeystoneAuthenticationToken)1 Endpoint (org.openstack4j.model.identity.v3.Endpoint)1 Service (org.openstack4j.model.identity.v3.Service)1