org.openide.cookies.LineCookie Java Examples

The following examples show how to use org.openide.cookies.LineCookie. 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: MiscEditorUtil.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static Line getLine(final FileObject fileObject, final int lineNumber) {
    if (fileObject != null) {
        LineCookie lineCookie = MiscEditorUtil.getLineCookie(fileObject);
        if (lineCookie != null) {
            Line.Set ls = lineCookie.getLineSet();
            if (ls != null) {
                try {
                    return ls.getCurrent(lineNumber - 1);
                } catch (IndexOutOfBoundsException ioob) {
                    List<? extends Line> lines = ls.getLines();
                    if (lines.size() > 0) {
                        return lines.get(lines.size() - 1);
                    } else {
                        return null;
                    }
                }
            }
        }
    }
    return null;
}
 
Example #2
Source File: Utils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Line getLine(int line, String remoteFileName, SessionId id) {
    DataObject dataObject = Utils.getDataObjectByRemote(id, remoteFileName);
    if (dataObject == null) {
        return null;
    }
    LineCookie lineCookie = (LineCookie) dataObject.getLookup().lookup(LineCookie.class);
    if (lineCookie == null) {
        return null;
    }
    Line.Set set = lineCookie.getLineSet();
    if (set == null) {
        return null;
    }
    try {
        return set.getCurrent(line - 1);
    } catch (IndexOutOfBoundsException | IllegalArgumentException e) {
        Logger.getLogger(Utils.class.getName()).log(Level.FINE, e.getMessage(), e);
    }
    return null;
}
 
