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


Java InvalidReferenceException类代码示例

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


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

示例1: queueError

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
private void queueError(String title, String msg, String image, String audio) {
        alertTitle = title;
        this.msg = msg;

        //Try to load the image
        this.alertImage = null;
        if(image != null) {
            try {
                Reference ref = ReferenceManager._().DeriveReference(image);
                InputStream in = ref.getStream();
                this.alertImage = Image.createImage(in);
                in.close();
            } catch (IOException e) {
                Logger.exception(e);
            } catch(InvalidReferenceException ire) {
                Logger.exception(ire);
            }
        }

        //Try to load the image
        this.audioURI = audio;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:Chatterbox.java

示例2: addDerivedLocation

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
/**
 * Derive a reference from the given location and context; adding it to the
 * vector of references.
 *
 * @param location Contains a reference to a resource.
 * @param context  Provides context for any relative reference accessors.
 *                 Can be null.
 * @param ret      Add derived reference of location to this Vector.
 */
private static void addDerivedLocation(ResourceLocation location,
                                       Reference context,
                                       Vector<Reference> ret) {
    try {
        final Reference derivedRef;
        if (context == null) {
            derivedRef =
                    ReferenceManager._().DeriveReference(location.getLocation());
        } else {
            // contextualize the location ref in terms of the multiple refs
            // pointing to different locations for the parent resource
            derivedRef =
                    ReferenceManager._().DeriveReference(location.getLocation(),
                            context);
        }
        ret.addElement(derivedRef);
    } catch (InvalidReferenceException e) {
        e.printStackTrace();
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:30,代码来源:ResourceTable.java

示例3: getAudioFilename

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
/**
 * Gets the audio source filename from the URI.
 *
 * @return Filepath of audio source stored in local URI. Returns an empty
 * string if no audio source is found.
 */
private String getAudioFilename(String URI) throws IOException {
    if (URI == null) {
        throw new IOException("No audio file was specified");
    }

    String audioFilename;
    try {
        audioFilename =
                ReferenceManager.instance().DeriveReference(URI).getLocalURI();
    } catch (InvalidReferenceException e) {
        throw new IOException(e);
    }

    File audioFile = new File(audioFilename);
    if (!audioFile.exists()) {
        throw new IOException("File missing: " + audioFilename);
    }
    return audioFilename;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:26,代码来源:MediaEntity.java

示例4: setReadyToInstall

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
private void setReadyToInstall(String reference) {
    incomingRef = reference;
    this.uiState = UiState.READY_TO_INSTALL;

    try {
        ReferenceManager.instance().DeriveReference(incomingRef);
        if (lastInstallMode == INSTALL_MODE_OFFLINE || lastInstallMode == INSTALL_MODE_FROM_LIST) {
            onStartInstallClicked();
        } else {
            uiStateScreenTransition();
        }
    } catch (InvalidReferenceException ire) {
        incomingRef = null;
        fail(Localization.get("install.bad.ref"));
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:17,代码来源:CommCareSetupActivity.java

示例5: performLocalRestore

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
public <I extends CommCareActivity & PullTaskResultReceiver> void performLocalRestore(
        I context,
        String username,
        String password) {

    try {
        ReferenceManager.instance().DeriveReference(
                SingleAppInstallation.LOCAL_RESTORE_REFERENCE).getStream();
    } catch (InvalidReferenceException | IOException e) {
        throw new RuntimeException("Local restore file missing");
    }

    LocalReferencePullResponseFactory.setRequestPayloads(new String[]{SingleAppInstallation.LOCAL_RESTORE_REFERENCE});
    syncData(context, false, false, "fake-server-that-is-never-used", username, password, "unused",
            LocalReferencePullResponseFactory.INSTANCE, true);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:17,代码来源:FormAndDataSyncer.java

示例6: onItemLongClick

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
        int position, long id) {
    MenuDisplayable value = (MenuDisplayable)parent.getAdapter().getItem(position);
    String audioURI = value.getAudioURI();
    MediaPlayer mp = new MediaPlayer();
    String audioFilename;
    if (audioURI != null && !audioURI.equals("")) {
        try {
            audioFilename = ReferenceManager.instance().DeriveReference(audioURI).getLocalURI();
            mp.setDataSource(audioFilename);
            mp.prepare();
            mp.start();
        } catch (IOException | IllegalStateException
                | InvalidReferenceException e) {
            e.printStackTrace();
        }
    }
    return false;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:21,代码来源:MenuGrid.java

示例7: initializeFileRoots

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
private void initializeFileRoots() {
    synchronized (lock) {
        String root = storageRoot();
        fileRoot = new JavaFileRoot(root);

        String testFileRoot = "jr://file/mytest.file";
        // Assertion: There should be _no_ other file roots when we initialize
        try {
            String testFilePath = ReferenceManager.instance().DeriveReference(testFileRoot).getLocalURI();
            String message = "Cannot setup sandbox. An Existing file root is set up, which directs to: " + testFilePath;
            Logger.log(LogTypes.TYPE_ERROR_DESIGN, message);
            throw new IllegalStateException(message);
        } catch (InvalidReferenceException ire) {
            // Expected.
        }


        ReferenceManager.instance().addReferenceFactory(fileRoot);

        // Double check that things point to the right place?
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:23,代码来源:CommCareApp.java

示例8: setupAudioButton

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
private void setupAudioButton(int rowId, AudioPlaybackButton audioPlaybackButton, MenuDisplayable menuDisplayable) {
    if (audioPlaybackButton != null) {
        final String audioURI = menuDisplayable.getAudioURI();
        String audioFilename = "";
        if (audioURI != null && !audioURI.equals("")) {
            try {
                audioFilename = ReferenceManager.instance().DeriveReference(audioURI).getLocalURI();
            } catch (InvalidReferenceException e) {
                Log.e("AVTLayout", "Invalid reference exception");
                e.printStackTrace();
            }
        }

        File audioFile = new File(audioFilename);
        // First set up the audio button
        ViewId viewId = ViewId.buildListViewId(rowId);
        if (!"".equals(audioFilename) && audioFile.exists()) {
            audioPlaybackButton.modifyButtonForNewView(viewId, audioURI, true);
        } else {
            audioPlaybackButton.modifyButtonForNewView(viewId, audioURI, false);
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:24,代码来源:MenuAdapter.java

示例9: removeAttachment

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
@Override
protected void removeAttachment(Case caseForBlock, String attachmentName) {
    if (!processAttachments) {
        return;
    }

    //TODO: All of this code should really be somewhere else, too, since we also need to remove attachments on
    //purge.
    String source = caseForBlock.getAttachmentSource(attachmentName);

    //TODO: Handle remote reference download?
    if (source == null) {
        return;
    }

    //Handle these cases better later.
    try {
        ReferenceManager.instance().DeriveReference(source).remove();
    } catch (InvalidReferenceException | IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:23,代码来源:AndroidCaseXmlParser.java

示例10: updateFilePath

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
/**
 * At some point hopefully soon we're not going to be shuffling our xforms around like crazy, so updates will mostly involve
 * just changing where the provider points.
 */
private boolean updateFilePath() {
    String localRawUri;
    try {
        localRawUri = ReferenceManager.instance().DeriveReference(this.localLocation).getLocalURI();
    } catch (InvalidReferenceException e) {
        Logger.log(LogTypes.TYPE_RESOURCES, "Installed resource wasn't able to be derived from " + localLocation);
        return false;
    }

    //We're maintaining this whole Content setup now, so we've goota update things when we move them.
    ContentResolver cr = CommCareApplication.instance().getContentResolver();

    ContentValues cv = new ContentValues();
    cv.put(FormsProviderAPI.FormsColumns.FORM_FILE_PATH, new File(localRawUri).getAbsolutePath());

    //Update the form file path
    int updatedRows = cr.update(Uri.parse(this.contentUri), cv, null, null);
    if (updatedRows > 1) {
        throw new RuntimeException("Bad URI stored for xforms installer: " + this.contentUri);
    }
    return updatedRows != 0;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:27,代码来源:XFormAndroidInstaller.java

示例11: upgrade

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
@Override
public boolean upgrade(Resource r, AndroidCommCarePlatform platform) {
    try {
        //TODO: This process is silly! Just put the files somewhere as a resource with a unique GUID and stop shuffling them around!

        //use same filename as before
        String filepart = localLocation.substring(localLocation.lastIndexOf("/"));

        //Get final destination
        String finalLocation = localDestination + "/" + filepart;

        if (!FileSystemUtils.moveFrom(localLocation, finalLocation, false)) {
            return false;
        }

        localLocation = finalLocation;
        return true;
    } catch (InvalidReferenceException e) {
        return false;
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:22,代码来源:FileSystemInstaller.java

示例12: initialize

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
@Override
public boolean initialize(AndroidCommCarePlatform platform, boolean isUpgrade) {
    try {

        Reference local = ReferenceManager.instance().DeriveReference(localLocation);

        ProfileParser parser = new ProfileParser(local.getStream(), platform, platform.getGlobalResourceTable(), null,
                Resource.RESOURCE_STATUS_INSTALLED, false);

        Profile p = parser.parse();
        platform.setProfile(p);

        return true;
    } catch (UnfullfilledRequirementsException | XmlPullParserException
            | InvalidStructureException | IOException
            | InvalidReferenceException e) {
        e.printStackTrace();
    }

    return false;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:22,代码来源:ProfileAndroidInstaller.java

示例13: addDerivedLocation

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
/**
 * Derive a reference from the given location and context; adding it to the
 * vector of references.
 *
 * @param location Contains a reference to a resource.
 * @param context  Provides context for any relative reference accessors.
 *                 Can be null.
 * @param ret      Add derived reference of location to this Vector.
 */
private static void addDerivedLocation(ResourceLocation location,
                                       Reference context,
                                       Vector<Reference> ret) {
    try {
        final Reference derivedRef;
        if (context == null) {
            derivedRef =
                    ReferenceManager.instance().DeriveReference(location.getLocation());
        } else {
            // contextualize the location ref in terms of the multiple refs
            // pointing to different locations for the parent resource
            derivedRef =
                    ReferenceManager.instance().DeriveReference(location.getLocation(),
                            context);
        }
        ret.addElement(derivedRef);
    } catch (InvalidReferenceException e) {
        e.printStackTrace();
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:30,代码来源:ResourceTable.java

示例14: readExternal

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    referenceName = ExtUtil.readString(in);
    try {
        ref = ReferenceManager._().DeriveReference(referenceName);
    } catch (InvalidReferenceException e) {
        throw new DeserializationException("Unsupported local reference " + e.getMessage());
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:9,代码来源:ReferenceDataPointer.java

示例15: setupVideo

import org.javarosa.core.reference.InvalidReferenceException; //导入依赖的package包/类
private void setupVideo(String textField) {
    String localLocation = null;
    try {
        localLocation = ReferenceManager.instance().DeriveReference(textField).getLocalURI();
        if (localLocation.startsWith("/")) {
            //TODO: This should likely actually be happening with the getLocalURI _anyway_.
            localLocation = FileUtil.getGlobalStringUri(localLocation);
        }
    } catch (InvalidReferenceException ire) {
        Logger.log(LogTypes.TYPE_ERROR_CONFIG_STRUCTURE, "Couldn't understand video reference format: " + localLocation + ". Error: " + ire.getMessage());
    }

    final String location = localLocation;

    videoButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            listener.playVideo(location);
        }

    });

    if (location == null) {
        videoButton.setEnabled(false);
        Logger.log(LogTypes.TYPE_ERROR_CONFIG_STRUCTURE, "No local video reference available for ref: " + textField);
    } else {
        videoButton.setEnabled(true);
    }

    updateCurrentView(VIDEO, videoButton);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:33,代码来源:EntityDetailView.java


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