jalview/util/ParseHtmlBodyAndLinks.js
java/util/function/Function.js
swingjs/a2s/A2SContainer.js
+
+jalview/fts/api/FTSData.js
+jalview/fts/api/FTSDataColumnI.js
+jalview/fts/api/FTSRestClientI.js
+jalview/fts/core/DecimalFormatTableCellRenderer.js
+jalview/fts/core/FTSDataColumnPreferences.js
+jalview/fts/core/FTSRestClient.js
+jalview/fts/core/FTSRestRequest.js
+jalview/fts/core/FTSRestResponse.js
+jalview/fts/service/pdb/PDBFTSRestClient.js
+jalview/gui/StructureChooser.js
+jalview/javascript/json/JSON.js
+jalview/javascript/web/Client.js
+jalview/javascript/web/ClientResponse.js
+jalview/javascript/web/WebResource.js
+jalview/jbgui/BackupFilesPresetEntry.js
+jalview/jbgui/GStructureChooser.js
+jalview/jbgui/IntKeyStringValueEntry.js
+java/awt/CardLayout.js
+java/awt/TextComponent.js
+java/awt/image/ImageConsumer.js
+java/io/ObjectStreamField.js
+java/net/HttpsURLConnection.js
+java/net/URI.js
+java/util/ComparableTimSort.js
+java/util/LinkedHashSet.js
+java/util/WeakHashMap.js
+javajs/util/Base64.js
+javax/swing/CellRendererPane.js
+javax/swing/DefaultListSelectionModel.js
+javax/swing/DefaultRowSorter.js
+javax/swing/DropMode.js
+javax/swing/Icon.js
+javax/swing/ImageIcon.js
+javax/swing/JTable.js
+javax/swing/JTextField.js
+javax/swing/ListSelectionModel.js
+javax/swing/RowSorter.js
+javax/swing/SortOrder.js
+javax/swing/event/CaretEvent.js
+javax/swing/event/CaretListener.js
+javax/swing/event/CellEditorListener.js
+javax/swing/event/DocumentListener.js
+javax/swing/event/ListSelectionEvent.js
+javax/swing/event/ListSelectionListener.js
+javax/swing/event/MouseInputListener.js
+javax/swing/event/RowSorterEvent.js
+javax/swing/event/RowSorterListener.js
+javax/swing/event/SwingPropertyChangeSupport.js
+javax/swing/event/TableColumnModelEvent.js
+javax/swing/event/TableColumnModelListener.js
+javax/swing/event/TableModelEvent.js
+javax/swing/plaf/InputMapUIResource.js
+javax/swing/table/DefaultTableCellRenderer.js
+javax/swing/table/DefaultTableColumnModel.js
+javax/swing/table/DefaultTableModel.js
+javax/swing/table/JTableHeader.js
+javax/swing/table/TableCellRenderer.js
+javax/swing/table/TableColumn.js
+javax/swing/table/TableColumnModel.js
+javax/swing/table/TableRowSorter.js
+javax/swing/text/Caret.js
+javax/swing/text/DefaultCaret.js
+javax/swing/text/DefaultEditorKit.js
+javax/swing/text/Document.js
+javax/swing/text/EditorKit.js
+javax/swing/text/Element.js
+javax/swing/text/JTextComponent.js
+javax/swing/text/Position.js
+javax/swing/text/TextAction.js
+javax/swing/text/View.js
+net/miginfocom/layout/AC.js
+net/miginfocom/layout/AnimSpec.js
+net/miginfocom/layout/BoundSize.js
+net/miginfocom/layout/CC.js
+net/miginfocom/layout/ComponentWrapper.js
+net/miginfocom/layout/ConstraintParser.js
+net/miginfocom/layout/ContainerWrapper.js
+net/miginfocom/layout/DimConstraint.js
+net/miginfocom/layout/Grid.js
+net/miginfocom/layout/LC.js
+net/miginfocom/layout/LayoutUtil.js
+net/miginfocom/layout/LinkHandler.js
+net/miginfocom/layout/PlatformDefaults.js
+net/miginfocom/layout/ResizeConstraint.js
+net/miginfocom/layout/UnitValue.js
+net/miginfocom/swing/MigLayout.js
+net/miginfocom/swing/SwingComponentWrapper.js
+net/miginfocom/swing/SwingContainerWrapper.js
+sun/swing/StringUIClientPropertyKey.js
+sun/swing/SwingUtilities2.js
+sun/swing/UIClientPropertyKey.js
+sun/swing/table/DefaultTableCellHeaderRenderer.js
+swingjs/JSAbstractDocument.js
+swingjs/JSImage.js
+swingjs/JSImagekit.js
+swingjs/JSPlainDocument.js
+swingjs/api/JSMinimalAbstractDocument.js
+swingjs/json/JSON.js
+swingjs/plaf/BasicHTML.js
+swingjs/plaf/CellHolder.js
+swingjs/plaf/JSTableHeaderUI.js
+swingjs/plaf/JSTableUI.js
+swingjs/plaf/JSTextFieldUI.js
+swingjs/plaf/JSTextUI.js
+swingjs/plaf/TextListener.js
+
+com/stevesoft/pat/Bracket.js
+com/stevesoft/pat/CaseMgr.js
+com/stevesoft/pat/FastMulti.js
+com/stevesoft/pat/NUnicodeAlpha.js
+com/stevesoft/pat/NUnicodeCurrency.js
+com/stevesoft/pat/NUnicodeDigit.js
+com/stevesoft/pat/NUnicodeMath.js
+com/stevesoft/pat/NUnicodePunct.js
+com/stevesoft/pat/NUnicodeW.js
+com/stevesoft/pat/NUnicodeWhite.js
+com/stevesoft/pat/NoPattern.js
+com/stevesoft/pat/Or.js
+com/stevesoft/pat/OrMark.js
+com/stevesoft/pat/Pattern.js
+com/stevesoft/pat/PatternSub.js
+com/stevesoft/pat/Pthings.js
+com/stevesoft/pat/Range.js
+com/stevesoft/pat/RegOpt.js
+com/stevesoft/pat/RegRes.js
+com/stevesoft/pat/Regex.js
+com/stevesoft/pat/Rthings.js
+com/stevesoft/pat/StrPos.js
+com/stevesoft/pat/StringLike.js
+com/stevesoft/pat/SubMark.js
+com/stevesoft/pat/UniValidator.js
+com/stevesoft/pat/UnicodeAlpha.js
+com/stevesoft/pat/UnicodeCurrency.js
+com/stevesoft/pat/UnicodeDigit.js
+com/stevesoft/pat/UnicodeLower.js
+com/stevesoft/pat/UnicodeMath.js
+com/stevesoft/pat/UnicodePunct.js
+com/stevesoft/pat/UnicodeUpper.js
+com/stevesoft/pat/UnicodeW.js
+com/stevesoft/pat/UnicodeWhite.js
+com/stevesoft/pat/Validator.js
+com/stevesoft/pat/oneChar.js
+com/stevesoft/pat/parsePerl.js
+com/stevesoft/pat/patInt.js
+com/stevesoft/pat/wrap/StringWrap.js
+
+jalview/api/DBRefEntryI.js
+jalview/api/SequenceStructureBinding.js
+jalview/api/structures/JalviewStructureDisplayI.js
+jalview/datamodel/DBRefEntry.js
+jalview/datamodel/Mapping.js
+jalview/datamodel/features/FeatureAttributes.js
/** Default file is ~/.jalview_properties */
static String propertiesFile;
- private static boolean propsAreReadOnly = Platform.isJS();/// ** @j2sNative
- /// true || */false;
+ private static boolean propsAreReadOnly = Platform.isJS();
private final static String JS_PROPERTY_PREFIX = "jalview_";
private static void setLogging()
{
// BH - for event debugging in JavaScript (Java mode only)
- if (!Platform.isJS())// !(/** @j2sNative true ||*/false))
+ if (!Platform.isJS())
/**
* Java only
*
if (!Platform.isJS())
/**
- * ignore in JavaScript
+ * Java only
*
* @j2sNative
*/
// And the user
// ////////////////////
- if (!Platform.isJS() && // /** @j2sNative false && */ // BH 2018
- !headless && file == null && vamsasImport == null
+ if (!Platform.isJS() && !headless && file == null
+ && vamsasImport == null
&& jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
/**
* Java only
package jalview.bin;
+import jalview.util.Platform;
+
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
protected static int focusTime = 0;
-private static void showFocusTimer() {
-
- Timer t = new Timer(100, new ActionListener() {
+ private static void showFocusTimer()
+ {
- @Override
- public void actionPerformed(ActionEvent e) {
- String s = /** @j2sNative document.activeElement.id || */
- null;
+ if (Platform.isJS())
+ {
+ Timer t = new Timer(100, new ActionListener()
+ {
- s += " " + (++focusTime);
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ String s = /** @j2sNative document.activeElement.id || */
+ null;
- /** @j2sNative document.title = s; */
- }
+ s += " " + (++focusTime);
- });
+ /** @j2sNative document.title = s; */
+ }
- t.setRepeats(true);
- if (/** @j2sNative true || */
- false)
- {
- t.start();
- }
+ });
+
+ t.setRepeats(true);
+ t.start();
+ }
}
public static int getSourceKey(String name) {
for (int i = 0; i < MASK_COUNT; i++) {
if (name.equals(allSources[i]))
- return 1<<i;
+ {
+ return 1<<i;
+ }
}
return 0;
}
return ((PRIMARY_SOURCES_MASK & getSourceKey(source)) != 0);
}
-
-// public static String[] allSourcesFromReflection;
-//
-// public static String[] allSources()
-//
-// {
-// /**
-// * @j2sNative
-// *
-// * return C$.allTypes;
-// *
-// */
-//
-// {
-// if (allSourcesFromReflection == null)
-// {
-// List<String> src = new ArrayList<>();
-// for (Field f : DBRefSource.class.getFields())
-// {
-// if (String.class.equals(f.getType()))
-// {
-// try
-// {
-// src.add((String) f.get(null));
-// } catch (Exception x)
-// {
-// x.printStackTrace();
-// }
-// }
-// }
-// allSourcesFromReflection = src.toArray(new String[0]);
-// }
-// return allSourcesFromReflection;
-// }
-// }
-
public static boolean isPrimaryCandidate(String ucversion) {
// tricky - this test really needs to search the sequence's set of dbrefs to
// see if there is a primary reference that derived this reference.
protected JInternalFrame mainFrame = new JInternalFrame(
getFTSFrameTitle());
- protected JTabbedPane tabs = jalview.jbgui.GDesktop.createTabbedPane();
+ protected JTabbedPane tabs = new JTabbedPane();
protected IProgressIndicator progressIndicator;
protected JLabel lbl_blank = new JLabel(balnkPlaceholderImage);
- JTabbedPane tabbedPane = jalview.jbgui.GDesktop.createTabbedPane();
+ JTabbedPane tabbedPane = new JTabbedPane();
private JPanel pnl_actions = new JPanel();
setBounds(xPos, yPos, 900, 650);
}
- // boolean doFullLoad = /** @j2sNative ! */true;
if (!Platform.isJS())
/**
* Java only
frame.setResizable(resizable);
frame.setMaximizable(resizable);
frame.setIconifiable(resizable);
- frame.setOpaque(Platform.isJS());/// ** @j2sNative true || */false);
+ frame.setOpaque(Platform.isJS());
if (frame.getX() < 1 && frame.getY() < 1)
{
* Javascript does not call componentResized on initial display,
* so do the update here
*/
- // boolean doUpdate = /** @j2sNative true || */ false;
if (Platform.isJS())
{
updateOverviewImage();
protected void showFeatureDetails(SequenceFeature sf)
{
JInternalFrame details;
- if (Platform.isJS())// ** @j2sNative true || */ false)
+ if (Platform.isJS())
{
details = new JInternalFrame();
JPanel panel = new JPanel(new BorderLayout());
this.interactiveDialog = interactive;
// show a splashscreen that will disapper
if (Platform.isJS()) // BH 2019
- // if (/** @j2sNative true || */ false)
{
authlist = new JLabel("");
run();
this.setLayout(new BorderLayout());
iframe.setContentPane(this);
iframe.setLayer(JLayeredPane.PALETTE_LAYER);
+ if (Platform.isJS())
+ {
+ // ignore in JavaScript
+ }
+ else
/**
- * we add image directly in html for javascript ?
+ * Java only
*
* @j2sNative
*/
iframe.setVisible(false);
oldtext = newtext.length();
if (Platform.isJS()) // BH 2019
- // if (/** @j2sNative true || */ false)
{
authlist = new JLabel(
"<html><br/><br/><img src=\"swingjs/j2s/images/Jalview_Logo.png\"/><br/>"
((JLabel) authlist).setBackground(Color.white);
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
- /**
- * Java only
- *
- * @j2sNative
- */
- {
- authlist = new JTextPane();
- ((JTextPane) authlist).setEditable(false);
- ((JTextPane) authlist).setContentType("text/html");
- ((JTextPane) authlist).setText(newtext);
- ((JTextPane) authlist).addHyperlinkListener(this);
- }
+ authlist = new JTextPane();
+ ((JTextPane) authlist).setEditable(false);
+ ((JTextPane) authlist).setContentType("text/html");
+ ((JTextPane) authlist).setText(newtext);
+ ((JTextPane) authlist).addHyperlinkListener(this);
}
authlist.addMouseListener(closer);
JvOptionPane.WARNING_MESSAGE);
}
- if (ColourSchemes.getInstance().nameExists(name))
- {
- // BH 2018 SwingJS bypasses this question with YES_OPTION
- int reply = /** @j2sNative 0 && */ JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
- MessageManager.formatMessage(
- "label.colour_scheme_exists_overwrite", new Object[]
- { name, name }),
- MessageManager.getString("label.duplicate_scheme_name"),
- JvOptionPane.YES_NO_OPTION);
- if (reply != JvOptionPane.YES_OPTION)
+ if (!Platform.isJS() && ColourSchemes.getInstance().nameExists(name))
+ {
+ /**
+ * java only
+ *
+ * @j2sNative
+ */
{
+ int reply = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ MessageManager.formatMessage(
+ "label.colour_scheme_exists_overwrite", new Object[]
+ { name, name }),
+ MessageManager.getString("label.duplicate_scheme_name"),
+ JvOptionPane.YES_NO_OPTION);
+ if (reply != JvOptionPane.YES_OPTION)
+ {
+ return;
+ }
}
}
MessageManager.getString("label.save_colour_scheme"));
chooser.setToolTipText(MessageManager.getString("action.save"));
int option = chooser.showSaveDialog(this);
- if (option == JalviewFileChooser.APPROVE_OPTION)
- {
- File file = chooser.getSelectedFile();
- UserColourScheme updatedScheme = addNewColourScheme(file.getPath());
- saveToFile(file);
- changedButNotSaved = false;
-
- /*
- * changes saved - apply to alignment if we are changing
- * the currently selected colour scheme; also make the updated
- * colours the 'backout' scheme on Cancel
- */
- if (oldColourScheme != null
- && name.equals(oldColourScheme.getSchemeName()))
- {
- oldColourScheme = updatedScheme;
- applyButton_actionPerformed();
- }
+ if (option == JalviewFileChooser.APPROVE_OPTION)
+ {
+ File file = chooser.getSelectedFile();
+ UserColourScheme updatedScheme = addNewColourScheme(file.getPath());
+ saveToFile(file);
+ changedButNotSaved = false;
+
+ /*
+ * changes saved - apply to alignment if we are changing
+ * the currently selected colour scheme; also make the updated
+ * colours the 'backout' scheme on Cancel
+ */
+ if (oldColourScheme != null
+ && name.equals(oldColourScheme.getSchemeName()))
+ {
+ oldColourScheme = updatedScheme;
+ applyButton_actionPerformed();
+ }
}
}
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
// revert to a tabbed pane.
JScrollPane firstpane;
this.remove(firstpane = (JScrollPane) jobPanes.get(0));
- subjobs = jalview.jbgui.GDesktop.createTabbedPane();
+ subjobs = new JTabbedPane();
this.add(subjobs, BorderLayout.CENTER);
subjobs.add(firstpane);
subjobs.setTitleAt(0, firstpane.getName());
frame.addInternalFrameListener(
new javax.swing.event.InternalFrameAdapter()
{
+ @Override
public void internalFrameClosed(
javax.swing.event.InternalFrameEvent evt)
{
* @param e
* DOCUMENT ME!
*/
+ @Override
protected void cancel_actionPerformed(ActionEvent e)
{
if (!serviceIsCancellable)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
JvOptionPane.showInternalMessageDialog(Desktop.desktop, message,
BufferedImage offscreen;
+ @Override
public void run()
{
startTime = System.currentTimeMillis();
}
}
+ @Override
public void paintComponent(Graphics g1)
{
drawPanel();
renderAsHtml = b;
}
+ @Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
Desktop.hyperlinkUpdate(e);
import java.util.List;
+import com.stevesoft.pat.Regex;
+
public class ModellerDescription
{
/**
private resCode validResidueCode(String field)
{
Integer val = null;
- com.stevesoft.pat.Regex r = new com.stevesoft.pat.Regex(
+ Regex r = new Regex(
"\\s*((([-0-9]+).?)|FIRST|LAST|@)");
if (!r.search(field))
import java.io.IOException;
import java.util.StringTokenizer;
+import com.stevesoft.pat.Regex;
+
/**
* Parse a new hanpshire style tree Caveats: NHX files are NOT supported and the
* tree distances and topology are unreliable when they are parsed. TODO: on
boolean printRootInfo = true;
- private com.stevesoft.pat.Regex[] NodeSafeName = new com.stevesoft.pat.Regex[] {
- new com.stevesoft.pat.Regex().perlCode("m/[\\[,:'()]/"), // test for
+ private Regex[] NodeSafeName = new Regex[] {
+ new Regex().perlCode("m/[\\[,:'()]/"), // test for
// requiring
// quotes
- new com.stevesoft.pat.Regex().perlCode("s/'/''/"), // escaping quote
+ new Regex().perlCode("s/'/''/"), // escaping quote
// characters
- new com.stevesoft.pat.Regex().perlCode("s/\\/w/_/") // unqoted whitespace
+ new Regex().perlCode("s/\\/w/_/") // unqoted whitespace
// transformation
};
boolean ascending = false; // flag indicating that we are leaving the
// current node
- com.stevesoft.pat.Regex majorsyms = new com.stevesoft.pat.Regex(
+ Regex majorsyms = new Regex(
"[(\\['),;]");
int nextcp = 0;
// Deal with quoted fields
case '\'':
- com.stevesoft.pat.Regex qnodename = new com.stevesoft.pat.Regex(
+ Regex qnodename = new Regex(
"'([^']|'')+'");
if (qnodename.searchFrom(nf, fcp))
nodename = new String(
qnodename.stringMatched().substring(1, nl - 1));
// unpack any escaped colons
- com.stevesoft.pat.Regex xpandquotes = com.stevesoft.pat.Regex
+ Regex xpandquotes = Regex
.perlCode("s/''/'/");
String widernodename = xpandquotes.replaceAll(nodename);
nodename = widernodename;
* '"+nf.substring(cp,fcp)+"'"); }
*/
// verify termination.
- com.stevesoft.pat.Regex comment = new com.stevesoft.pat.Regex(
+ Regex comment = new Regex(
"]");
if (comment.searchFrom(nf, fcp))
{
+ fstring.substring(cend + 1);
}
- com.stevesoft.pat.Regex uqnodename = new com.stevesoft.pat.Regex(
+ Regex uqnodename = new Regex(
"\\b([^' :;\\](),]+)");
- com.stevesoft.pat.Regex nbootstrap = new com.stevesoft.pat.Regex(
+ Regex nbootstrap = new Regex(
"\\s*([0-9+]+)\\s*:");
- com.stevesoft.pat.Regex ndist = new com.stevesoft.pat.Regex(
+ Regex ndist = new Regex(
":([-0-9Ee.+]+)");
if (!parsednodename && uqnodename.search(fstring)
trf.parse();
System.out.println("Original file :\n");
- com.stevesoft.pat.Regex nonl = new com.stevesoft.pat.Regex("\n+", "");
+ Regex nonl = new Regex("\n+", "");
System.out.println(nonl.replaceAll(newickfile.toString()) + "\n");
System.out.println("Parsed file.\n");
public static BufferedReader getJSONReader(InputStream is) {
return /** @j2sNative swingjs.JSUtil.getJSONReader$O(is) || */null;
- }
+ }
/**
*
protected JCheckBoxMenuItem hiddenMarkers = new JCheckBoxMenuItem();
- protected JTabbedPane tabbedPane = jalview.jbgui.GDesktop
- .createTabbedPane();
+ protected JTabbedPane tabbedPane = new JTabbedPane();
protected JMenuItem reload = new JMenuItem();
public class GDesktop extends JFrame
{
- public static javax.swing.JTabbedPane createTabbedPane()
- {
- // now just always return JTabbedPane
- return new javax.swing.JTabbedPane();
-// // BH 2018 coercing jalview.jbgui.swing.JTabbedPane() for now
-// if (/** @j2sNative false && */
-// true)
-// {
-// // Java
-// return new javax.swing.JTabbedPane();
-// }
-// // JavaScript
-// return (javax.swing.JTabbedPane) (Object) new jalview.jbgui.swing.JTabbedPane();
- }
-
-
protected static JMenu windowMenu = new JMenu();
JMenuBar desktopMenubar = new JMenuBar();
*/
private void jbInit() throws Exception
{
- final JTabbedPane tabbedPane = jalview.jbgui.GDesktop.createTabbedPane();
+ final JTabbedPane tabbedPane = new JTabbedPane();
this.setLayout(new BorderLayout());
JPanel okCancelPanel = initOkCancelPanel();
this.add(tabbedPane, BorderLayout.CENTER);
paste.setLayout(
new MigLayout("", "[grow 100, fill]", "[][grow 100,fill]"));
- panels = jalview.jbgui.GDesktop.createTabbedPane();
+ panels = new JTabbedPane();
panels.addTab(details.getName(), details);
panels.addTab(inputs.getName(), inputs);
panels.addTab(paste.getName(), paste);
{
this.dividerRatio = r;
/**
+ *
+ * BH need for this? - NOT setting the location?
+ *
* @j2sNative
*/
{
protected void setDividerLocation(int p)
{
/**
+ * BH: Why are we not setting the location?
+ *
* @j2sNative
*/
{
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
-import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
protected JTable tbl_local_pdb = new JTable();
- protected JTabbedPane pnl_filter = jalview.jbgui.GDesktop.createTabbedPane();
+ protected JTabbedPane pnl_filter = new JTabbedPane();
protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
PreferenceSource.STRUCTURE_CHOOSER,
loadedWithoutErrors = true;
+ if (!Platform.isJS())
/**
+ * Java only
*
* @j2sNative
*
private static boolean loadClasses()
{
+ if (!Platform.isJS())
/**
+ * Java only
+ *
* @j2sNative
*
*/
*/
private static Object locateBrowser()
{
+ if (!Platform.isJS())
/**
+ * Java only
+ *
* @j2sNative
*
*/
public static void openURL(String url) throws IOException
{
- if (Platform.openURL(url))
+ if (Platform.isJS())
{
+ Platform.openURL(url);
return;
}
+ else
/**
* Java only
*
}
/**
+ * BH TODO to Platform?
+ *
* @j2sNative
*
* return jsonArray.elementData.slice(0, n).join(",");
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
try
{
br = new BufferedReader(new InputStreamReader(response, "UTF-8"));
- return parseJSON(br);
+ return new JSONParser().parse(br);
} finally
{
if (br != null)
}
+ /**
+ * Dump the input stream to an output file.
+ *
+ * @param is
+ * @param outFile
+ * @throws IOException
+ * if the file cannot be created or there is a problem reading the
+ * input stream.
+ */
+ public static void streamToFile(InputStream is, File outFile)
+ throws IOException
+ {
+ if (!isJS() || /**
+ * @j2sNative outFile.setBytes$O && outFile.setBytes$O(is) ||
+ */
+ false)
+ {
+ return;
+ }
+ FileOutputStream fio = new FileOutputStream(outFile);
+ try
+ {
+ byte[] bb = new byte[32 * 1024];
+ int l;
+ while ((l = is.read(bb)) > 0)
+ {
+ fio.write(bb, 0, l);
+ }
+ } finally
+ {
+ fio.close();
+ }
+ }
+
}
import jalview.datamodel.DBRefSource;
import jalview.util.MessageManager;
+import jalview.util.Platform;
-import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
* @param database
* @param format
* @param outFile
- * @return
+ * @return array of lines from EBI only if outFile is null (which it will not
+ * be)
* @throws OutOfMemoryError
*/
String[] fetchBatch(String ids, String database, String format,
File outFile) throws OutOfMemoryError
{
- // long time = System.currentTimeMillis();
String url = buildUrl(ids, database, format);
-
+ InputStream is = null;
try
{
URL rcall = new URL(url);
-
HttpURLConnection conn = (HttpURLConnection) rcall.openConnection();
int responseCode = conn.getResponseCode();
- if (responseCode != 200)
- {
- System.err.println("Warning: response code " + responseCode
- + " for " + url);
- }
- InputStream is = new BufferedInputStream(conn.getInputStream());
- if (outFile != null)
+ if (responseCode == 200)
{
- /**@j2sNative
- * if (outFile._isTemp) {
- * outFile._bytes = is.$in.$in.buf;
- * return null;
- * }
- */
- FileOutputStream fio = new FileOutputStream(outFile);
- byte[] bb = new byte[32 * 1024];
- int l;
- while ((l = is.read(bb)) > 0)
+ is = conn.getInputStream();
+ if (outFile != null)
{
- fio.write(bb, 0, l);
+ Platform.streamToFile(is, outFile);
+ return null;
}
- fio.close();
- is.close();
- }
- else
- {
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String rtn;
- List<String> arl = new ArrayList<String>();
+ List<String> arl = new ArrayList<>();
while ((rtn = br.readLine()) != null)
{
arl.add(rtn);
}
- return arl.toArray(new String[arl.size()]);
+ return (String[]) arl.toArray();
}
+ System.err.println(
+ "Warning: response code " + responseCode + " for " + url);
} catch (OutOfMemoryError er)
{
System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + database
throw er;
} catch (Exception ex)
{
- if (ex.getMessage().startsWith(
+ if (!ex.getMessage().startsWith(
"uk.ac.ebi.jdbfetch.exceptions.DbfNoEntryFoundException"))
{
- return null;
+ System.err.println("Unexpected exception when retrieving from "
+ + database + "\nQuery was : '" + ids + "'");
+ ex.printStackTrace(System.err);
}
- System.err.println("Unexpected exception when retrieving from "
- + database + "\nQuery was : '" + ids + "'");
- ex.printStackTrace(System.err);
- return null;
} finally
{
- // System.err.println("EBIFetch took " + (System.currentTimeMillis() -
- // time) + " ms");
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ } catch (IOException e)
+ {
+ }
+ }
}
return null;
}
-20190331212928
+20190403083450
-20190331212928
+20190403083450