Package org.apache.beehive.netui.pageflow.internal

Examples of org.apache.beehive.netui.pageflow.internal.PageFlowRequestWrapper$State


    @Override
    public CompletionContext<State> buildContext(
        SelectionModel selection, DocumentParser parser) {
      JsonArray<Token> tokens = JsonCollections.createArray();
      State state = TestUtils.createMockState();
      tokens.add(new Token(null, NULL, ""));
      ParseResult<State> parseResult = new ParseResult<State>(tokens, state) {};
      return buildContext(
          new ParseUtils.ExtendedParseResult<State>(parseResult, ParseUtils.Context.IN_CODE));
    }
View Full Code Here


   * @param anchorToUpdate the optional anchor that this method will update
   */
  private boolean parseImplCm2(Line line, int lineNumber, int numLinesToProcess,
      @Nullable Anchor anchorToUpdate, ParsedTokensRecipient tokensRecipient) {

    State parserState = loadParserStateForBeginningOfLine(line);
    if (parserState == null) {
      return false;
    }

    Line previousLine = line.getPreviousLine();

    for (int numLinesProcessed = 0; line != null && numLinesProcessed < numLinesToProcess;) {
      State stateToSave = parserState;
      if (line.getText().length() > LINE_LENGTH_LIMIT) {
        // Save the initial state instead of state at the end of line.
        stateToSave = parserState.copy(codeMirrorParser);
      }

View Full Code Here

    parseImplCm2(line, -1, 1, null, tokensRecipient);
    return tokensRecipient.tokens;
  }

  int getIndentation(Line line) {
    State stateBefore = loadParserStateForBeginningOfLine(line);
    String textAfter = line.getText();
    textAfter = textAfter.substring(StringUtils.lengthOfStartingWhitespace(textAfter));
    return codeMirrorParser.indent(stateBefore, textAfter);
  }
View Full Code Here

   *
   * @return copy of corresponding parser state, or {@code null} if the state
   *         if not known yet (previous line wasn't parsed).
   */
  private <T extends State> T loadParserStateForBeginningOfLine(TaggableLine line) {
    State state;
    if (line.isFirstLine()) {
      state = codeMirrorParser.defaultState();
    } else {
      state = line.getPreviousLine().getTag(LINE_TAG_END_OF_LINE_PARSER_STATE_SNAPSHOT);
      state = (state == null) ? null : state.copy(codeMirrorParser);
    }

    @SuppressWarnings("unchecked")
    T result = (T) state;
    return result;
View Full Code Here

   *
   * @see #loadParserStateForBeginningOfLine
   */
  @Nullable
  String getInitialMode(@Nonnull TaggableLine line) {
    State state = loadParserStateForBeginningOfLine(line);
    if (state == null) {
      return null;
    }
    return codeMirrorParser.getName(state);
  }
View Full Code Here

    }
    return codeMirrorParser.getName(state);
  }

  private void saveEndOfLineParserState(Line line, State parserState) {
    State copiedParserState = parserState.copy(codeMirrorParser);
    line.putTag(LINE_TAG_END_OF_LINE_PARSER_STATE_SNAPSHOT, copiedParserState);
  }
View Full Code Here

   *
   * @param toMatch
   * @return
   */
  public Iterator<Lookup> match(String toMatch) {
    State currentState = getInitialState();
    for (int i = 0; i < toMatch.length(); i++) {
      char currentChar = toMatch.charAt(i);
      currentState = currentState.next(currentChar);
      if (currentState == null) {
        break;
      }
      if (i==(toMatch.length()-1) && currentState.isFinal()) {  // we are at the last character
        return getLookups(currentState);
      }
    }
    return null;
  }
View Full Code Here

    kv2[0] = "KEY1of2";
    kv2[1] = "VALUE1of2";
    kv2[2] = "KEY2of2";
    kv2[3] = "VALUE2of2";
    gs.addLookup("as", info1, kv2);
    State init = gs.getInitialState();
    System.out.println("Initial State: "+init);
    State s1 = init.next('a');
    System.out.println("State after a: "+s1);
    System.out.println("isFinal: "+s1.isFinal());
    State s2 = s1.next('s');
    System.out.println("State after s: "+s2);
    System.out.println("isFinal: "+s2.isFinal());
    Iterator<Lookup> lookupIter = gs.getLookups(s2);
    System.out.println("Have lookups: "+lookupIter.hasNext());
    while(lookupIter.hasNext()) {
      Lookup l = lookupIter.next();
      System.out.println("Have a lookup"+l);
    }
    File someFile = new File("tmp.gazbin");
    try {
      gs.save(someFile);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      assertTrue("could not save trie", false);
      return;
    }
    GazStoreTrie3 gs2 = new GazStoreTrie3();
    try {
      gs2 = (GazStoreTrie3)gs2.load(someFile);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      assertTrue("could not load trie",false);
      return;
    }
    State init_2 = gs2.getInitialState();
    System.out.println("Initial State: "+init_2);
    State s1_2 = init_2.next('a');
    System.out.println("State after a: "+s1_2);
    System.out.println("isFinal: "+s1_2.isFinal());
    State s2_2 = s1_2.next('s');
    System.out.println("State after s: "+s2_2);
    System.out.println("isFinal: "+s2_2.isFinal());
    Iterator<Lookup> lookupIter_2 = gs2.getLookups(s2_2);
    System.out.println("Have lookups: "+lookupIter_2.hasNext());
    while(lookupIter_2.hasNext()) {
      Lookup l = lookupIter_2.next();
      System.out.println("Have a lookup"+l);
View Full Code Here

        throws IOException, ServletException
    {
        //
        // First check to see if we're already in a forwarded fallback request.  If so, just bail.
        //
        PageFlowRequestWrapper rw = PageFlowRequestWrapper.get( request );
        if ( rw.getOriginalServletPath() != null ) return false;      
       
        SharedFlowController sharedFlowToTry = null;
        String uriBaseName = ServletUtils.getBaseName( uri );
        int firstDot = uriBaseName.indexOf( '.' );
        int lastDot = uriBaseName.lastIndexOf( '.' );
       
        if ( firstDot != -1 && firstDot != lastDot )
        {
            String sharedFlowName = uriBaseName.substring( 0, firstDot );
           
            try
            {
                RequestContext rc = new RequestContext( request, response );
                Map defaultSharedFlows = FlowControllerFactory.get( getServletContext() ).getDefaultSharedFlows( rc );
               
                if ( defaultSharedFlows != null )
                {
                    sharedFlowToTry = ( SharedFlowController ) defaultSharedFlows.get( sharedFlowName );
                    uriBaseName = uriBaseName.substring( firstDot + 1 );
                }
            }
            catch ( ClassNotFoundException e )
            {
                throw new ServletException( e );
            }
            catch ( InstantiationException e )
            {
                throw new ServletException( e );
            }
            catch ( IllegalAccessException e )
            {
                throw new ServletException( e );
            }
        }
        else
        {
            sharedFlowToTry = FlowControllerFactory.getGlobalApp( request, response, getServletContext() );
        }
       
        //
        // If we couldn't find an appropriate module, try raising the action on the (deprecated) Global.app.
        //
       
        if ( sharedFlowToTry != null )
        {
            InternalStringBuilder sfActionURI = new InternalStringBuilder( sharedFlowToTry.getModulePath() );
            sfActionURI.append( '/' );
            sfActionURI.append( uriBaseName );
            rw.setOriginalServletPath( uri );
            ForwardRedirectHandler frh = _handlers.getForwardRedirectHandler();
            FlowControllerHandlerContext context = new FlowControllerHandlerContext( request, response, null );
            frh.forward( context, sfActionURI.toString() );
            return true;
        }
View Full Code Here

            //
            // Register the default URLRewriter
            //
            URLRewriterService.registerURLRewriter( 0, request, new DefaultURLRewriter() );

            PageFlowRequestWrapper rw = PageFlowRequestWrapper.unwrap( request );
            boolean isForwardedRequest = rw != null && rw.isForwardedRequest();
           
            try
            {
                ModuleConfig prevModuleConfig = RequestUtils.getRequestModuleConfig( httpRequest );
                MessageResources prevMessageResources = ( MessageResources ) request.getAttribute( Globals.MESSAGES_KEY );
                if ( rw == null || ! rw.isStayInCurrentModule() ) initializeModule( httpRequest, httpResponse );
               
                try
                {
                    //
                    // Initialize shared flows for the current request.
                    //
                    Map/*< String, SharedFlowController >*/ sharedFlows =
                            _flowControllerFactory.getSharedFlowsForRequest( requestContext );
                    ImplicitObjectUtil.loadSharedFlow( request, sharedFlows );
                    ImplicitObjectUtil.loadGlobalApp( request, PageFlowUtils.getGlobalApp( httpRequest ) );
                   
                    //
                    // Make sure that the current PageFlowController is set up for this request.
                    //
                    PageFlowController curJpf;
                    if ( rw != null && rw.isStayInCurrentModule() )
                    {
                        rw.setStayInCurrentModule( false );
                        curJpf = PageFlowUtils.getCurrentPageFlow( httpRequest, _servletContext );
                    }
                    else
                    {
                        curJpf = _flowControllerFactory.getPageFlowForRequest( requestContext );
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.pageflow.internal.PageFlowRequestWrapper$State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.