Example #3
Source File: Nodes.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages("ERR_CannotOpen=Cannot open target file")
static void openErrorDescription(AnalyzerFactory analyzer, ErrorDescription ed) throws IndexOutOfBoundsException {
    try {
        DataObject od = DataObject.find(ed.getFile());
        LineCookie lc = od.getLookup().lookup(LineCookie.class);

        if (lc != null) {
            Line line = lc.getLineSet().getCurrent(ed.getRange().getBegin().getLine());

            line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
            analyzer.warningOpened(ed);
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(Exceptions.attachLocalizedMessage(Exceptions.attachSeverity(ex, Level.WARNING), Bundle.ERR_CannotOpen()));
    }
}
 
Example #4
Source File: XMLJ2eeDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public XMLJ2eeDataObject(FileObject pf, MultiFileLoader loader)
    throws org.openide.loaders.DataObjectExistsException {
    super(pf,loader);
    
    CookieSet cs = getCookieSet();
    cs.add(XMLJ2eeEditorSupport.class, this);
    cs.add(EditCookie.class, this);
    cs.add(EditorCookie.class, this);
    cs.add(LineCookie.class, this);
    cs.add(PrintCookie.class, this);
    cs.add(CloseCookie.class, this);
    // added CheckXMLCookie
    InputSource in = DataObjectAdapters.inputSource(this);
    CheckXMLCookie checkCookie = new CheckXMLSupport(in);
    cs.add(checkCookie);
}
 
Example #5
Source File: GsfDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public GsfDataObject(FileObject pf, MultiFileLoader loader, Language language) throws DataObjectExistsException {
    super(pf, loader);

    // If the user creates a file with a filename where we can't figure out the language
    // (e.g. the PHP New File wizard doesn't enforce a file extension, so if you create
    // a file named "pie.class" (issue 124044) the data loader doesn't know which language
    // to associate this with since it isn't a GSF file extension or mimetype). However
    // during template creation we know the language anyway so we can use it. On subsequent
    // IDE restarts the file won't be recognized so the user will have to rename or
    // add a new file extension to file type mapping.
    if (language == null) {
        language = templateLanguage;
    }
    this.language = language;
    getCookieSet().add(new Class[]{
            GenericEditorSupport.class, // NOI18N
            SaveAsCapable.class, Openable.class, EditorCookie.Observable.class, 
            PrintCookie.class, CloseCookie.class, Editable.class, LineCookie.class,
            DataEditorSupport.class, CloneableEditorSupport.class,
            CloneableOpenSupport.class
        }, new EditorSupportFactory());
}
 
Example #6
Source File: GsfDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public <T extends Cookie> T createCookie(Class<T> klass) {
        if (
        klass.isAssignableFrom(DataEditorSupport.class) || 
        DataEditorSupport.class.isAssignableFrom(klass) || 
        klass.isAssignableFrom(Openable.class) || 
        klass.isAssignableFrom(Editable.class) || 
        klass.isAssignableFrom(EditorCookie.Observable.class) || 
        klass.isAssignableFrom(PrintCookie.class) || 
        klass.isAssignableFrom(CloseCookie.class) || 
        klass.isAssignableFrom(LineCookie.class)
    ) {
        return klass.cast(createEditorSupport());
    }
    return null;
}
 
Example #7
Source File: Utils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void open(String targetUri, Range targetRange) {
    try {
        URI target = URI.create(targetUri);
        FileObject targetFile = URLMapper.findFileObject(target.toURL());

        if (targetFile != null) {
            LineCookie lc = targetFile.getLookup().lookup(LineCookie.class);

            //TODO: expecting lc != null!

            Line line = lc.getLineSet().getCurrent(targetRange.getStart().getLine());

            SwingUtilities.invokeLater(() ->
                line.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, targetRange.getStart().getCharacter())
            );
        } else {
            //TODO: beep
        }
    } catch (MalformedURLException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
Example #8
Source File: EditorUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static Line getLine(V8Debugger dbg, FileObject fo, int line, int column) {
    SourceMapsTranslator smtr = dbg.getScriptsHandler().getSourceMapsTranslator();
    if (smtr != null) {
        if (column < 0) {
            column = 0; // If column not defined, set it to zero
        } else if (line == 0) {
            column -= dbg.getScriptsHandler().getScriptFirstLineColumnShift(fo);
        }
        SourceMapsTranslator.Location loc = new SourceMapsTranslator.Location(fo, line, column);
        loc = smtr.getSourceLocation(loc);
        fo = loc.getFile();
        line = loc.getLine();
    }
    LineCookie lineCookie = fo.getLookup().lookup(LineCookie.class);
    try {
        return lineCookie.getLineSet().getCurrent(line);
    } catch (IndexOutOfBoundsException ioob) {
        List<? extends Line> lines = lineCookie.getLineSet().getLines();
        if (lines.size() > 0) {
            return lines.get(lines.size() - 1);
        } else {
            return null;
        }
    }
}
 
Example #9
Source File: OpenTaskAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean canOpenTask() {
    if( null != Accessor.getDefaultAction( task ) )
        return true;

    URL url = Accessor.getURL( task );
    if( null != url )
        return true;

    FileObject fo = Accessor.getFile(task);
    if( null == fo )
        return false;

    DataObject dob = null;
    try {
        dob = DataObject.find( fo );
    } catch( DataObjectNotFoundException donfE ) {
        return false;
    }
    if( Accessor.getLine( task ) > 0 ) {
        return null != dob.getCookie( LineCookie.class );
    }

    return null != dob.getCookie( OpenCookie.class )
        || null != dob.getCookie( EditCookie.class )
        || null != dob.getCookie( ViewCookie.class );
}
 
Example #10
Source File: WatchAnnotationProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Line getLine (FileObject file, int lineNumber) {
    if (file == null) return null;
    DataObject dataObject;
    try {
        dataObject = DataObject.find (file);
    } catch (DataObjectNotFoundException ex) {
        return null;
    }
    if (dataObject == null) return null;
    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    if (lineCookie == null) return null;
    Line.Set ls = lineCookie.getLineSet ();
    if (ls == null) return null;
    try {
        return ls.getCurrent (lineNumber);
    } catch (IndexOutOfBoundsException | IllegalArgumentException e) {
    }
    return null;
}
 
Example #11
Source File: JSUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static Line getLine(final FileObject fileObject, final int lineNumber) {
    if (fileObject != null) {
        LineCookie lineCookie = JSUtils.getLineCookie(fileObject);
        if (lineCookie != null) {
            Line.Set ls = lineCookie.getLineSet();
            if (ls != null) {
                try {
                    return ls.getCurrent(lineNumber - 1);
                } catch (IndexOutOfBoundsException ioob) {
                    List<? extends Line> lines = ls.getLines();
                    if (lines.size() > 0) {
                        return lines.get(lines.size() - 1);
                    } else {
                        return null;
                    }
                }
            }
        }
    }
    return null;
}
 
Example #12
Source File: EditorLineHandlerFactoryImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public EditorLineHandler get(FileObject fo, int lineNumber) {
    try {
        DataObject dobj = DataObject.find(fo);
        LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
        if (lineCookie == null) {
            return null;
        }
        try {
            Line line = lineCookie.getLineSet().getCurrent(lineNumber - 1);
            return new LineDelegate(line);
        } catch (IndexOutOfBoundsException ioobex) {
            // The line is gone.
            return null;
        }
    } catch (DataObjectNotFoundException ex) {
        return null;
    }
}
 
Example #13
Source File: TextDetail.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void prepareLine() {
    if (dobj == null || !dobj.isValid()) {
        lineObj = null;
    } else if (lineObj == null) { // try to get Line from DataObject
        LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
        if (lineCookie != null) {
            Line.Set lineSet = lineCookie.getLineSet();
            try {
                lineObj = lineSet.getOriginal(line - 1);
            } catch (IndexOutOfBoundsException ioobex) {
                // The line doesn't exist - go to the last line
                lineObj = lineSet.getOriginal(findMaxLine(lineSet));
                column = markLength = 0;
            }
        }
    }
}
 
Example #14
Source File: ModelUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Opens a pom file at location defined in InputLocation parameter
 * @since 2.77
 * @param location 
 */
public static void openAtSource(InputLocation location) {
    InputSource source = location.getSource();
    if (source != null && source.getLocation() != null) {
        FileObject fobj = FileUtilities.convertStringToFileObject(source.getLocation());
        if (fobj != null) {
            try {
                DataObject dobj = DataObject.find(NodeUtils.readOnlyLocalRepositoryFile(fobj));
                EditCookie edit = dobj.getLookup().lookup(EditCookie.class);
                if (edit != null) {
                    edit.edit();
                }
                LineCookie lc = dobj.getLookup().lookup(LineCookie.class);
                lc.getLineSet().getOriginal(location.getLineNumber() - 1).show(Line.ShowOpenType.REUSE, Line.ShowVisibilityType.FOCUS, location.getColumnNumber() - 1);
            } catch (DataObjectNotFoundException ex) {
                LOG.log(Level.FINE, "dataobject not found", ex);
            }
        }
    }
}
 
Example #15
Source File: HyperlinkProviderImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void openAtSource(InputLocation location) {
    InputSource source = location.getSource();
    if (source != null && source.getLocation() != null) {
        FileObject fobj = FileUtilities.convertStringToFileObject(source.getLocation());
        if (fobj != null) {
            try {
                DataObject dobj = DataObject.find(NodeUtils.readOnlyLocalRepositoryFile(fobj));
                EditCookie edit = dobj.getLookup().lookup(EditCookie.class);
                if (edit != null) {
                    edit.edit();
                }
                LineCookie lc = dobj.getLookup().lookup(LineCookie.class);
                lc.getLineSet().getOriginal(location.getLineNumber() - 1).show(Line.ShowOpenType.REUSE, Line.ShowVisibilityType.FOCUS, location.getColumnNumber() - 1);
            } catch (DataObjectNotFoundException ex) {
                LOG.log(Level.FINE, "dataobject not found", ex);
            }
        }
    }
}
 
Example #16
Source File: SpringXMLConfigEditorUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static boolean openFileAtOffset(DataObject dataObject, int offset) throws IOException {
    EditorCookie ec = dataObject.getCookie(EditorCookie.class);
    LineCookie lc = dataObject.getCookie(LineCookie.class);
    if (ec != null && lc != null) {
        StyledDocument doc = ec.openDocument();
        if (doc != null) {
            int lineNumber = NbDocument.findLineNumber(doc, offset);
            if (lineNumber != -1) {
                Line line = lc.getLineSet().getCurrent(lineNumber);
                if (line != null) {
                    int lineOffset = NbDocument.findLineOffset(doc, lineNumber);
                    int column = offset - lineOffset;
                    line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example #17
Source File: LineTranslations.java    From netbeans with Apache License 2.0 6 votes vote down vote up
Line.Set getLineSet (String url, Object timeStamp) {
    DataObject dataObject = getDataObject (url);
    if (dataObject == null) {
        return null;
    }
    
    if (timeStamp != null) {
        // get original
        synchronized (this) {
            Registry registry = timeStampToRegistry.get (timeStamp);
            if (registry != null) {
                Line.Set ls = registry.getLineSet (dataObject);
                if (ls != null) {
                    return ls;
                }
            }
        }
    }
    
    // get current
    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    if (lineCookie == null) {
        return null;
    }
    return lineCookie.getLineSet ();
}
 
Example #18
Source File: NbEditorUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Get the line object from the given position.
 * @param doc document for which the line is being retrieved
 * @param offset position in the document
 * @param original whether to retrieve the original line (true) before
 *   the modifications were done or the current line (false)
 * @return the line object
 */
public static Line getLine(Document doc, int offset, boolean original) {
    DataObject dob = getDataObject(doc);
    if (dob != null) {
        LineCookie lc = (LineCookie)dob.getCookie(LineCookie.class);
        if (lc != null) {
            Line.Set lineSet = lc.getLineSet();
            if (lineSet != null) {
                Element lineRoot = (doc instanceof AbstractDocument)
                    ? ((AbstractDocument)doc).getParagraphElement(0).getParentElement()
                    : doc.getDefaultRootElement();
                int lineIndex = lineRoot.getElementIndex(offset);
                return original
                       ? lineSet.getOriginal(lineIndex)
                       : lineSet.getCurrent(lineIndex);
            }
        }
    }
    return null;
}
 
Example #19
Source File: NbEditorUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Get the line object from the given position.
* @param doc document for which the line is being retrieved
* @param offset position in the document
* @param original whether to retrieve the original line (true) before
*   the modifications were done or the current line (false)
* @return the line object
* @deprecated Replaced by more generic method having {@link javax.swing.text.Document} parameter.
*/
public static Line getLine(BaseDocument doc, int offset, boolean original) {
    DataObject dob = getDataObject(doc);
    if (dob != null) {
        LineCookie lc = (LineCookie)dob.getCookie(LineCookie.class);
        if (lc != null) {
            Line.Set lineSet = lc.getLineSet();
            if (lineSet != null) {
                try {
                    int lineOffset = Utilities.getLineOffset(doc, offset);
                    return original
                           ? lineSet.getOriginal(lineOffset)
                           : lineSet.getCurrent(lineOffset);
                } catch (BadLocationException e) {
                }

            }
        }
    }
    return null;
}
 
Example #20
Source File: JShellDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public JShellDataObject(FileObject fo, MultiFileLoader loader) throws DataObjectExistsException {
    super(fo, loader);
    CookieSet cks = getCookieSet();
    cks.add(new Class[] {
            OpenCookie.class,
            EditorCookie.Observable.class,
            CloseCookie.class,
            LineCookie.class,
            SimpleES.class,
        }, new CookieSet.Factory() {
        private CloneableEditorSupport supp;
        public <T extends Node.Cookie> T createCookie(Class<T> klass) {
            if (supp != null) {
                return klass.cast(supp);
            }
            return klass.cast(
                    /*
                    supp = DataEditorSupport.create(JShellDataObject.this, 
                            getPrimaryEntry(), getCookieSet(), 
                            () -> createPane())
                    );*/
                    supp = new SimpleES(JShellDataObject.this, getPrimaryEntry())
            );
        }
    });
}
 
Example #21
Source File: LineDelegate.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void setLineNumber(int lineNumber) {
    lineNumber--; // Line works with 0-based lines.
    if (line.getLineNumber() == lineNumber) {
        return ;
    }
    LineCookie lineCookie = line.getLookup().lookup(LineCookie.class);
    Line.Set lineSet = lineCookie.getLineSet();
    List<? extends Line> lines = lineSet.getLines();
    if (lines.size() > 0) {
        int lastLineNumber = lines.get(lines.size() - 1).getLineNumber();
        if (lineNumber > lastLineNumber) {
            lineNumber = lastLineNumber;
        }
    }
    Line cline;
    try {
        cline = lineSet.getCurrent(lineNumber);
    } catch (IndexOutOfBoundsException ioobex) {
        cline = lineSet.getCurrent(0);
    }
    setLine(cline);
}
 
Example #22
Source File: ActionProviderImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void open(FileObject file, int line) {
    LineCookie lc = file.getLookup().lookup(LineCookie.class);

    if (lc != null) {
        Line.Set ls = lc.getLineSet();
        try {
            Line originalLine = ls.getOriginal(line);
            originalLine.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
        } catch (IndexOutOfBoundsException ex) {
            LOG.log(Level.FINE, null, ex);
        }
    }

    OpenCookie oc = file.getLookup().lookup(OpenCookie.class);

    if (oc != null) {
        oc.open();
    }
}
 
Example #23
Source File: LineDelegate.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public FileObject getFileObject() {
    if (line instanceof FutureLine) {
        URL url = getURL();
        FileObject fo = URLMapper.findFileObject(url);
        if (fo != null) {
            try {
                DataObject dobj = DataObject.find(fo);
                LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
                if (lineCookie == null) {
                    return null;
                }
                Line l = lineCookie.getLineSet().getCurrent(getLineNumber() - 1);
                setLine(l);
            } catch (DataObjectNotFoundException ex) {
            }
        }
        return fo;
    } else {
        return line.getLookup().lookup(FileObject.class);
    }
}
 
Example #24
Source File: FileDescription.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void edit(@NonNull final DataObject dobj, final int lineNo) {
    // if linenumber is given then try to open file at this line
    // code taken from org.netbeans.modules.java.stackanalyzer.StackLineAnalyser.Link.show()
    LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
    if (lineCookie == null) {
        //Workaround of non functional org.openide.util.Lookup class hierarchy cache.
        lineCookie = dobj.getLookup().lookup(EditorCookie.class);
    }
    if (lineCookie != null && lineNo != -1) {
        try {
            final Line l = lineCookie.getLineSet().getCurrent(lineNo - 1);
            if (l != null) {
                // open file at the given line
                l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, -1);
                return;
            }
        } catch (IndexOutOfBoundsException oob) {
            LOG.log(Level.FINE, "Line no more exists.", oob);   //NOI18N
        }
    }
    Editable editable = dobj.getLookup().lookup(Editable.class);
    if (editable == null) {
        //Workaround of non functional org.openide.util.Lookup class hierarchy cache.
        editable = dobj.getLookup().lookup(EditCookie.class);
    }
    if (editable != null) {
        editable.edit();
        return;
    }
    open(dobj);
}
 
Example #25
Source File: OpenTaskAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean openAt( LineCookie lineCookie, int lineNo ) {
    Line.Set lines = lineCookie.getLineSet();
    try {
        Line line = lines.getCurrent( lineNo );
        if( null == line )
            line = lines.getCurrent( 0 );
        if( null != line ) {
            line.show( ShowOpenType.OPEN , ShowVisibilityType.FOCUS);
            return true;
        }
    } catch( IndexOutOfBoundsException e ) {
        //probably the document has been modified but not saved yet
    }
    return false;
}
 
Example #26
Source File: OpenInEditorAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void doWork() {
    if (url == null) {
        return;
    }
    try {
        FileObject fo;
        if (url.getProtocol().equals("file")) { //NOI18N
            fo = FileUtil.toFileObject(new File(url.getPath()));
        } else {
            fo = URLMapper.findFileObject(url); //NOI18N
        }
        DataObject dobj = DataObject.find(fo);
        EditorCookie ed = dobj.getLookup().lookup(EditorCookie.class);
        if (ed != null && fo == dobj.getPrimaryFile()) {
            if (lineNumber == -1) {
                ed.open();
            } else {
                lc = dobj.getLookup().lookup(LineCookie.class);
                SwingUtilities.invokeLater(this);
            }
        } else {
            Toolkit.getDefaultToolkit().beep();
        }
    } catch (Exception ex) {
        // ignore
    }
}
 
Example #27
Source File: SQLExecutionLoggerImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "# {0} - the name of the executed SQL file",
    "LBL_SQLFileExecution={0} execution"})
public SQLExecutionLoggerImpl(String displayName, LineCookie lineCookie) {
    this.lineCookie = lineCookie;

    String ioName = LBL_SQLFileExecution(displayName);
    inputOutput = IOProvider.getDefault().getIO(ioName, true);
}
 
Example #28
Source File: DefaultDataLoadersBridge.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public String getLine(Document doc, int lineNumber) {
    DataObject dObj = (DataObject) doc.getProperty(doc.StreamDescriptionProperty);
    LineCookie lc = dObj.getCookie(LineCookie.class);
    Line line = lc.getLineSet().getCurrent(lineNumber);

    return line.getText();
}
 
Example #29
Source File: EditorOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Returns instance of org.openide.text.Line for given line number.
 * @param lineNumber number of line (beginning at 1)
 * @return org.openide.text.Line instance
 */
private Object getLine(int lineNumber) {
    Document doc = txtEditorPane().getDocument();
    DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
    Set set = (od.getCookie(LineCookie.class)).getLineSet();
    try {
        return set.getCurrent(lineNumber - 1);
    } catch (IndexOutOfBoundsException e) {
        throw new JemmyException("Index must be > 0", e);
    }
}
 
Example #30
Source File: JSUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static LineCookie getLineCookie(final FileObject fo) {
    LineCookie result = null;
    try {
        DataObject dataObject = DataObject.find(fo);
        if (dataObject != null) {
            result = dataObject.getLookup().lookup(LineCookie.class);
        }
    } catch (DataObjectNotFoundException e) {
        e.printStackTrace();
    }
    return result;
}