当前位置: 首页>>代码示例>>Java>>正文


Java StackFrameStep类代码示例

本文整理汇总了Java中org.commcare.suite.model.StackFrameStep的典型用法代码示例。如果您正苦于以下问题:Java StackFrameStep类的具体用法?Java StackFrameStep怎么用?Java StackFrameStep使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StackFrameStep类属于org.commcare.suite.model包,在下文中一共展示了StackFrameStep类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
@Before
public void setUp() {
    mSandbox = new PersistableSandbox();

    commandIdStepV1 = new StackFrameStep(SessionFrame.STATE_COMMAND_ID, "id", null);
    commandIdStepV2 = new StackFrameStep(SessionFrame.STATE_COMMAND_ID, "id", null);

    caseIdStepV1 = new StackFrameStep(SessionFrame.STATE_DATUM_VAL, "id", "case_val");
    caseIdStepV2 = new StackFrameStep(SessionFrame.STATE_DATUM_VAL, "id", null);

    formXmlnsStepV1 = new StackFrameStep(SessionFrame.STATE_FORM_XMLNS, "xmlns_id1", null);
    formXmlnsStepV2 = new StackFrameStep(SessionFrame.STATE_FORM_XMLNS, "xmlns_id2", null);

    datumComputedStepV1 = new StackFrameStep(SessionFrame.STATE_DATUM_COMPUTED, "datum_val_id", "datum_val1");
    datumComputedStepV2 = new StackFrameStep(SessionFrame.STATE_DATUM_COMPUTED, "datum_val_id", "datum_val2");

    // frame steps can store externalizable data, such as ints, Strings,
    // or anything that implements Externalizable
    stepWithExtras = new StackFrameStep(SessionFrame.STATE_DATUM_COMPUTED, "datum_val_id", "datum_val2");
    stepWithExtras.addExtra("key", 123);

    // Demonstrate how frame steps can't store non-externalizable data in extras
    stepWithBadExtras = new StackFrameStep(SessionFrame.STATE_DATUM_COMPUTED, "datum_val_id", "datum_val2");
    stepWithBadExtras.addExtra("key", new ByteArrayInputStream(new byte[]{1,2,3}));
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:26,代码来源:StackFrameStepTests.java

示例2: serializationTest

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
@Test
public void serializationTest() {
    byte[] serializedStep = mSandbox.serialize(commandIdStepV1);
    StackFrameStep deserialized = mSandbox.deserialize(serializedStep, StackFrameStep.class);
    assertTrue("Serialization resulted in altered StackFrameStep",
            commandIdStepV1.equals(deserialized));

    serializedStep = mSandbox.serialize(stepWithExtras);
    deserialized = mSandbox.deserialize(serializedStep, StackFrameStep.class);
    assertTrue("",
            stepWithExtras.equals(deserialized));

    boolean failed = false;
    try {
        mSandbox.serialize(stepWithBadExtras);
    } catch (Exception e) {
        failed = true;
    }
    assertTrue(failed);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:21,代码来源:StackFrameStepTests.java

示例3: CommCareSession

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
/**
 * Copy constructor
 */
public CommCareSession(CommCareSession oldCommCareSession) {
    // NOTE: 'platform' is being copied in a shallow manner
    this.platform = oldCommCareSession.platform;

    if (oldCommCareSession.popped != null) {
        this.popped = new StackFrameStep(oldCommCareSession.popped);
    }
    this.currentCmd = oldCommCareSession.currentCmd;
    this.currentXmlns = oldCommCareSession.currentXmlns;
    this.frame = new SessionFrame(oldCommCareSession.frame);

    collectedDatums = new OrderedHashtable<String, String>();
    for (Enumeration e = oldCommCareSession.collectedDatums.keys(); e.hasMoreElements(); ) {
        String key = (String)e.nextElement();
        collectedDatums.put(key, oldCommCareSession.collectedDatums.get(key));
    }

    this.frameStack = new Stack<SessionFrame>();
    // NOTE: can't use for/each due to J2ME build issues w/ Stack
    for (int i = 0; i < oldCommCareSession.frameStack.size(); i++) {
        frameStack.addElement(oldCommCareSession.frameStack.elementAt(i));
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:27,代码来源:CommCareSession.java

示例4: syncState

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
private void syncState() {
    this.collectedDatums.clear();
    this.currentCmd = null;
    this.currentXmlns = null;
    this.popped = null;

    for (StackFrameStep step : frame.getSteps()) {
        if (SessionFrame.STATE_DATUM_VAL.equals(step.getType())) {
            String key = step.getId();
            String value = step.getValue();
            if (key != null && value != null) {
                collectedDatums.put(key, value);
            }
        } else if (SessionFrame.STATE_QUERY_REQUEST.equals(step.getType())) {
            collectedDatums.put(step.getId(), step.getValue());
        } else if (SessionFrame.STATE_COMMAND_ID.equals(step.getType())) {
            this.currentCmd = step.getId();
        } else if (SessionFrame.STATE_FORM_XMLNS.equals(step.getType())) {
            this.currentXmlns = step.getId();
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:CommCareSession.java

示例5: parseValue

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
private StackFrameStep parseValue(String type, String datumId) throws XmlPullParserException, IOException, InvalidStructureException {
    //TODO: ... require this to have a value!!!! It's not processing this properly
    String value = parser.getAttributeValue(null, "value");
    boolean valueIsXpath;
    if (value == null) {
        //must have a child
        value = parser.nextText();
        //Can we get here, or would this have caused an exception?
        if (value == null) {
            throw new InvalidStructureException("Stack frame element must define a value expression or have a direct value", parser);
        } else {
            value = value.trim();
        }
        valueIsXpath = false;
    } else {
        //parse out the xpath value to double check for errors
        valueIsXpath = true;
    }
    try {
        return new StackFrameStep(type, datumId, value, valueIsXpath);
    } catch (XPathSyntaxException e) {
        throw new InvalidStructureException("Invalid expression for stack frame step definition: " + value + ".\n" + e.getMessage(), parser);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:25,代码来源:StackFrameStepParser.java

示例6: buildContextTile

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
private Pair<View, TreeReference> buildContextTile(StackFrameStep stepToFrame, AndroidSessionWrapper asw) {
    if (stepToFrame == null) {
        return null;
    }

    //check to make sure we can look up this child
    EntityDatum entityDatum = asw.getSession().findDatumDefinition(stepToFrame.getId());
    if (entityDatum == null || entityDatum.getPersistentDetail() == null) {
        return null;
    }

    //Make sure there is a valid reference to the entity we can build
    Detail detail = asw.getSession().getDetail(entityDatum.getPersistentDetail());

    EvaluationContext ec = asw.getEvaluationContext();

    TreeReference ref = entityDatum.getEntityFromID(ec, stepToFrame.getValue());
    if (ref == null) {
        return null;
    }

    Pair<View, TreeReference> r = buildContextTile(detail, ref, asw);
    r.first.setTag(entityDatum.getInlineDetail());
    return r;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:26,代码来源:BreadcrumbBarFragment.java

示例7: createSessionDescriptor

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
/**
 * Serializes the session into a string which is unique for a
 * given path through the application, and which can be deserialzied
 * back into a live session.
 *
 * NOTE: Currently we rely on this state being semantically unique,
 * but it may change in the future. Rely on the specific format as
 * little as possible.
 */
public static String createSessionDescriptor(CommCareSession session) {
    StringBuilder descriptor = new StringBuilder();
    for (StackFrameStep step : session.getFrame().getSteps()) {
        String type = step.getType();
        if (SessionFrame.STATE_QUERY_REQUEST.equals(type) ||
                SessionFrame.STATE_SYNC_REQUEST.equals(type)) {
            // Skip adding remote server query/sync steps to the descriptor.
            // They are hard to replay (requires serializing query results)
            // and shouldn't be needed for incomplete forms
            continue;
        }
        descriptor.append(type).append(" ");
        if (SessionFrame.STATE_COMMAND_ID.equals(type)) {
            descriptor.append(step.getId()).append(" ");
        } else if (SessionFrame.STATE_DATUM_VAL.equals(type)
                || SessionFrame.STATE_DATUM_COMPUTED.equals(type)) {
            descriptor.append(step.getId()).append(" ").append(step.getValue()).append(" ");
        }
    }
    return descriptor.toString().trim();
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:31,代码来源:SessionDescriptorUtil.java

示例8: CommCareSession

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
/**
 * Copy constructor
 */
public CommCareSession(CommCareSession oldCommCareSession) {
    // NOTE: 'platform' is being copied in a shallow manner
    this.platform = oldCommCareSession.platform;

    if (oldCommCareSession.popped != null) {
        this.popped = new StackFrameStep(oldCommCareSession.popped);
    }
    this.currentCmd = oldCommCareSession.currentCmd;
    this.currentXmlns = oldCommCareSession.currentXmlns;
    this.frame = new SessionFrame(oldCommCareSession.frame);

    collectedDatums = new OrderedHashtable<>();
    for (Enumeration e = oldCommCareSession.collectedDatums.keys(); e.hasMoreElements(); ) {
        String key = (String)e.nextElement();
        collectedDatums.put(key, oldCommCareSession.collectedDatums.get(key));
    }

    this.frameStack = new Stack<>();
    // NOTE: can't use for/each due to J2ME build issues w/ Stack
    for (int i = 0; i < oldCommCareSession.frameStack.size(); i++) {
        frameStack.addElement(oldCommCareSession.frameStack.elementAt(i));
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:27,代码来源:CommCareSession.java

示例9: guessUnknownType

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
/**
 * When StackFrameSteps are parsed, those that are "datum" operations will be marked as type
 * "unknown". When we encounter a StackFrameStep of unknown type at runtime, we need to
 * determine whether it should be interpreted as STATE_DATUM_COMPUTED, STATE_COMMAND_ID,
 * or STATE_DATUM_VAL This primarily affects the behavior of stepBack().
 *
 * The logic being employed is: If there is a previous step on the stack whose entries would
 * have added this command, interpret it as a command. If there is an EntityDatum that
 * was have added this as an entity selection, interpret this as a datum_val. O
 * Otherwise, interpret it as a computed datum.
 */
private String guessUnknownType(StackFrameStep popped) {
    String poppedId = popped.getId();
    for (StackFrameStep stackFrameStep : frame.getSteps()) {
        String commandId = stackFrameStep.getId();
        Vector<Entry> entries = getEntriesForCommand(commandId);
        for (Entry entry : entries) {
            String childCommand = entry.getCommandId();
            if (childCommand.equals(poppedId)) {
                return SessionFrame.STATE_COMMAND_ID;
            }
            Vector<SessionDatum> data = entry.getSessionDataReqs();
            for (SessionDatum datum : data) {
                if (datum instanceof EntityDatum &&
                        datum.getDataId().equals(poppedId)) {
                    return SessionFrame.STATE_DATUM_VAL;
                }
            }
        }
    }
    return SessionFrame.STATE_DATUM_COMPUTED;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:33,代码来源:CommCareSession.java

示例10: syncState

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
public void syncState() {
    this.collectedDatums.clear();
    this.currentCmd = null;
    this.currentXmlns = null;
    this.popped = null;

    for (StackFrameStep step : frame.getSteps()) {
        if (SessionFrame.STATE_DATUM_VAL.equals(step.getType()) ||
                SessionFrame.STATE_DATUM_COMPUTED.equals(step.getType()) ||
                SessionFrame.STATE_UNKNOWN.equals(step.getType()) &&
                        (guessUnknownType(step).equals(SessionFrame.STATE_DATUM_COMPUTED)
                        || guessUnknownType(step).equals(SessionFrame.STATE_DATUM_VAL))) {
            String key = step.getId();
            String value = step.getValue();
            if (key != null && value != null) {
                collectedDatums.put(key, value);
            }
        } else if (SessionFrame.STATE_QUERY_REQUEST.equals(step.getType())) {
            collectedDatums.put(step.getId(), step.getValue());
        } else if (SessionFrame.STATE_COMMAND_ID.equals(step.getType())) {
            this.currentCmd = step.getId();
        } else if (SessionFrame.STATE_FORM_XMLNS.equals(step.getType())) {
            this.currentXmlns = step.getId();
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:27,代码来源:CommCareSession.java

示例11: parse

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
@Override
public StackFrameStep parse() throws InvalidStructureException, IOException, XmlPullParserException {
    String operation = parser.getName();

    switch (operation) {
        case "datum":
            String id = parser.getAttributeValue(null, "id");
            return parseValue(SessionFrame.STATE_UNKNOWN, id);
        case "rewind":
            return parseValue(SessionFrame.STATE_REWIND, null);
        case "mark":
            return parseValue(SessionFrame.STATE_MARK, null);
        case "command":
            return parseValue(SessionFrame.STATE_COMMAND_ID, null);
        default:
            throw new InvalidStructureException("<" + operation + "> is not a valid stack frame element!", this.parser);
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:19,代码来源:StackFrameStepParser.java

示例12: printStack

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
private void printStack(SessionWrapper mSession) {
    SessionFrame frame = mSession.getFrame();
    System.out.println("Live Frame" + (frame.getFrameId() == null ? "" : " [" + frame.getFrameId() + "]"));
    System.out.println("----------");
    for (StackFrameStep step : frame.getSteps()) {
        if (step.getType().equals(SessionFrame.STATE_COMMAND_ID)) {
            System.out.println("COMMAND: " + step.getId());
        } else {
            System.out.println("DATUM : " + step.getId() + " - " + step.getValue());
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:13,代码来源:ApplicationHost.java

示例13: getHeaderTitles

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
public String[] getHeaderTitles() {
    Hashtable<String, String> menus = new Hashtable<String, String>();

    for (Suite s : platform.getInstalledSuites()) {
        for (Menu m : s.getMenus()) {
            menus.put(m.getId(), m.getName().evaluate());
        }
    }

    Vector<StackFrameStep> steps = frame.getSteps();
    String[] returnVal = new String[steps.size()];

    Hashtable<String, Entry> entries = platform.getMenuMap();
    int i = 0;
    for (StackFrameStep step : steps) {
        if (SessionFrame.STATE_COMMAND_ID.equals(step.getType())) {
            //Menu or form.
            if (menus.containsKey(step.getId())) {
                returnVal[i] = menus.get(step.getId());
            } else if (entries.containsKey(step.getId())) {
                returnVal[i] = entries.get(step.getId()).getText().evaluate();
            }
        } else if (SessionFrame.STATE_DATUM_VAL.equals(step.getType())) {
            //TODO: Grab the name of the case
        } else if (SessionFrame.STATE_DATUM_COMPUTED.equals(step.getType())) {
            //Nothing to do here
        }

        if (returnVal[i] != null) {
            //Menus contain a potential argument listing where that value is on the screen,
            //clear it out if it exists
            returnVal[i] = Localizer.processArguments(returnVal[i], new String[]{""}).trim();
        }

        ++i;
    }

    return returnVal;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:40,代码来源:CommCareSession.java

示例14: setQueryDatum

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
/**
 * Set a (xml) data instance as the result to a session query datum.
 * The instance is available in session's evaluation context until the corresponding query frame is removed
 */
public void setQueryDatum(ExternalDataInstance queryResultInstance) {
    SessionDatum datum = getNeededDatum();
    if (datum instanceof RemoteQueryDatum) {
        StackFrameStep step =
                new StackFrameStep(SessionFrame.STATE_QUERY_REQUEST,
                        datum.getDataId(), datum.getValue(), queryResultInstance);
        frame.pushStep(step);
        syncState();
    } else {
        throw new RuntimeException("Trying to set query successful when one isn't needed.");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:CommCareSession.java

示例15: addInstancesFromFrame

import org.commcare.suite.model.StackFrameStep; //导入依赖的package包/类
private void addInstancesFromFrame(Hashtable<String, DataInstance> instanceMap) {
    for (StackFrameStep step : frame.getSteps()) {
        if (step.hasXmlInstance()) {
            instanceMap.put(step.getId(), step.getXmlInstance());
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:8,代码来源:CommCareSession.java


注:本文中的org.commcare.suite.model.StackFrameStep类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。