blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
403e3b9b2ca4c016369a5b472023ae7793574093 | 643505452a77d17949628c67d6d6bcac7cc74f5c | /problema1/Solucion1/src/paquete1/Terreno.java | 3e4c1cbfc81a217ee38d7e7ddb1993201db03db1 | [] | no_license | ProgOrientadaObjetos-P-AA2021/taller03-Thony11 | b619042fb7271f2bfef0bc3cfaaf07b433bc550f | 561029baf08682fe6daa6de2039c888726850d44 | refs/heads/main | 2023-04-11T09:25:37.858496 | 2021-04-25T21:57:25 | 2021-04-25T21:57:25 | 360,668,580 | 0 | 0 | null | 2021-04-22T20:06:27 | 2021-04-22T20:06:23 | null | UTF-8 | Java | false | false | 1,190 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package paquete1;
/**
*
* @author LENOVO
*/
public class Terreno {
/**
* @param args the command line arguments
*/
private double costo;
private double ancho;
private double largo;
private double area;
private double valorMetroCuadrado;
public void establecerCosto() {
costo = valorMetroCuadrado * area;
}
public void establecerAncho(double c) {
ancho = c;
}
public void establecerLargo(double c) {
largo = c;
}
public void calcularArea() {
area = largo * ancho;
}
public void establecerMetroCuadrado(double c) {
valorMetroCuadrado = c;
}
public double obtenerCosto() {
return costo;
}
public double obtenerAncho() {
return ancho;
}
public double obtenerLargo() {
return largo;
}
public double obtenerArea() {
return area;
}
public double obtenerMetroCuadrado() {
return valorMetroCuadrado;
}
}
| [
"[email protected]"
] | |
adcb4d9c8dc4a8233153e5ae4275946b33fb791f | 8b7e412ec842ac4185b7bd38862bc8105244834c | /daywdzk2/src/main/java/com/example/daywdzk2/api/Api.java | 9620a10de4e7aaa22ff6a3336aaf85428b0045a4 | [] | no_license | wangjie123haha/demo_zk2 | 807bd04d1e6fce507f1c18dd4ed2e5fb5b631b2c | 6d690e0989b587f8d4d85be2d6cf40b06d87b52a | refs/heads/master | 2020-03-28T09:07:27.872607 | 2018-09-09T10:41:00 | 2018-09-09T10:41:00 | 148,015,573 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 312 | java | package com.example.daywdzk2.api;
import com.example.daywdzk2.bean.news;
import io.reactivex.Observable;
import retrofit2.http.GET;
/**
* Created by lenovo on 2018/9/9.
*/
public interface Api {
@GET("content_lists&version=1.7&token=&type=1&cat=&catid2=&page=1")
Observable<news> getresponse();
}
| [
"[email protected]"
] | |
a5b526eb3913127a48356e42ff13f71d61377643 | 08c6b8f54e396790eab0e16b860c53b2a1df8598 | /app/src/main/java/com/example/ujiansim/DataHelper.java | 82e67f118911cdf62df26aa71f895a314376b8a4 | [] | no_license | doniantoro/ujian-sim-online | d0cc20f7e5f20ad3dc78158da367d9bac2c862d7 | f9f53e44a91a23aae04110799c8f800d3c88d60b | refs/heads/master | 2020-11-24T03:30:55.946149 | 2019-12-14T01:18:52 | 2019-12-14T01:18:52 | 227,946,346 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,749 | java | package com.example.ujiansim;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class DataHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "soalUjian.db";
private static final int DATABASE_VERSION = 1;
public DataHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
String sql = "create table soalUjian(no integer primary key, jenis_ujian text null,soal text null, jawabanA text null, jawabanB text null, jawabanC text null,kj text null);";
Log.d("Data", "onCreate: " + sql);
db.execSQL(sql);
sql = "INSERT INTO soalUjian (no, jenis_ujian, soal, jawabanA, jawabanB,jawabanC,kj) VALUES " +
"('1', 'Ujian SIM C', '1. Manakah yang tidak termasuk dalam peralatan pendukung kendaraan beroda dua?', 'Helm yang berstandar SNI','Rompi pemantul cahaya','Kacamata hitam','Kacamata hitam')," +
"('2', 'Ujian SIM C', '2. Isyarat peringatan dengan bunyi yang berupa klakson dapat digunakan apabila:', 'Diperlukan untuk keselamatan lalu lintas','Melewati kendaraan bermotor lainnya','Butir a dan b benar','Butir a dan b benar')," +
"('3', 'Ujian SIM C', '3. Di antara persyaratan berikut, manakah yang harus dipenuhi untuk mendapatkan SIM?', 'Usia','Persyaratan kesehatan','Semua jawaban benar','Semua jawaban benar')," +
"('4', 'Ujian SIM C', '4. Lampu rem pada kendaraan bermotor sesuai ketentuan adalah?', 'Hijau dan menyala tidak berkelip','Merah dan menyala tidak berkelip','Merah dan menyala berkelip - kelip','Merah dan menyala tidak berkelip')," +
"('5', 'Ujian SIM C', '5. Sebagai pengguna jalan hal yang paling utama buat saya adalah:', 'Keselamatan saya dan orang lain','Keselamatan saya','kecepatan','Keselamatan saya dan orang lain')," +
"('6', 'Ujian SIM C', '6. Surat Izin Mengemudi digolongkan berdasarkan', 'Jenis kendaraan bermotor','Tingkat sosial ekonomi pemegangnya','Tingkat sosial ekonomi pemegangnya','Jenis kendaraan bermotor')," +
"('7', 'Ujian SIM C', '7. Isyarat peringatan dengan bunyi yang berupa klakson dapat digunakan apabila', 'Melewati kendaraan bermotor lainnya','Butir a dan c benar semua','Diperlukan untuk keselamatan lalu lintas','Butir a dan c benar semua')," +
"('8', 'Ujian SIM C', '8. Menurut sifatnya, rambu lalu lintas terdiri dari:', 'Peringatan, Larangan, Perintah, Petunjuk','Peringatan, Larangan, Perintah','Larangan, Perintah, Petunjuk','Peringatan, Larangan, Perintah, Petunjuk')," +
"('9', 'Ujian SIM C', '9. Alat pengukur kecepatan di kendaraan, secara umum menunjukkan…', 'Kecepatan rata-rata kendaraan kita','Semuanya benar','Kecepatan aktual,saat melintasi alat','Kecepatan aktual,saat melintasi alat')," +
"('10', 'Ujian SIM C', '10. Marka membujur berupa:', 'Garis utuh dan garis putus-putus','Semuanya benar','Garis ganda yang terdiri dari dua garis utuh','Semuanya benar')," +
"('11', 'Ujian SIM C', '11. Fungsi dari rem adalah…', 'Untuk memperlambat atau menghentikan putaran roda','Untuk menurunkan putaran mesin','Untuk mengganti gigi transmisi kendaraan','Untuk memperlambat atau menghentikan putaran roda')," +
"('12', 'Ujian SIM C', '12. Yang bukan merupakan jenis surat ijin mengemudi adalah ', 'SIM Kendaraan Bermotor ganda, Perintah, Petunjuk','Semua jawaban salah','SIM Kendaraan Bermotor umum','SIM Kendaraan Bermotor ganda')," +
"('13', 'Ujian SIM C', '13. Pemilik SIM golongan C dapat digunakan untuk mengemudi kendaraan?', 'Untuk mengemudikan seluruh jenis kendaraan','Hanya untuk mengendarai jenis sepeda motor di bawah 250 cc','Untuk mengendarai seluruh jenis sepeda motor kecuali diatas 500 cc','Hanya untuk mengendarai jenis sepeda motor di bawah 250 cc')," +
"('14', 'Ujian SIM C', '14. Jika Anda mengendari Motor Gede (Moge) diatas 1000 cylinder capacity (cc), jenis SIM apakah yang harus dimiliki? ', 'SIM C I','SIM C','SIM C II','SIM C II')," +
"('15', 'Ujian SIM C', '15. Golongan SIM apakah yang diperlukan jika anda hendak mengendarai motor 250 cc?', 'Golongan SIM C I & II','Golongan SIM C II','Golongan SIM C I','Golongan SIM C I & II');";
db.execSQL(sql);
}
@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
} | [
"[email protected]"
] | |
28f3fecde05942bc572174bafa415851f15afc29 | fba8af31d5d36d8a6cf0c341faed98b6cd5ec0cb | /src/main/java/com/alipay/api/domain/AlipayEcoDingMessageNotifyModel.java | 1f8f630759044d99c1c121b114fbe231d7770a0c | [
"Apache-2.0"
] | permissive | planesweep/alipay-sdk-java-all | b60ea1437e3377582bd08c61f942018891ce7762 | 637edbcc5ed137c2b55064521f24b675c3080e37 | refs/heads/master | 2020-12-12T09:23:19.133661 | 2020-01-09T11:04:31 | 2020-01-09T11:04:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,083 | java | package com.alipay.api.domain;
import com.alipay.api.AlipayObject;
import com.alipay.api.internal.mapping.ApiField;
/**
* 钉钉消息通知对外接口服务
*
* @author auto create
* @since 1.0, 2019-09-06 18:22:10
*/
public class AlipayEcoDingMessageNotifyModel extends AlipayObject {
private static final long serialVersionUID = 3238637656581212899L;
/**
* 钉钉通知@人列表
*/
@ApiField("at_mobiles")
private String atMobiles;
/**
* 钉钉通知内容
*/
@ApiField("content")
private String content;
/**
* 钉钉群token
*/
@ApiField("ding_token")
private String dingToken;
public String getAtMobiles() {
return this.atMobiles;
}
public void setAtMobiles(String atMobiles) {
this.atMobiles = atMobiles;
}
public String getContent() {
return this.content;
}
public void setContent(String content) {
this.content = content;
}
public String getDingToken() {
return this.dingToken;
}
public void setDingToken(String dingToken) {
this.dingToken = dingToken;
}
}
| [
"[email protected]"
] | |
2b7452aa9e967164a48bacc018e0214ace99a5e9 | 1db832f4437981c0f9e8ea53d4302e7d74d5ebda | /src/main/java/nl/belastingdienst/registreren/Util.java | d72dd92092bc4108bdce6e6d1fb007aa953e7cf5 | [] | no_license | DRDosSAntos/Case1 | 19949f0071fbe3d53410346bd3c9fd3b537efa69 | 3a65924df187707d1541e4840c6c513b6ebac630 | refs/heads/master | 2023-04-27T22:19:38.297840 | 2021-05-06T12:52:15 | 2021-05-06T12:52:15 | 360,876,103 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 569 | java | package nl.belastingdienst.registreren;
import java.util.Scanner;
public class Util {
public String readLine() {
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
}
public static String promptString(String message) {
System.out.print(message);
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
}
public static int promptInt(String message) {
System.out.print(message);
Scanner scanner = new Scanner(System.in);
return scanner.nextInt();
}
}
| [
"[email protected]"
] | |
80c7de5d7f865ead2488955e6c65cc7653c0105f | 64369997c17624c8f48338b89cece160a9de9cbe | /global/hbaseindex/base/src/main/java/org/lilyproject/hbaseindex/IntegerIndexFieldDefinition.java | dd752101938624e32d8278be7ab5c1959cfa0272 | [
"Apache-2.0"
] | permissive | isabella232/lilyproject | 4f75984add11d045a79fb94e09cc4bd34b81c5c2 | 15150a5c1ee2241bf55cbe4d4ea3f7f07275a529 | refs/heads/master | 2023-03-17T07:48:27.754362 | 2014-12-09T12:38:24 | 2014-12-09T12:40:22 | 320,800,142 | 0 | 0 | Apache-2.0 | 2021-02-23T22:07:48 | 2020-12-12T10:06:35 | null | UTF-8 | Java | false | false | 1,528 | java | /*
* Copyright 2010 Outerthought bvba
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lilyproject.hbaseindex;
import com.gotometrics.orderly.IntegerRowKey;
import com.gotometrics.orderly.RowKey;
import com.gotometrics.orderly.Termination;
import org.codehaus.jackson.node.ObjectNode;
public class IntegerIndexFieldDefinition extends IndexFieldDefinition {
public IntegerIndexFieldDefinition() {
// hadoop serialization
}
public IntegerIndexFieldDefinition(String name) {
super(name);
}
public IntegerIndexFieldDefinition(String name, ObjectNode jsonObject) {
super(name, jsonObject);
}
@Override
RowKey asRowKey() {
final
IntegerRowKey rowKey = new IntegerRowKey();
rowKey.setOrder(this.getOrder());
return rowKey;
}
@Override
RowKey asRowKeyWithoutTermination() {
final RowKey rowKey = asRowKey();
rowKey.setTermination(Termination.SHOULD_NOT);
return rowKey;
}
}
| [
"[email protected]"
] | |
f830c8cd126e18ef049b6b1d76ac0a40ca25d0ea | a6b372d807e8127d5df8e54f5425d6f1736fccd2 | /files/todo.java | 70f7252527c314758e066916201c932f4441fe9e | [] | no_license | kiquetal/study_oca | 7fed48f689a9917e15d0a88e356943b587ef28d4 | 3e7b8cc34a8ba71c96415ce9fa30bc09928898e5 | refs/heads/master | 2021-01-21T11:08:57.851744 | 2015-01-22T17:06:27 | 2015-01-22T17:06:27 | 28,718,992 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 204 | java | public class todo
{
public static void main(String args[])
{
class todoc
{
private int d=12;
{
System.out.println("que ha pasado");
}
}
todoc a=new todoc();
}
static class Another
{
}
}
| [
"[email protected]"
] | |
eee18f8fa97e19df2ab7f44a1e1474a8b4dd6773 | 5cb8816c0ee361934fc291c495917464490491db | /src/main/java/com/bgi/jingwei/util/ImageUI.java | 8c97803c44eefc9147eb46e4e37f41211cf3af1f | [] | no_license | lvmker/jingwei | 0448ec22e61b2ea8c7267a225be17249c47793ae | f730c4517e1c7b2f250a496d2d0fcadbb6aeab01 | refs/heads/master | 2022-11-28T14:48:50.755909 | 2020-07-31T10:19:39 | 2020-07-31T10:19:39 | 283,139,307 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,414 | java | package com.bgi.jingwei.util;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JDialog;
import org.opencv.core.Mat;
import com.bgi.jingwei.entity.JingweiMat;
public class ImageUI extends JComponent {
private static final long serialVersionUID = 1L;
private BufferedImage image;
public ImageUI() {
this.image = null;
}
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
if (image == null) {
g2d.setPaint(Color.BLACK);
g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
} else {
g2d.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null);
}
}
/**
* 显示图片
* @param title
* @param src
*/
public void imshow(String title, Mat src) {
this.image = convert2BufferedImage(src);
//对话框
JDialog ui = new JDialog();
ui.setTitle(title);
//设置布局
ui.getContentPane().setLayout(new BorderLayout());
//设置布局居中方式
ui.getContentPane().add(this, BorderLayout.CENTER);
//设置宽高
ui.setSize(image.getWidth() + 16, image.getHeight() + 38);
//设置可见
ui.setVisible(true);
//刷新
this.repaint();
}
public void imshow(JingweiMat jingweiMat) {
imshow(jingweiMat.getDesc(), jingweiMat.getMat());
}
private BufferedImage convert2BufferedImage(Mat src) {
int width = src.cols();
int height = src.rows();
int dims = src.channels();
byte[] data = new byte[width * height * dims];//存储图像所有像素点
src.get(0, 0, data);
int[] pixels = new int[width * height];
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
int r = 0, g = 0, b = 0;
int index = 0;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
index = row * width * dims + col * dims;
if (dims == 3) {
b = data[index] & 0xff;
g = data[index + 1] & 0xff;
r = data[index + 2] & 0xff;
pixels[row * width + col] = ((255&0xff) << 24) | ((r&0xff) << 16) | ((g&0xff) << 8) | (b&0xff);
} else if (dims == 1){
b = data[index] & 0xff;
pixels[row * width + col] = ((255&0xff) << 24) | ((b&0xff) << 16) | ((b&0xff) << 8) | (b&0xff);
}
}
}
bi.getRaster().setDataElements(0, 0, width, height, pixels);
return bi;
}
}
| [
"[email protected]"
] | |
3e615f55b7c08d77300b478d762b950a058ea720 | b9990f290e75eb8b50688532b83fc77a89242398 | /app/src/androidTest/java/com/jchen/cplay/ExampleInstrumentedTest.java | c0085a8eb2561068357b294ecca3db6224a6a705 | [] | no_license | jianchenj/Cplay | 80f98c3ef5fe9824e88589c22d26553bfc86e40f | 9c53cce2218d5c4ecbc4ff227f03048031d43c73 | refs/heads/master | 2022-11-14T20:13:33.897227 | 2020-06-28T10:04:15 | 2020-06-28T10:04:15 | 274,630,899 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 744 | java | package com.jchen.cplay;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.jchen.cplay", appContext.getPackageName());
}
} | [
"[email protected]"
] | |
25ff7e9ff1acf07f5229b4e1bd174c262ec1e376 | 3e40b87768a30858a60903fdc8d084260760b0ad | /core/src/main/java/org/juzu/impl/spi/fs/classloader/URLCache.java | 3bc3dfad3aae0d5573240d1254b56d983ba37742 | [] | no_license | kmenzli/juzu | c964314835391b08191e7af719ebdbeb8145d35f | 636094f6237754a58eb699860986b8afeee203bb | refs/heads/master | 2021-01-16T21:55:17.813174 | 2012-05-04T12:34:03 | 2012-05-15T15:14:13 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,099 | java | package org.juzu.impl.spi.fs.classloader;
import org.juzu.impl.utils.Tools;
import org.juzu.impl.utils.Trie;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
/** @author <a href="mailto:[email protected]">Julien Viet</a> */
class URLCache
{
/** . */
private final Trie<String, URL> root;
public URLCache()
{
this.root = new Trie<String, URL>();
}
void add(ClassLoader classLoader) throws IOException
{
// Get the root class path files
for (Enumeration<URL> i = classLoader.getResources("");i.hasMoreElements();)
{
URL url = i.nextElement();
if (url.getProtocol().equals("file"))
{
try
{
File f = new File(url.toURI());
if (f.isDirectory())
{
add(root, f);
}
else
{
// WTF ?
}
}
catch (URISyntaxException e)
{
throw new IOException(e);
}
}
}
//
ArrayList<URL> items = Collections.list(classLoader.getResources("META-INF/MANIFEST.MF"));
for (URL item : items)
{
if ("jar".equals(item.getProtocol()))
{
String path = item.getPath();
int pos = path.indexOf("!/");
URL url = new URL(path.substring(0, pos));
add(root, url);
}
}
}
void add(Class<?> clazz) throws IOException
{
URL inject = clazz.getClassLoader().getResource("javax/inject/Inject.class");
if (inject != null)
{
if ("jar".equals(inject.getProtocol()))
{
String path = inject.getPath();
int pos = path.indexOf("!/");
URL url = new URL(path.substring(0, pos));
add(root, url);
}
}
}
Trie<String, URL> get(Iterable<String> names) throws IOException
{
return root.get(names.iterator());
}
private static void add(Trie<String, URL> root, URL url) throws IOException
{
if ("file".equals(url.getProtocol()))
{
// The fast way (but that requires a File object)
try
{
File f = new File(url.toURI());
ZipFile jarFile = new ZipFile(f);
for (Enumeration<? extends ZipEntry> en = jarFile.entries();en.hasMoreElements();)
{
ZipEntry entry = en.nextElement();
add(root, url, entry);
}
}
catch (URISyntaxException e1)
{
throw new IOException("Could not access jar file " + url, e1);
}
}
else
{
// The slow way
ZipInputStream in = new ZipInputStream(url.openStream());
try
{
for (ZipEntry jarEntry = in.getNextEntry();jarEntry != null;jarEntry = in.getNextEntry())
{
add(root, url, jarEntry);
}
}
finally
{
Tools.safeClose(in);
}
}
}
private static void add(Trie<String, URL> trie, File f) throws IOException
{
for (File file : f.listFiles())
{
Trie<String, URL> child = trie.add(file.getName());
if (file.isDirectory())
{
add(child, file);
}
else
{
child.value(file.toURI().toURL());
}
}
}
private static void add(Trie<String, URL> root, URL baseURL, ZipEntry entry) throws IOException
{
String name = entry.getName();
if (!entry.isDirectory())
{
String[] names = Tools.split(name, '/');
Trie<String, URL> trie = root.add(names);
URL entryURL = new URL("jar:" + baseURL + "!/" + name);
trie.value(entryURL);
}
}
}
| [
"[email protected]"
] | |
95870c0d74a91d0fd29f5624e5113b1127d87584 | 590cebae4483121569983808da1f91563254efed | /Router/eps2-src/router-aud/src/main/java/ru/acs/fts/aud/router/processing/exceptions/ArchiveException.java | edf390ae574955babb10af69a047407e5b3550d6 | [] | no_license | ke-kontur/eps | 8b00f9c7a5f92edeaac2f04146bf0676a3a78e27 | 7f0580cd82022d36d99fb846c4025e5950b0c103 | refs/heads/master | 2020-05-16T23:53:03.163443 | 2014-11-26T07:00:34 | 2014-11-26T07:01:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,859 | java | package ru.acs.fts.aud.router.processing.exceptions;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ArchiveException extends BaseAudException
{
private static final long serialVersionUID = -3202865040095456797L;
private Map< String, List< ArchiveError > > _documentErrors = new HashMap< String, List< ArchiveError > >( );
private List< ArchiveError > _requestErrors = new ArrayList< ArchiveError >( );
private String _message;
public static ArchiveException createWithDocumentError( String documentId, String code, Object... params )
{
ArchiveException exc = new ArchiveException( String.format( "Ошибка в работе сервера: %s", code ) );
exc.addDocumentError( documentId, code, params );
return exc;
}
public ArchiveException( String code, Object... params )
{
super( code );
_message = String.format( "Ошибка в работе сервера: %s", code );
addRequestError( code, params );
}
@Override
public String getMessage( )
{
return _message;
}
public void setMessage( String message )
{
_message = message;
}
public void addDocumentError( String documentId, String code, Object[ ] params )
{
ArchiveError error = new ArchiveError( code, params );
List< ArchiveError > errors = _documentErrors.get( documentId );
if ( null == errors )
{
errors = new ArrayList< ArchiveError >( );
_documentErrors.put( documentId, errors );
}
errors.add( error );
}
public void addRequestError( String code, Object[ ] params ) // NO_UCD (use private)
{
_requestErrors.add( new ArchiveError( code, params ) );
}
public List< ArchiveError > getRequestErrors( )
{
return _requestErrors;
}
public Map< String, List< ArchiveError > > getDocumentErrors( )
{
return _documentErrors;
}
public boolean hasRequestErrors( )
{
return ! _requestErrors.isEmpty( );
}
public boolean hasDocumentErrors( )
{
return ! _documentErrors.isEmpty( );
}
/*
public ArchiveException copyWithMessage( String newMessage )
{
ArchiveException copy = new ArchiveException( newMessage );
copy.setErrorCode( getErrorCode( ) );
copy.setErrorType( getErrorType( ) );
copy.setFailScenario( getFailScenario( ) );
copy.setIsRethrow( getIsRethrow( ) );
copy.setNeedRollBack( getNeedRollBack( ) );
copy.setResultCode( getResultCode( ) );
copy.setStackTrace( getStackTrace( ) );
copy.setWarningLevel( getWarningLevel( ) );
copy.setDocumentErrors( getDocumentErrors( ) );
copy.setRequestErrors( getRequestErrors( ) );
return copy;
}
private void setDocumentErrors( Map< String, List< ArchiveError > > documentErrors )
{
_documentErrors = documentErrors;
}
private void setRequestErrors( List< ArchiveError > requestErrors )
{
_requestErrors = requestErrors;
}
*/
}
| [
"[email protected]"
] | |
8859cdb528b011ed15b11aaff7612407df46032f | ebef145afa739074d8aa4b248153041510bbc1da | /src/Schedule.java | 35f2225327d0b1895f04bd3ca02e5f807413810f | [] | no_license | EthanReese/Scriba | 5be9a7951d973203a80b71fa665e926a45cecc55 | 009f317f8f22e72803cd121a3d82623345051a3b | refs/heads/master | 2021-01-01T18:00:32.643811 | 2017-12-09T22:44:43 | 2017-12-09T22:44:43 | 98,223,150 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,661 | java | import java.util.ArrayList;
public class Schedule {
ArrayList<Courses> courses;
ArrayList<Student> students;
public ArrayList<Courses> getCourses() {
return courses;
}
public void setCourses(ArrayList<Courses> courses) {
this.courses = (ArrayList<Courses>)courses.clone();
}
public ArrayList<Student> getStudents() {
return students;
}
public void setStudents(ArrayList<Student> students) {
this.students = (ArrayList<Student>)students.clone();
}
public ArrayList<Teacher> getTeachers() {
return teachers;
}
public void setTeachers(ArrayList<Teacher> teachers) {
this.teachers = (ArrayList<Teacher>)teachers.clone();
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
public ArrayList<Sections> getSections() {
return sections;
}
public void setSections(ArrayList<Sections> sections) {
this.sections = (ArrayList<Sections>)sections.clone();
}
ArrayList<Teacher> teachers;
double score;
ArrayList<Sections> sections;
int newTeachers;
public ArrayList<Teacher> getAddedTeachers() {
return addedTeachers;
}
public void setAddedTeachers(ArrayList<Teacher> addedTeachers) {
this.addedTeachers = (ArrayList<Teacher>)addedTeachers.clone();
}
ArrayList<Teacher> addedTeachers;
public int getNewTeachers() {
return newTeachers;
}
public void setNewTeachers(int newTeachers) {
this.newTeachers = newTeachers;
}
public Schedule(){
}
}
| [
"[email protected]"
] | |
2c06637bdc0adcd86e3eac147a80502ab303865a | 62acc80a3eee58a3e3dfc81fae094339bf16a09b | /core/src/main/java/me/fromgate/reactions/flags/factions/FlagFaction.java | b875809772fec12c3f73e46284fc132dfd1e42b3 | [] | no_license | MaxDikiy/ReActions | 27c89d7b35df66cbe3066354b14135802e14d1bf | 784eb723a3e95c154a83fff72de26c7b2fe92365 | refs/heads/master | 2021-01-20T00:28:48.844991 | 2017-05-03T16:36:20 | 2017-05-03T16:36:20 | 89,137,863 | 1 | 0 | null | 2017-05-03T16:36:21 | 2017-04-23T11:47:17 | Java | UTF-8 | Java | false | false | 1,310 | java | /*
* ReActions, Minecraft bukkit plugin
* (c)2012-2014, fromgate, [email protected]
* http://dev.bukkit.org/server-mods/reactions/
*
* This file is part of ReActions.
*
* ReActions is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ReActions is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ReActions. If not, see <http://www.gnorg/licenses/>.
*
*/
package me.fromgate.reactions.flags.factions;
import me.fromgate.reactions.externals.Externals;
import me.fromgate.reactions.externals.RAFactions;
import me.fromgate.reactions.flags.Flag;
import org.bukkit.entity.Player;
public class FlagFaction extends Flag {
@Override
public boolean checkFlag(Player player, String param) {
if (!Externals.isConnectedFactions()) return false;
return RAFactions.isPlayerInFaction(player, param);
}
}
| [
"[email protected]"
] | |
b529da3ddc663edca86234168bf0985133958d7e | af9da36463bd50684f738a86a8fe7a0616fa657c | /L3_S6/Prog/apnee2/src/main/java/q3/action/LoadAction.java | ac26740299bd63266e8ca10993607d2b2b50a587 | [] | no_license | christopherferreira19/Univ | 8970a4e0b334b4d843ab5c38133f2d1b17fcbbe4 | 272360d1972275d81805eb37cdebeadc97d3878d | refs/heads/master | 2023-04-09T17:35:13.769519 | 2018-07-15T01:21:47 | 2018-07-15T01:21:47 | 358,498,078 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,180 | java | package q3.action;
import q3.DessinArea;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
public class LoadAction extends AbstractAction {
private final JFrame frame;
private final DessinArea dessinArea;
public LoadAction(JFrame frame, DessinArea dessinArea) {
super("Charger");
this.frame = frame;
this.dessinArea = dessinArea;
}
@Override
public void actionPerformed(ActionEvent actionEvent) {
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("PNG Images", "png");
chooser.setFileFilter(filter);
int result = chooser.showOpenDialog(dessinArea);
if (result != JFileChooser.APPROVE_OPTION) {
return;
}
File src = chooser.getSelectedFile();
try {
dessinArea.load(src);
} catch (IOException e) {
JOptionPane.showMessageDialog(frame, "Erreur lors de l'ouverture du fichier", "Erreur",
JOptionPane.ERROR_MESSAGE);
}
}
}
| [
"[email protected]"
] | |
ed0d90843b433ed90e666f5e58df1c2b85f7bd52 | a45486545f2fed1492348632209bdec278708727 | /WebUI/src/kr/ac/sunmoon/client/ImagePanel.java | a35c43ea9fa529b5fd7cdc69f2601a7ce02f95c5 | [] | no_license | Bangjeho/capston_design | 592a70a733313a4ea224b32b27c52551e760f709 | 050feab7671e438b65b5c0caa72b0be3c86a3b9c | refs/heads/master | 2020-09-05T17:08:01.755460 | 2019-12-17T04:54:38 | 2019-12-17T04:54:38 | 220,162,804 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 128 | java | version https://git-lfs.github.com/spec/v1
oid sha256:aa845b1cb62d5c1de7034777ca7413cb9032cc2e6ca3b510b5df9f0bb6e1dd7c
size 449
| [
"[email protected]"
] | |
949d5c8b74745eb3d84a4bc728a84ae45ccc5fa9 | 1833f2fc01a4312c74b84704b26a985b5bb54bc4 | /src/main/java/com/mayaccom/service/mapper/EntityMapper.java | fc9ace45573eaaf0c1b955f9f578fd8465addaf6 | [] | no_license | zhummer/jMaya | b1e51ffcf03f5bebe28a2a81628489635e97b532 | df336cad0784484fc484940d9ba99a9c2381b725 | refs/heads/master | 2021-01-25T10:06:17.804641 | 2018-03-01T10:46:50 | 2018-03-01T10:46:50 | 123,339,024 | 0 | 0 | null | 2018-02-28T21:03:36 | 2018-02-28T20:32:00 | Java | UTF-8 | Java | false | false | 368 | java | package com.mayaccom.service.mapper;
import java.util.List;
/**
* Contract for a generic dto to entity mapper.
*
* @param <D> - DTO type parameter.
* @param <E> - Entity type parameter.
*/
public interface EntityMapper <D, E> {
E toEntity(D dto);
D toDto(E entity);
List <E> toEntity(List<D> dtoList);
List <D> toDto(List<E> entityList);
}
| [
"[email protected]"
] | |
dd9b14b7a113bef002a3cfbfbf9047de5e21a69d | a6eeb60379204be84f3b005787f31dbfba290696 | /src/main/java/com/uday/learning/bean/response/ExaminerLoginFailedLoginResponse.java | 1f71b254de30e1beeb9e6d54de7dc0590500ee5e | [] | no_license | uday553/online-exam | 0c51231ed20fc693b834b930fc23b06f7445f7f7 | 7ed04a46eabd2f5f5bbcca667cf7664044a53255 | refs/heads/master | 2022-12-09T15:52:50.973644 | 2020-09-14T04:08:00 | 2020-09-14T04:08:00 | 294,966,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 372 | java | package com.uday.learning.bean.response;
import lombok.*;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@Getter
@Setter
@ResponseStatus(HttpStatus.FORBIDDEN)
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class ExaminerLoginFailedLoginResponse extends BaseLoginResponse {
private String token;
}
| [
"[email protected]"
] | |
16f76314ea564d69fa2c481369cf3d7a85fa978a | 0ebd6aee8102cf7191ae4e8fbb9478fb0ff6b52a | /src/Assets/Plugins/StansAssets/Android/facebook/src/com/facebook/internal/ServerProtocol.java | fdda6dc2838e89b5d72808ca5529fc9f3ec80192 | [] | no_license | acornies/maud | 3b9d0ca5ff8aa50bda7bb046b28ae6a63e461a15 | 7a38c9012db169da65f64e7abc77cee3ecd37b5c | refs/heads/master | 2022-06-06T20:55:16.607095 | 2019-03-01T18:28:11 | 2019-03-01T18:28:11 | 20,458,385 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,479 | java | /**
* Copyright 2010-present Facebook.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.internal;
import com.facebook.Settings;
import java.util.Collection;
/**
* com.facebook.internal is solely for the use of other packages within the Facebook SDK for Android. Use of
* any of the classes in this package is unsupported, and they may be modified or removed without warning at
* any time.
*/
public final class ServerProtocol {
private static final String DIALOG_AUTHORITY_FORMAT = "m.%s";
public static final String DIALOG_PATH = "dialog/";
public static final String DIALOG_PARAM_ACCESS_TOKEN = "access_token";
public static final String DIALOG_PARAM_APP_ID = "app_id";
public static final String DIALOG_PARAM_AUTH_TYPE = "auth_type";
public static final String DIALOG_PARAM_CLIENT_ID = "client_id";
public static final String DIALOG_PARAM_DISPLAY = "display";
public static final String DIALOG_PARAM_E2E = "e2e";
public static final String DIALOG_PARAM_LEGACY_OVERRIDE = "legacy_override";
public static final String DIALOG_PARAM_REDIRECT_URI = "redirect_uri";
public static final String DIALOG_PARAM_RESPONSE_TYPE = "response_type";
public static final String DIALOG_PARAM_RETURN_SCOPES = "return_scopes";
public static final String DIALOG_PARAM_SCOPE = "scope";
public static final String DIALOG_PARAM_DEFAULT_AUDIENCE = "default_audience";
public static final String DIALOG_REREQUEST_AUTH_TYPE = "rerequest";
public static final String DIALOG_RESPONSE_TYPE_TOKEN = "token";
public static final String DIALOG_RETURN_SCOPES_TRUE = "true";
// URL components
private static final String GRAPH_VIDEO_URL_FORMAT = "https://graph-video.%s";
private static final String GRAPH_URL_FORMAT = "https://graph.%s";
public static final String GRAPH_API_VERSION = "v2.1";
private static final String LEGACY_API_VERSION = "v1.0";
public static final Collection<String> errorsProxyAuthDisabled =
Utility.unmodifiableCollection("service_disabled", "AndroidAuthKillSwitchException");
public static final Collection<String> errorsUserCanceled =
Utility.unmodifiableCollection("access_denied", "OAuthAccessDeniedException");
public static final String getDialogAuthority() {
return String.format(DIALOG_AUTHORITY_FORMAT, Settings.getFacebookDomain());
}
public static final String getGraphUrlBase() {
return String.format(GRAPH_URL_FORMAT, Settings.getFacebookDomain());
}
public static final String getGraphVideoUrlBase() {
return String.format(GRAPH_VIDEO_URL_FORMAT, Settings.getFacebookDomain());
}
public static final String getAPIVersion() {
if (Settings.getPlatformCompatibilityEnabled()) {
return LEGACY_API_VERSION;
}
return GRAPH_API_VERSION;
}
}
| [
"[email protected]"
] | |
a116c8319e11418a990c02acc12ce8eec10ed682 | 48658cca94e62179ad8b82bb4f0210e3c0a88363 | /sd-store-cli/src/test/java/pt/ulisboa/tecnico/sdis/store/cli/test/StoreFrontendMockTest.java | dcb1d050fa04c920ffb85548cf73a7ba2849a954 | [] | no_license | Code-hound/ES | 11a17b446ec460bffed7cb5c04ff6bf90397ebe2 | 1e49f6eafd6f8ab913425e5552405a5c3698544b | refs/heads/master | 2021-01-10T18:16:07.062819 | 2015-05-25T21:29:54 | 2015-05-25T21:29:54 | 52,991,998 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,797 | java | package pt.ulisboa.tecnico.sdis.store.cli.test;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Map;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.WebServiceException;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import mockit.Expectations;
import mockit.Injectable;
import mockit.Mocked;
import mockit.NonStrictExpectations;
import mockit.integration.junit4.JMockit;
import static mockit.Deencapsulation.*;
import pt.ulisboa.tecnico.sdis.store.ws.DocUserPair;
import pt.ulisboa.tecnico.sdis.store.ws.SDStore;
import pt.ulisboa.tecnico.sdis.store.ws.SDStore_Service;
import store.cli.StoreFrontend;
import ws.handler.HeaderHandler;
@RunWith(JMockit.class)
public class StoreFrontendMockTest {
private static String goodContent = "When I was young coach called me The Tiger";
private static String badContent = "I always had a knack for the danger";
private static String oldTime;
private static String newTime;
ArrayList<SDStore> endpoints = new ArrayList<SDStore>();
@Before
public void setup() {
newTime = new DateTime().toString();
oldTime = new DateTime(newTime).minusMinutes(5).toString();
}
@Test
public void mockFrontend_OneWrongValues(
@Injectable final Map<String, Object> requestContext,
@Mocked final SDStore endpoint,
@Mocked final DocUserPair pair)
throws Exception {
endpoints.add(endpoint);
endpoints.add(endpoint);
endpoints.add(endpoint);
final StoreFrontendMock frontend = new StoreFrontendMock();
frontend.setEndpoints(endpoints);
new NonStrictExpectations(frontend) {{
endpoint.load(pair);
returns (badContent.getBytes(), goodContent.getBytes(), goodContent.getBytes());
frontend.getTime();
returns(oldTime, newTime, newTime);
frontend.getID();
returns("1", "1", "1");
}};
byte[] loadedContent = frontend.load(pair);
assertEquals(new String(goodContent), new String(loadedContent));
}
@Test
public void mockFrontend_TwoWrongValues(
@Injectable final Map<String, Object> requestContext,
@Mocked final SDStore endpoint,
@Mocked final DocUserPair pair)
throws Exception {
endpoints.add(endpoint);
endpoints.add(endpoint);
endpoints.add(endpoint);
final StoreFrontendMock frontend = new StoreFrontendMock();
frontend.setEndpoints(endpoints);
new NonStrictExpectations(frontend) {{
endpoint.load(pair);
returns (badContent.getBytes(), goodContent.getBytes(), badContent.getBytes());
frontend.getTime();
returns(oldTime, newTime, oldTime);
frontend.getID();
returns("1", "1", "1");
}};
byte[] loadedContent = frontend.load(pair);
assertEquals(new String(goodContent), new String(loadedContent));
}
}
| [
"[email protected]"
] | |
c67b5d92aac0f5d2981027f5a1a6ea9a80dc036c | 270ca671143f18792910e127e08741d42b3b2a9d | /00-cms/src/main/java/com/bjpowernode/cms/sys/roleUser/service/IRoleUserService.java | 6e6e667d58ab08fd8d46c1edc3adaf8037370f1e | [] | no_license | startshineye/e-commerce | c52670b9241049643c54444fa657146f3ff16a26 | e07c8c15c83da8dc3752af1b08721f83ba66b125 | refs/heads/master | 2020-03-29T14:27:33.555473 | 2016-07-25T10:25:51 | 2016-07-25T10:25:51 | 62,574,213 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 542 | java | package com.bjpowernode.cms.sys.roleUser.service;
import java.util.List;
import com.bjpowernode.cms.sys.roleUser.model.RoleUser;
import com.bjpowernode.cms.sys.roleUser.model.RoleUserCond;
/**
* 用户角色关联Service接口类
*
* @author GZZ
* @date 2014-02-15 12:59:49
*/
public interface IRoleUserService {
/**
* 批量关联用户
*/
public int doConnect(String[] funcid, String roleid);
/**
* @方法说明:按条件查询不分页列表(使用范型)
*/
public List<RoleUser> queryAllObj(RoleUserCond cond);
}
| [
"[email protected]"
] | |
15fa2cce63ec8022f72c37108062c4065cb33cdf | 949f4a688e6fe03c798cd94c23191d3e62a0feb9 | /UiFramework/app/src/main/java/com/ui/Adapter/HistoryAdapter.java | d55d667e65182ddd4c3905ad511fb50f5f1882cd | [] | no_license | 1794208519/lazyearn | 9e6fccc019eb76cbfed6f41e5c24202408547323 | f754aff0dbd6e61863b21cfc371c433a20900c9c | refs/heads/master | 2021-09-03T02:44:22.958402 | 2018-01-05T01:29:57 | 2018-01-05T01:29:57 | 112,985,891 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,353 | java | package com.ui.Adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.uidemo.R;
import com.utils.Urlutils;
import org.xutils.image.ImageOptions;
import org.xutils.x;
import java.util.ArrayList;
import java.util.List;
/**
* Created by qq944 on 2017/11/3.
*/
public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.MyViewHolder>{
private List<String> keywordList = new ArrayList<String>();
private Context context;
private HistoryAdapter.OnItemClickListener mOnItemClickListener = null;
public HistoryAdapter(List<String> keywordList, Context context) {
this.keywordList = keywordList;
this.context = context;
}
public HistoryAdapter() {
}
@Override
public HistoryAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.layout_history_item, parent, false);
HistoryAdapter.MyViewHolder holder = new HistoryAdapter.MyViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(final HistoryAdapter.MyViewHolder holder, final int position) {
holder.tv.setText(keywordList.get(keywordList.size()-position-1));
if (mOnItemClickListener != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOnItemClickListener.onItemClick(holder.itemView, position);
}
});
}
}
@Override
public int getItemCount() {
return keywordList.size();
}
class MyViewHolder extends RecyclerView.ViewHolder
{
TextView tv;
public MyViewHolder(View view)
{
super(view);
tv = (TextView) view.findViewById(R.id.tv_history);
}
}
public interface OnItemClickListener{
void onItemClick(View v, int position);
}
public void setOnItemClickListener(HistoryAdapter.OnItemClickListener onItemClickListener ){
this. mOnItemClickListener=onItemClickListener;
}
}
| [
"[email protected]"
] | |
402b6fca92ce99f15288b2a115a2c6acc81a6827 | 864865e8b4e2fa00c71a52bdd6dc3a2723a602b6 | /src/main/java/br/com/compasso/votacao/api/adapter/TopicResponse.java | 6eb16af88bdcb59dc256b07f949d9b2e7811c41d | [] | no_license | eliasmeyer/compasso-votemanager-api | 66b2a5deff740ef5cf6c28033db21ff725ed1cbc | 461ee63e50458535489c66cb92a8e24e8d7af836 | refs/heads/master | 2022-11-27T03:33:28.550791 | 2020-08-03T15:18:16 | 2020-08-03T15:18:16 | 270,192,426 | 0 | 0 | null | 2020-07-30T19:05:48 | 2020-06-07T04:31:32 | Java | UTF-8 | Java | false | false | 312 | java | package br.com.compasso.votacao.api.adapter;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class TopicResponse {
private Long id;
private String title;
private String description;
private String createdAt;
private ResultResponse result;
}
| [
"[email protected]"
] | |
65d0f72bdb1c4bf84e398cac4489d96851251f6e | d4850e773872f333b78f3056b52b12c501a4ce5e | /baselib/src/main/java/com/litesuits/android/view/BreathingViewHelper.java | 12afdb14e8fc7fcdda28807c14ea9a05fbdd1990 | [] | no_license | rockgarden/MyCard | 0c359aa3611c16a6384cf3f6705f955dd42508a0 | 526de6b66a1b9c0ef4d4a3b596bc3fcd74eef898 | refs/heads/master | 2020-12-14T03:56:53.702161 | 2016-07-29T05:59:26 | 2016-07-29T05:59:26 | 46,687,989 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 8,060 | java | /*
* The MIT License (MIT)
*
* Copyright (c) 2015 drakeet
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.litesuits.android.view;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Build;
import android.view.View;
import java.util.Date;
/**
* 给View增加呼吸效果
* https://github.com/drakeet/BreathingViewHelper
* 用法:
* // start
* BreathingViewHelper.setBreathingBackgroundColor(findViewById(R.id.any_view),getResources().getColor(R.color.md_red_200));
* // stop
* BreathingViewHelper.stopBreathingBackgroundColor(findViewById(R.id.any_view));
*
* Created by drakeet on 6/12/15.
*/
public class BreathingViewHelper {
private static AsyncTask<Void, Integer, Void> mAsyncTask;
private static int mColor;
private static boolean mCancelled;
public static void setBreathingBackgroundColor(final View view, final int color) {
Date firstDate = new Date();
final long firstTime = firstDate.getTime();
mAsyncTask = new AsyncTask<Void, Integer, Void>() {
int n = 1, t = 3000;
boolean increaseN;
@Override
protected Void doInBackground(Void... params) {
while (!isCancelled() || !mCancelled) {
Date currentDate = new Date();
long diffTime = currentDate.getTime() - firstTime;
if (diffTime > n * t) {
increaseN = true;
}
if (increaseN) {
n++;
increaseN = false;
}
double y = getBreathingY(diffTime, n, t);
int alpha = (int) ((y * 0.618f + 0.382f) * 255);
int resultColor = setAlphaComponent(color, alpha);
mColor = resultColor;
publishProgress(resultColor);
try {
Thread.sleep(38);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return null;
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
view.setBackgroundColor(values[0]);
}
};
executeAsyncTask(mAsyncTask);
}
public static void stopBreathingBackgroundColor(View view) {
if (mAsyncTask != null) {
BreathingViewHelper.mAsyncTask.cancel(true);
} else {
mCancelled = true;
}
smoothToOrigin(view);
}
@SafeVarargs
private static <Params, Progress, Result> void executeAsyncTask(
AsyncTask<Params, Progress, Result> task, Params... params) {
if (Build.VERSION.SDK_INT >= 11) {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
} else {
task.execute(params);
}
}
private static double getBreathingY(long time, int n, int t) {
float k = 1.0f / 3;
float pi = 3.1415f;
float x = time / 1000.0f;
t = (int) (t / 1000.0f);
if (x >= ((n - 1) * t) && x < ((n - (1 - k)) * t)) {
double i = pi / (k * t) * ((x - (0.5f * k * t)) - (n - 1) * t);
return 0.5f * Math.sin(i) + 0.5f;
} else if (x >= ((n - (1 - k)) * t) && x < n * t) {
double j = pi / ((1 - k) * t) * ((x - (0.5f * (3 - k) * t)) - (n - 1) * t);
double one = 0.5f * Math.sin(j) + 0.5f;
return one * one;
}
return 0;
}
private static double getSinY(long time) {
return 0.5f * Math.sin(3 * time / 1000.0f) + 0.5;
}
private static void smoothToOrigin(final View view) {
Date firstDate = new Date();
final long firstTime = firstDate.getTime();
executeAsyncTask(new AsyncTask<Void, Integer, Void>() {
int n = 1, t = 4000;
boolean increaseN;
@Override
protected Void doInBackground(Void... params) {
while (!isCancelled()) {
Date currentDate = new Date();
long diffTime = currentDate.getTime() - firstTime;
double y = getCosY(diffTime);
int alpha = (int) (y * 255);
int resultColor = setAlphaComponent(mColor, alpha);
if (alpha < 0.038 * 255) {
publishProgress(0);
this.cancel(true);
return null;
}
publishProgress(resultColor, alpha);
try {
Thread.sleep(38);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return null;
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
view.setBackgroundColor(values[0]);
}
});
}
public static void smoothToTransparentFromColor(final View view, final int color) {
Date firstDate = new Date();
final long firstTime = firstDate.getTime();
executeAsyncTask(new AsyncTask<Void, Integer, Void>() {
int n = 1, t = 4000;
boolean increaseN;
@Override
protected Void doInBackground(Void... params) {
while (!isCancelled()) {
Date currentDate = new Date();
long diffTime = currentDate.getTime() - firstTime;
double y = getCosY(diffTime);
int alpha = (int) (y * Color.alpha(color));
int resultColor = setAlphaComponent(color, alpha);
if (alpha < 0.038 * 255) {
publishProgress(0);
this.cancel(true);
return null;
}
publishProgress(resultColor, alpha);
try {
Thread.sleep(38);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return null;
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
view.setBackgroundColor(values[0]);
}
});
}
private static double getCosY(long diffTime) {
return 0.5f * Math.cos(3 * diffTime / 1000.0f) + 0.5;
}
public static int setAlphaComponent(int color, int alpha) {
if (alpha < 0 || alpha > 255) {
throw new IllegalArgumentException("alpha must be between 0 and 255.");
}
return (color & 0x00ffffff) | (alpha << 24);
}
}
| [
"ro"
] | ro |
6bd798ae15e656eb82ea7f15c2cc860a5551fc9a | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/4/4_0adca6c6cb9ce8976fe725feed90850e9631be65/RenderTileWardChest/4_0adca6c6cb9ce8976fe725feed90850e9631be65_RenderTileWardChest_t.java | b6888289f2ca97dd27b839f82cd3476621858841 | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 4,204 | java | /**
* This class was created by <Vazkii>. It's distributed as
* part of the ThaumicTinkerer Mod.
*
* ThaumicTinkerer is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* ThaumicTinkerer is a Derivative Work on Thaumcraft 3.
* Thaumcraft 3 Azanor 2012
* (http://www.minecraftforum.net/topic/1585216-)
*
* File Created @ [5 May 2013, 18:23:31 (GMT)]
*/
package vazkii.tinkerer.client.render.tile;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.tinkerer.client.util.handler.ClientTickHandler;
import vazkii.tinkerer.lib.LibMisc;
import vazkii.tinkerer.lib.LibResources;
import vazkii.tinkerer.tile.TileEntityWardChest;
import vazkii.tinkerer.util.helper.MiscHelper;
public class RenderTileWardChest extends TileEntitySpecialRenderer {
ModelChest chestModel;
public RenderTileWardChest() {
chestModel = new ModelChest();
}
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
int meta = tileentity.worldObj == null ? 3 : tileentity.getBlockMetadata();
int rotation = meta == 2 ? 180 : meta == 3 ? 0 : meta == 4 ? 90 : 270;
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslatef((float)x, (float)y , (float)z);
bindTextureByName(LibResources.MODEL_WARD_CHEST);
GL11.glTranslatef(0F, 1F, 1F);
GL11.glScalef(1F, -1F, -1F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glRotatef(rotation, 0F, 1F, 0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
chestModel.chestBelow.render(LibMisc.MODEL_DEFAULT_RENDER_SCALE);
chestModel.chestKnob.render(LibMisc.MODEL_DEFAULT_RENDER_SCALE);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslatef((float) x, (float) y, (float) z);
renderOverlay((TileEntityWardChest) tileentity);
GL11.glTranslatef((float) -x, (float) -y, (float) -z);
bindTextureByName(LibResources.MODEL_WARD_CHEST);
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(false);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslatef((float)x, (float)y , (float)z);
bindTextureByName(LibResources.MODEL_WARD_CHEST);
GL11.glTranslatef(0F, 1F, 1F);
GL11.glScalef(1F, -1F, -1F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glRotatef(rotation, 0F, 1F, 0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
chestModel.chestLid.render(LibMisc.MODEL_DEFAULT_RENDER_SCALE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
}
private void renderOverlay(TileEntityWardChest chest) {
Minecraft mc = MiscHelper.getMc();
mc.renderEngine.bindTexture(LibResources.MISC_WARD_CHEST_OVERLAY);
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glTranslatef(0.5F, 0.65F, 0.5F);
float deg = (float) ((chest.worldObj == null ? ClientTickHandler.clientTicksElapsed : chest.ticksExisted) % 360F);
GL11.glRotatef(deg, 0F, 1F, 0F);
GL11.glColor4f(1F, 1F, 1F, 1F);
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
tess.addVertexWithUV(-0.45, 0, 0.45, 0, 1);
tess.addVertexWithUV(0.45, 0, 0.45, 1, 1);
tess.addVertexWithUV(0.45, 0, -0.45, 1, 0);
tess.addVertexWithUV(-0.45, 0, -0.45, 0, 0);
tess.draw();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
}
| [
"[email protected]"
] | |
bba41b589313e349ee87f9c8dcc9be19d088657d | a7fba3a1904d9de56dbf36d979c0802c49aa7ce5 | /security/src/main/java/org/xipki/security/bc/XiXDHContentVerifierProvider.java | abb7985923305e3146058e1d8c9bc10f1050cfa2 | [
"Apache-2.0"
] | permissive | mvandermeulen/xipki | 3d4895d06ac461b84a29b1ea7c966ab918d13608 | 3cb25e0f055778b80768a7d6820a44b973d29027 | refs/heads/master | 2022-11-25T03:08:25.064360 | 2020-08-01T20:34:00 | 2020-08-01T20:34:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,411 | java | /*
*
* Copyright (c) 2013 - 2020 Lijun Liao
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xipki.security.bc;
import static org.xipki.util.Args.notNull;
import java.io.IOException;
import java.io.OutputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PublicKey;
import java.util.Arrays;
import javax.crypto.KeyAgreement;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.crmf.DhSigStatic;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.crypto.RuntimeCryptoException;
import org.bouncycastle.operator.ContentVerifier;
import org.bouncycastle.operator.ContentVerifierProvider;
import org.bouncycastle.operator.OperatorCreationException;
import org.xipki.security.DHSigStaticKeyCertPair;
import org.xipki.security.EdECConstants;
import org.xipki.security.HashAlgo;
import org.xipki.security.ObjectIdentifiers.Xipki;
/**
* {@link ContentVerifierProvider} for the algorithm X25519/X448 static HMAC (XiPKI own
* algorithm, based on RFC 6955).
*
* @author Lijun Liao
*/
// CHECKSTYLE:SKIP
public class XiXDHContentVerifierProvider implements ContentVerifierProvider {
//CHECKSTYLE:SKIP
private static class XDHContentVerifier implements ContentVerifier {
private class HmacOutputStream extends OutputStream {
@Override
public void write(int bb) throws IOException {
hmac.update((byte) bb);
}
@Override
public void write(byte[] bytes) throws IOException {
hmac.update(bytes, 0, bytes.length);
}
@Override
public void write(byte[] bytes, int off, int len) throws IOException {
hmac.update(bytes, off, len);
}
} // class HmacOutputStream
private final AlgorithmIdentifier algId;
private final HmacOutputStream outputStream;
private final Mac hmac;
private final SecretKey macKey;
private XDHContentVerifier(AlgorithmIdentifier algId, Mac hmac, SecretKey macKey) {
this.algId = algId;
this.hmac = hmac;
this.macKey = macKey;
this.outputStream = new HmacOutputStream();
}
@Override
public AlgorithmIdentifier getAlgorithmIdentifier() {
return algId;
}
@Override
public OutputStream getOutputStream() {
try {
hmac.init(macKey);
} catch (InvalidKeyException ex) {
throw new RuntimeCryptoException("could not init MAC: " + ex.getMessage());
}
return outputStream;
}
@Override
public boolean verify(byte[] expected) {
DhSigStatic dhsig = DhSigStatic.getInstance(expected);
byte[] expectedHashValue = dhsig.getHashValue();
// compute the hashvalue
byte[] hashValue = hmac.doFinal();
return Arrays.equals(expectedHashValue, hashValue);
}
} // class XDHContentVerifier
private final SecretKey hmacKey;
private final String hmacAlgoithm;
private final ASN1ObjectIdentifier sigAlgOid;
public XiXDHContentVerifierProvider(PublicKey verifyKey, DHSigStaticKeyCertPair ownerKeyAndCert)
throws InvalidKeyException {
notNull(verifyKey, "verifyKey");
notNull(ownerKeyAndCert, "ownerKeyAndCert");
String keyAlgName = verifyKey.getAlgorithm();
HashAlgo hash;
if (EdECConstants.X25519.equalsIgnoreCase(keyAlgName)) {
this.sigAlgOid = Xipki.id_alg_dhPop_x25519_sha256;
this.hmacAlgoithm = "HMAC-SHA256";
hash = HashAlgo.SHA256;
} else if (EdECConstants.X448.equalsIgnoreCase(keyAlgName)) {
this.sigAlgOid = Xipki.id_alg_dhPop_x448_sha512;
this.hmacAlgoithm = "HMAC-SHA512";
hash = HashAlgo.SHA512;
} else {
throw new InvalidKeyException("unsupported verifyKey.getAlgorithm(): " + keyAlgName);
}
if (!keyAlgName.equals(ownerKeyAndCert.getPrivateKey().getAlgorithm())) {
throw new InvalidKeyException("verifyKey and ownerKeyAndCert does not match");
}
// compute the secret key
byte[] zz;
try {
KeyAgreement keyAgreement = KeyAgreement.getInstance(keyAlgName, "BC");
keyAgreement.init(ownerKeyAndCert.getPrivateKey());
keyAgreement.doPhase(verifyKey, true);
zz = keyAgreement.generateSecret();
} catch (NoSuchAlgorithmException | NoSuchProviderException
| InvalidKeyException | IllegalStateException ex) {
throw new InvalidKeyException("KeyChange error", ex);
}
// as defined in RFC 6955, raw hash algorithm is used as KDF
// LeadingInfo := Subject Distinguished Name from certificate
byte[] leadingInfo = ownerKeyAndCert.getEncodedSubject();
// TrailingInfo ::= Issuer Distinguished Name from certificate
byte[] trailingInfo = ownerKeyAndCert.getEncodedIssuer();
byte[] k = hash.hash(leadingInfo, zz, trailingInfo);
this.hmacKey = new SecretKeySpec(k, hmacAlgoithm);
} // constructor
@Override
public boolean hasAssociatedCertificate() {
return false;
}
@Override
public X509CertificateHolder getAssociatedCertificate() {
return null;
}
@Override
public ContentVerifier get(AlgorithmIdentifier verifierAlgorithmIdentifier)
throws OperatorCreationException {
ASN1ObjectIdentifier oid = verifierAlgorithmIdentifier.getAlgorithm();
if (!this.sigAlgOid.equals(oid)) {
throw new OperatorCreationException(
"given public key is not suitable for the alogithm " + oid.getId());
}
Mac hmac;
try {
hmac = Mac.getInstance(hmacAlgoithm);
} catch (NoSuchAlgorithmException ex) {
throw new OperatorCreationException(ex.getMessage());
}
return new XDHContentVerifier(verifierAlgorithmIdentifier, hmac, hmacKey);
} // method get
}
| [
"[email protected]"
] | |
fe69f3ffd7efc0cb57e0382553df3b3a5edf3dd5 | bb9b004b4c5d35cafe7ff522852d7720b7b12df4 | /hw0/1.4/SubOptimalMultipleDots.java | 98f87b8b29c3514908ef6f21f7393069872a40e2 | [] | no_license | bharat1910/AI | f0948ee2720b70b7ef89b2850618df1aa1a61c8c | 1355b2b58b30384e49256c34d7315c4e8bbe5ebb | refs/heads/master | 2020-04-14T02:38:13.744991 | 2013-10-29T23:23:33 | 2013-10-29T23:23:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,810 | java | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
/* Helper Class Coordinate */
public class SubOptimalMultipleDots {
class Coordinate{
int x;
int y;
public Coordinate(int x, int y){
this.x=x;
this.y=y;
}
}
class POINT implements Comparable<POINT>{
int x;
int y;
int count;
boolean goalState[][];
int dots_eaten;
int heuristic_value;
int heuristic_value_2;
List<Coordinate> outputSequence;
// Used for BFS, DFS
public POINT(int i, int j, int c, int dots_eaten, boolean goalState[][], List<Coordinate> l) {
x = i;
y = j;
count = c;
this.dots_eaten = dots_eaten;
this.goalState = goalState;
this.outputSequence = l;
}
public POINT(int i, int j, int c, int dots_eaten, boolean goalState[][]) {
x = i;
y = j;
count = c;
this.dots_eaten = dots_eaten;
this.goalState = goalState;
}
// Used for GBFS,A*
public POINT(int i, int j, int c, int dots_eaten, boolean goalState[][], int heuristic_value, List<Coordinate> l) {
x = i;
y = j;
count = c;
this.dots_eaten = dots_eaten;
this.goalState = goalState;
this.heuristic_value = heuristic_value;
this.outputSequence = l;
}
public POINT(int i, int j, int c, int dots_eaten, boolean goalState[][], int heuristic_value, int h_2,List<Coordinate> l) {
x = i;
y = j;
count = c;
this.dots_eaten = dots_eaten;
this.goalState = goalState;
this.heuristic_value = heuristic_value;
this.outputSequence = l;
this.heuristic_value_2 = h_2;
}
// Used for GBFS,A*
public POINT(int i, int j, int c, int dots_eaten, boolean goalState[][], int heuristic_value) {
x = i;
y = j;
count = c;
this.dots_eaten = dots_eaten;
this.goalState = goalState;
this.heuristic_value = heuristic_value;
}
public int findClosestWallDistance(){
int xleft = x;
int ytop = y;
int xright = column - x;
int ybottom = row - y;
return Math.min(xleft, Math.min(ytop, Math.min(xright, ybottom)));
}
@Override
public int compareTo(POINT obj) {
if(heuristic_value != obj.heuristic_value){
return heuristic_value - obj.heuristic_value;
}else{
//return -1*(dots_eaten - obj.dots_eaten);
return -1*(findClosestWallDistance() - obj.findClosestWallDistance());
}
}
}
class Edge implements Comparable<Edge> {
int wt;
int pt1;
int pt2;
Edge(int pt1, int pt2, int wt){
this.pt1 = pt1;
this.pt2 = pt2;
this.wt = wt;
}
@Override
public int compareTo(Edge obj) {
return wt - obj.wt;
}
}
// Variable of the problem.
char[][] maze = new char[100][100];
int starti, startj, number_dots;
int row, column;
List<Coordinate> dots;
/* Used to store the state information */
class stateNode {
boolean isExpanded;
List<boolean [][]> visitedStates;
// Note we could use primitive arrays with collections but basic primitive type
// List<boolean>l will throw errors.
stateNode(){
isExpanded = false;
visitedStates = new ArrayList<boolean [][]>();
}
}
// Since arrays in java are passed by reference and we want to
// keep separate state for each path traversed hence we will
// have to perform deep copy operation.
public void run() throws IOException
{
@SuppressWarnings("resource")
BufferedReader reader = new BufferedReader(new FileReader("hw0/1.4/maze_medium.txt"));
String line = null;
int count = 0;
number_dots = 0;
int sz = 0;
dots = new ArrayList<Coordinate>();
while ((line = reader.readLine()) != null) {
sz= line.length();
for (int i=0; i<sz; i++) {
maze[count][i] = line.charAt(i);
if (maze[count][i] == 'P') {
starti = count;
startj = i;
}
if (maze[count][i] == '.') {
number_dots++;
}
}
count++;
}
row = count;
column = sz;
for(int i=0;i < row;i++){
for(int j=0;j<column;j++){
System.out.print(maze[i][j]);
}
System.out.println();
}
GBF();
}
private void GBF()
{
stateNode shouldVisit[][] = new stateNode[row][column];
for(int i = 0;i < row;i++){
for(int j =0; j<column;j++){
shouldVisit[i][j] = new stateNode();
}
}
System.out.println("rows - " + row + " columns - " + column);
boolean[][] goalState = new boolean[row][column];
int number_nodes_expanded = 0;
int maximum_tree_depth_searched = 1;
Queue<POINT> pq = new PriorityQueue<POINT>();
pq.add(new POINT(starti, startj, 1, 0, goalState, new ArrayList<Coordinate>()));
shouldVisit[starti][startj] = new stateNode();
List<Coordinate> outputSequence = null;
while (!pq.isEmpty()) {
POINT top = (POINT) pq.remove();
int x = top.x, y = top.y, count = top.count;
int dots_eaten = top.dots_eaten;
boolean curr_gs[][] = top.goalState;
List<Coordinate> l = top.outputSequence;
if(maximum_tree_depth_searched < count){
maximum_tree_depth_searched = count;
}
// Check if we need to expand this node.
if(shouldExpand(x,y, shouldVisit, curr_gs)){
//System.out.println("Expanding - " + x + " " + y);
number_nodes_expanded++;
shouldVisit[x][y].isExpanded = true;
shouldVisit[x][y].visitedStates.add(curr_gs);
if(maze[x][y] == '.' && curr_gs[x][y] == false){
++dots_eaten;
l.add(new Coordinate(x, y));
if(dots_eaten == number_dots){
outputSequence = l;
break;
}
curr_gs[x][y] = true;
shouldVisit[x][y].visitedStates.add(deepCopy(curr_gs));
}
//System.out.println("Dots Eaten - " + dots_eaten);
if (maze[x][y - 1] != '%' ) {
int heuristic_val = computeHeuristicValue(x, y-1, maze, curr_gs, new boolean[row][column],2);
pq.add(new POINT(x, y - 1, count + 1, dots_eaten, deepCopy(curr_gs), heuristic_val,deepCopy(l)));
}
if (maze[x][y + 1] != '%') {
int heuristic_val = computeHeuristicValue(x, y+1, maze, curr_gs, new boolean[row][column],2);
pq.add(new POINT(x, y + 1, count + 1, dots_eaten, deepCopy(curr_gs), heuristic_val, deepCopy(l)));
}
if (maze[x + 1][y] != '%' ) {
int heuristic_val = computeHeuristicValue(x+1, y, maze, curr_gs, new boolean[row][column],2);
pq.add(new POINT(x + 1, y, count + 1, dots_eaten, deepCopy(curr_gs), heuristic_val, deepCopy(l)));
}
if (maze[x - 1][y] != '%' ){
int heuristic_val = computeHeuristicValue(x-1, y, maze, curr_gs, new boolean[row][column],2);
pq.add(new POINT(x - 1, y, count + 1, dots_eaten, deepCopy(curr_gs), heuristic_val, deepCopy(l)));
}
}
}
System.out.println("GBFS");
System.out.println("Number of nodes expanded : " + number_nodes_expanded);
System.out.println("Maximum Tree Depth Searched " + maximum_tree_depth_searched);
char [][]output = new char[row][column];
for(int i=0;i<row;i++){
for(int j=0;j<column;j++){
output[i][j] = maze[i][j];
}
}
int j = 97;
for(int k = 0;k<outputSequence.size();k++){
if(k<=9)
output[outputSequence.get(k).x][outputSequence.get(k).y]=(char)(k+48);
else
output[outputSequence.get(k).x][outputSequence.get(k).y]=(char)(j++);
}
/*for(int i=0;i<row;i++){
for(int k=0;k<column;k++){
System.out.print(output[i][k] + " ");
}
System.out.println();
}*/
System.out.println("---------------------------------------------------------");
}
public int closestDotDistance(int x, int y, char [][]maze, boolean [][]goalState){
int minDist = 9999;
int xclosest = -1;
int yclosest = -1;
int xfarthest = xclosest;
int yfarthest = yclosest;
for(int i = 0; i< row; i++){
for(int j = 0; j < column; j++){
if(maze[i][j] == '.' && goalState[i][j] == false) {
if((Math.abs(x-i) + Math.abs(y-j) < minDist)){
minDist = Math.min(minDist, (Math.abs(x-i) + Math.abs(y-j)));
xclosest = i;
yclosest = j;
}
}
}
}
if(minDist == 9999) return 0;
return minDist;
//int degree = 0;
}
public static void main(String[] args) throws IOException
{
SubOptimalMultipleDots main = new SubOptimalMultipleDots();
main.run();
System.exit(0);
}
/*
* Below is a list of the helper functions
* that are used to perform specific tasks.
*/
/*
* This function is used for deep copying of the boolean array.
*/
public boolean[][] deepCopy(boolean[][] original) {
if (original == null) {
return null;
}
boolean[][] result = new boolean[original.length][];
for (int i = 0; i < original.length; i++) {
result[i] = Arrays.copyOf(original[i], original[i].length);
}
return result;
}
/*
* This function is used for deep copying of the list of coordinates.
*/
public List<Coordinate> deepCopy(List<Coordinate> original) {
if (original == null) {
return null;
}
List<Coordinate> result = new ArrayList<Coordinate>();
for (int i = 0; i < original.size(); i++) {
int x = original.get(i).x;
int y = original.get(i).y;
result.add(new Coordinate(x, y));
}
return result;
}
/*
* Computes the minimal spanning tree for a list of dots.
*/
private int computeMinimalSpanningTreeWeight(List<Coordinate> dots){
// build the graph using dots;
int sz = dots.size();
int graph[][] = new int[sz][sz];
int mst[][] = new int[sz][sz];
Queue<Edge> queue = new PriorityQueue<Edge>();
for(int i = 0;i<sz;i++){
for(int j = i+1;j<sz;j++){
// compute distance between node i and node j
Coordinate p = dots.get(i);
Coordinate q = dots.get(j);
int wt = Math.abs(p.x - q.x) + Math.abs(p.y - q.y);
graph[i][j] = wt;
queue.add(new Edge(i,j,wt));
}
}
boolean chosenNodes[] = new boolean[sz];
List<Integer> edges = new ArrayList<Integer>();
int result = 0;
while(queue.size()>0){
Edge e = queue.remove();
// Check if we can select this edge
if(edges.size() == 0 || (chosenNodes[e.pt1] == false && chosenNodes[e.pt2] ==false)){
result = result + e.wt;
edges.add(e.wt);
chosenNodes[e.pt1]=true;
chosenNodes[e.pt2]=true;
mst[e.pt1][e.pt2]=e.wt;
mst[e.pt2][e.pt1]=e.wt;
}
else if((chosenNodes[e.pt1] == true && chosenNodes[e.pt2] ==false) || (chosenNodes[e.pt1] == false && chosenNodes[e.pt2] == true)){
result = result + e.wt;
edges.add(e.wt);
chosenNodes[e.pt1]=true;
chosenNodes[e.pt2]=true;
mst[e.pt1][e.pt2]=e.wt;
mst[e.pt2][e.pt1]=e.wt;
}else{
continue;
}
// Check for the terminating condition.
boolean allVerticesSelected = true;
for(int k = 0;k<sz;k++){
allVerticesSelected = allVerticesSelected & chosenNodes[k];
}
if(allVerticesSelected) break;
}
// Now we need to traverse the mst to find the total path cost.
result = computeCostofMST(0, mst, new boolean[sz][sz]);
return result;
}
int computeCostofMST(int row,int mst[][], boolean visited[][]){
int result = 0;
for(int k =0;k<mst.length;k++){
if(mst[row][k]!=0 && visited[row][k] == false){
visited[row][k] = true;
visited[k][row] = true;
result = result + mst[row][k] + computeCostofMST(k, mst, visited);
}
}
return result;
}
private int findExtremeDistance(int P, List<Coordinate> pts, boolean []visited){
int result = 0;
visited[P] = true;
int min = +9999;
int nxt = -1;
for(int i = 0;i<pts.size();i++){
if(visited[i] == false){
int u = pts.get(i).x;
int v = pts.get(i).y;
int dist = Math.abs(u-pts.get(P).x) + Math.abs(v-pts.get(P).y);
if(dist<min){
nxt = i;
min = dist;
}
}
}
if(min == 9999){return 0;}
else return min + findExtremeDistance(nxt, pts, visited);
}
/*
* Computes the heuristic-value of a point
* type - 1 : admissible heuristics
* type - 2 : non-admissible heuristics
*/
public int computeHeuristicValue(int x, int y, char [][]maze, boolean [][]goalState, boolean visited[][], int type){
if(type==1){
Coordinate xminCoordinate=null,xmaxCoordinate=null,yminCoordinate=null,ymaxCoordinate=null,P;
P = new Coordinate(x, y);
int xmin = 9999, ymin = 9999;
int xmax = -1, ymax = -1;
for(int i = 0; i< row; i++){
for(int j = 0; j < column; j++){
if(maze[i][j] == '.' && goalState[i][j] == false) {
if(xmin < i){
xmin = i;
xminCoordinate = new Coordinate(xmin, j);
}
if(xmax > i){
xmax = i;
xminCoordinate = new Coordinate(xmax, j);
}
if(ymin < j){
ymin = j;
yminCoordinate = new Coordinate(i, ymin);
}
if(ymax > j){
ymax = j;
xminCoordinate = new Coordinate(i,ymax);
}
}
}
}
List<Coordinate> l1 = new ArrayList<Coordinate>();
l1.add(P);
l1.add(xmaxCoordinate);
l1.add(xminCoordinate);
l1.add(yminCoordinate);
l1.add(ymaxCoordinate);
int d = findExtremeDistance(0,l1, new boolean[l1.size()]);
List<Integer> l = new ArrayList<Integer>();
l.add(Math.abs(x-xmax));
l.add(Math.abs(x-xmin));
l.add(Math.abs(y-ymin));
l.add(Math.abs(y-ymax));
Collections.sort(l);
int h_1 = 2*(l.get(0) + l.get(1) + l.get(2)) + l.get(3);
//int h_1 = l.get(3);
dots.add(new Coordinate(x, y));
for(int i = 0; i< row; i++){
for(int j = 0; j < column; j++){
if(maze[i][j] == '.' && goalState[i][j] == false) {
dots.add(new Coordinate(i, j));
}
}
}
int h_2 = computeMinimalSpanningTreeWeight(dots);
dots.clear();
return d;
//return Math.max(h_1, Math.max(h_2, d));
}else{
int min = +99999;
int xNext=-1, yNext=-1;
visited[x][y] = true;
for(int i = 0; i< row; i++){
for(int j = 0; j < column; j++){
if(maze[i][j] == '.' && goalState[i][j] == false && visited[i][j] == false) {
if((Math.abs(x-i) + Math.abs(y-j)) < min){
min = Math.abs(x-i) + Math.abs(y-j);
xNext=i;
yNext=j;
}
}
}
}
if(min == 99999) return 0;
else return min + computeHeuristicValue(xNext, yNext, maze, goalState, visited,2);}
}
/*
*
*/
private boolean shouldExpand(int x, int y, stateNode shouldVisit[][], boolean [][]currState){
if(shouldVisit[x][y].isExpanded == false){
return true;
}else{
// Check for what output states have we expanded this node
for(int i = 0; i < shouldVisit[x][y].visitedStates.size(); i++){
boolean visitedGoalState[][] = shouldVisit[x][y].visitedStates.get(i);
boolean tmp = true;
for(int l = 0;l< row;l++){
for(int m = 0;m < column;m++){
if(currState[l][m] == visitedGoalState[l][m]) tmp = tmp & true;
else tmp = tmp & false;
}
}
if(tmp == true) return false;
}
return true;
}
}
} | [
"[email protected]"
] | |
687f6b9a4e6de8a6a88e283c7fac582c8c67ff36 | 8967ebc08823e7a7b2598ca582bab1647380ade3 | /Circulo/app/src/main/java/com/example/ines/circulo/dependencyinjection/fragment/FragmentComponent.java | 939d49447eb8aa4b5b180ee816b7f62f6864bd1b | [] | no_license | inessgil/App_Circulo | 8617ea8eae1147c9587e2963a50c1bb1c237d554 | 163da52df1895e51a65f8e2df487c71fc84bbf4e | refs/heads/master | 2020-03-22T06:12:34.660132 | 2018-07-26T11:27:54 | 2018-07-26T11:27:54 | 139,618,067 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 291 | java | package com.example.ines.circulo.dependencyinjection.fragment;
import com.example.ines.circulo.dependencyinjection.scope.PerFragment;
import dagger.Subcomponent;
@PerFragment
@Subcomponent(modules = {FragmentModule.class, FragmentViewModule.class})
public interface FragmentComponent {
}
| [
"[email protected]"
] | |
32aaeda0f38fcff7be5239c8397b3052a8277e3a | b82b459b0252e4416628d2202c9709a9583619bc | /src/test/java/com/etl/GameMysqlTest.java | 838a3388b0d20ec6c8f5f7923b9dbd231cfbd0d0 | [] | no_license | Karlzzb/tsied_etl2 | d0de20ede59f350e56dc3943c08d672d019e01c5 | 4398cb523491b94a37dadcff46f72a0e7528cbce | refs/heads/master | 2021-01-01T05:18:56.696576 | 2016-05-16T03:27:49 | 2016-05-16T03:27:49 | 58,029,396 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,387 | java | package com.etl;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.etl.dao.entity.GameMysql;
import com.etl.service.IGameService;
/**
* @author Rainisic
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "../../applicationContext.xml")
public class GameMysqlTest extends AbstractJUnit4SpringContextTests {
@Autowired
private IGameService gameService;
public IGameService getGameMysqlService() {
return gameService;
}
public void setTestMysqlService(IGameService gameService) {
this.gameService = gameService;
}
// @Test
// public void saveTest() {
// TestMysql test = new TestMysql();
// test.setTestKey("啊伯特");
// test.setTestValue(19);
// //testMysqlService.saveTest(test);
// }
@Test
public void findTest() {
GameMysql game = new GameMysql();
// game.setGid(0);
List<GameMysql> gameList = gameService.findGameByGame(game);
for (GameMysql gameMysql : gameList) {
System.out.println("============" + gameMysql.getTitle());
System.out.println("============" + gameMysql.getGid());
}
}
}
| [
"[email protected]"
] | |
6c1ede7d28b1dcbec11f33db438e1abe1d4d460f | 0df784bbe5dec86c47715944fb49282b7e40c9a5 | /src/de/hdm/itprojekt/client/gui/LeftSideFrame.java | d21f2cd4133a06276474a9c28c3c40d54d527bfc | [] | no_license | GiuseppeGGalati/itprojekt1819 | 15164d5e4b50a9df23f188ea271ac6381de91f96 | 256a28b1f666b6334bb51c3a8ca128f24692fa20 | refs/heads/master | 2020-04-04T11:26:59.801267 | 2018-12-16T15:29:46 | 2018-12-16T15:29:46 | 155,601,669 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 675 | java | package de.hdm.itprojekt.client.gui;
import com.google.gwt.user.client.ui.HorizontalPanel;
/**
* Abstrakte Klasse für das LeftSideFrame, somit für die Baumstruktur.
*
* @author giuseppegalati
*
*/
public abstract class LeftSideFrame extends HorizontalPanel {
/**
* Automatisch geladene Methode onLoad(). Löscht den Div-Container content
* und ruft die Methode run() auf.
*/
public void onLoad() {
/*
* Bevor wir unsere eigene Formatierung veranslassen, überlassen wir es
* der Superklasse eine Initialisierung vorzunehmen.
*/
super.onLoad();
// RootPanel.get("leftmenutree").clear();
this.run();
}
protected abstract void run();
}
| [
"[email protected]"
] | |
b6bbd3232ccfae311a1c16a3cafea9561c1f5fe7 | d696ceda768f479aa827e345e36798654a6ed6e3 | /week05/src/main/java/com/works/homework2/Order.java | 7fd7bbb715fe9a0e61e2443509805bb65b362e82 | [] | no_license | lsmilek/geekAdvancedWorks | 38af514e96c3779941958a9c4bdaef1e633015f5 | 6a507c6ac25f879a6905ea6c3025683369737980 | refs/heads/main | 2023-06-08T20:15:58.142104 | 2021-06-21T09:45:43 | 2021-06-21T09:45:43 | 364,232,931 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 366 | java | package com.works.homework2;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @ClassName Order
* @Description TODO
* @Author yqr
* @Date 2021/6/3 16:57
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Order {
private String orderId;
private String payType;
}
| [
"[email protected]"
] | |
4e86ae2dca71187826c32a4d1a99c793bdfbeef9 | 79c22fdbb10a47aa1b851f4642f6e7963fc53e7b | /app/src/main/java/com/code_embryo/android/ble/beacon/BeaconKey.java | d0cb9d5886b817f66f174472e1a34af90d1bc521 | [
"MIT"
] | permissive | HirokiTsuihiji/BeaconFinder | 18ce19c320e45a6f46e7b5a25cefbdf8779de3dd | b867f6c105646b968205bbbbaaf639f6bc453555 | refs/heads/master | 2020-12-24T19:37:11.815899 | 2016-04-27T04:12:38 | 2016-04-27T04:12:38 | 57,104,432 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,790 | java | /*
* MIT License
*
* Copyright(c) 2016 Hiroki Tsuihiji
*
* Permission is hereby granted,free of charge,to any person obtaining a copy
* of this software and associated documentation files(the"Software"),to deal
* in the Software without restriction,including without limitation the rights
* to use,copy,modify,merge,publish,distribute,sublicense,and/or sell
* copies of the Software,and to permit persons to whom the Software is
* furnished to do so,subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED"AS IS",WITHOUT WARRANTY OF ANY KIND,EXPRESS OR
* IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER
* LIABILITY,WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE,ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.code_embryo.android.ble.beacon;
import android.annotation.SuppressLint;
/**
* ビーコン情報を元に保存用のキーを作成する
*/
public class BeaconKey {
private final String key;
/**
* ビーコンを登録するキー情報
*
* @param beacon ビーコン情報
*/
@SuppressLint("DefaultLocale")
public BeaconKey(Beacon beacon) {
this.key = beacon.uuid()
+ String.format("%05d", beacon.major())
+ String.format("%05d", beacon.minor());
}
/**
* 作成したキーをString型で返す.
*
* @return String ビーコン情報キー
*/
public String value() {
return key;
}
}
| [
"[email protected]"
] | |
d1d5b93e9121eaa4a91e135749338c6e89c01b96 | ec4d24b0be94d6d1bb33a8066dfd71771ac67cd6 | /src/ch4/t01_reentrantLockTest/MyService.java | e2d7acdffbf106b69d57972b131498f9237f6989 | [] | no_license | Jlif/multi-thread | e89aa601656d575094bc2854878c999e8814718d | 86822d744407a92199b34492dabebfd0d96c5564 | refs/heads/master | 2021-01-20T09:01:08.858356 | 2017-05-16T05:57:56 | 2017-05-16T05:57:56 | 90,212,782 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 389 | java | package ch4.t01_reentrantLockTest;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class MyService {
private Lock lock = new ReentrantLock();
public void testMethod() {
lock.lock();
for (int i = 0; i < 10; i++) {
System.out.println("ThreadName=" + Thread.currentThread().getName() + (" " + (i + 1)));
}
lock.unlock();
}
}
| [
"[email protected]"
] | |
a9231a20a4d149a54d77e823db8bc3097f5e621d | d3af09ab5a8f3bf175a2b82f10a8604d30ffbffc | /app/src/main/java/com/example/ibb/lianxi/MypagerAdapter.java | 3f512f4efbc06e00a096c69201a3131f99c6916d | [] | no_license | zhizhulp/IBB | 30cb8afbdc75367b2bc4d41defeced26185d490c | eb6860cd317036afe2ee39b2b34e2c696e30ed81 | refs/heads/master | 2020-07-13T18:07:42.541714 | 2019-08-29T09:25:36 | 2019-08-29T09:25:36 | 205,127,878 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 833 | java | package com.example.ibb.lianxi;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import java.util.List;
/**
* Created by 张凯雅 on 2018/3/15.
*/
public class MypagerAdapter extends FragmentPagerAdapter {
private List<Fragment> listf;
private List<String> listt;
public MypagerAdapter(FragmentManager fm, List<Fragment> listf, List<String> listt) {
super(fm);
this.listf = listf;
this.listt = listt;
}
@Override
public Fragment getItem(int position) {
return listf.get(position);
}
@Override
public int getCount() {
return listf.size();
}
@Override
public CharSequence getPageTitle(int position) {
return listt.get(position);
}
}
| [
"[email protected]"
] | |
87e4fd10b2d1465a02059b219cc860f6696773ce | f525deacb5c97e139ae2d73a4c1304affb7ea197 | /gitv/src/main/java/com/gala/video/lib/share/uikit/action/model/ApplicationActionModel.java | 5788a8656bcef22fa3b50e8318d4593966c1bb92 | [] | no_license | AgnitumuS/gitv | 93b2359e1bf9f2b6c945298c61c5c6dbfeea49b3 | 242c9a10a0aeb41b9589de9f254e6ce9f57bd77a | refs/heads/master | 2021-08-08T00:50:10.630301 | 2017-11-09T08:10:33 | 2017-11-09T08:10:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,288 | java | package com.gala.video.lib.share.uikit.action.model;
import com.gala.video.lib.framework.core.utils.StringUtils;
import com.gala.video.lib.share.ifmanager.bussnessIF.epg.data.model.ItemDataType;
import com.gala.video.lib.share.uikit.action.data.AppActionData;
import com.gala.video.lib.share.uikit.loader.data.AppStore;
public class ApplicationActionModel extends BaseActionModel<AppStore> {
private AppActionData mData;
public ApplicationActionModel(ItemDataType itemDataType) {
super(itemDataType);
}
public BaseActionModel buildActionModel(AppStore dataSource) {
if (this.mData == null) {
this.mData = new AppActionData();
}
if (dataSource.app_type == 2) {
this.mData.setAppId(StringUtils.parse(dataSource.app_id, 0));
}
if (dataSource.app_type == 4) {
this.mData.setAppDownloadUrl(dataSource.app_download_url);
}
this.mData.setApplicationType(dataSource.app_type);
this.mData.setAppPackageName(dataSource.app_package_name);
this.mData.setAppName(dataSource.app_name);
return this;
}
public void setData(AppActionData data) {
this.mData = data;
}
public AppActionData getData() {
return this.mData;
}
}
| [
"[email protected]"
] | |
2984da5dd2fa7e3b50943c1ade9478caefbb3d24 | 8a5fb7f90d874edfadf3e32d4283fdc3c501a8af | /meteor-client/src/main/java/meteor/plugins/itemcharges/ItemChargeOverlay.java | 3b3fdec2fcd815368d2e487f875798e8052c9210 | [] | no_license | illumineawake/MeteorLite | 9ae1a7e541fca900d91a620e4629c311c5d607a1 | 3660bb4d0bfa96477a586e9642ec97f11ae2f229 | refs/heads/main | 2023-07-13T11:21:49.282006 | 2021-08-25T07:23:31 | 2021-08-25T07:23:31 | 398,165,027 | 1 | 0 | null | 2021-08-20T05:26:33 | 2021-08-20T05:26:32 | null | UTF-8 | Java | false | false | 3,299 | java | /*
* Copyright (c) 2017, Seth <[email protected]>
* Copyright (c) 2019, Aleios <https://github.com/aleios>
* Copyright (c) 2020, Unmoon <https://github.com/unmoon>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package meteor.plugins.itemcharges;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import javax.inject.Inject;
import meteor.ui.FontManager;
import meteor.ui.overlay.WidgetItemOverlay;
import meteor.ui.overlay.components.TextComponent;
import net.runelite.api.widgets.WidgetItem;
class ItemChargeOverlay extends WidgetItemOverlay {
private final ItemChargePlugin itemChargePlugin;
private final ItemChargeConfig config;
@Inject
ItemChargeOverlay(ItemChargePlugin itemChargePlugin, ItemChargeConfig config) {
this.itemChargePlugin = itemChargePlugin;
this.config = config;
showOnInventory();
showOnEquipment();
}
@Override
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem widgetItem) {
int charges;
ItemWithConfig itemWithConfig = ItemWithConfig.findItem(itemId);
if (itemWithConfig != null) {
if (!itemWithConfig.getType().getEnabled().test(config)) {
return;
}
charges = itemChargePlugin.getItemCharges(itemWithConfig.getConfigKey());
} else {
ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId);
if (chargeItem == null) {
return;
}
ItemChargeType type = chargeItem.getType();
if (!type.getEnabled().test(config)) {
return;
}
charges = chargeItem.getCharges();
}
graphics.setFont(FontManager.getRunescapeSmallFont());
final Rectangle bounds = widgetItem.getCanvasBounds();
final TextComponent textComponent = new TextComponent();
textComponent.setPosition(new Point(bounds.x - 1, bounds.y + 15));
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
textComponent.setColor(itemChargePlugin.getColor(charges));
textComponent.render(graphics);
}
}
| [
"[email protected]"
] | |
50c0b9fbd1746e7322cdefbf150eb70c1ec76c9d | 64a2c72c70dc2615ff8ef809c40041fc960fe811 | /serv/filerepo/filerepo.impl/src/main/java/at/kc/tugraz/ss/service/filerepo/impl/fct/activity/SSFileRepoActivityFct.java | f388e104a74be3ca23f50bd08c36a844724e56d6 | [
"Apache-2.0"
] | permissive | xingzhixi/SocialSemanticServer | 4a588492a83768c86a5e102388703e8dd01684d2 | 478c9b4e2907c3848dc23a3bc216d8dbac082a01 | refs/heads/master | 2021-01-16T18:54:04.013089 | 2015-03-16T11:41:36 | 2015-03-16T11:41:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,272 | java | /**
* Code contributed to the Learning Layers project
* http://www.learning-layers.eu
* Development is partly funded by the FP7 Programme of the European Commission under
* Grant Agreement FP7-ICT-318209.
* Copyright (c) 2014, Graz University of Technology - KTI (Knowledge Technologies Institute).
* For a list of contributors see the AUTHORS file at the top-level directory of this distribution.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package at.kc.tugraz.ss.service.filerepo.impl.fct.activity;
import at.kc.tugraz.socialserver.utils.SSLogU;
import at.kc.tugraz.ss.activity.datatypes.enums.SSActivityE;
import at.kc.tugraz.ss.datatypes.datatypes.SSTextComment;
import at.kc.tugraz.ss.datatypes.datatypes.entity.SSUri;
import at.kc.tugraz.ss.serv.err.reg.SSServErrReg;
import at.kc.tugraz.ss.serv.serv.caller.SSServCaller;
import java.util.List;
import sss.serv.err.datatypes.SSErr;
public class SSFileRepoActivityFct{
public static void shareFileWithUser(
final SSUri user,
final SSUri entity,
final List<SSUri> usersToShareWith,
final Boolean saveActivity) throws Exception{
if(!saveActivity){
return;
}
try{
SSServCaller.activityAdd(
user,
SSActivityE.shareFileWithUsers,
entity,
SSUri.asListWithoutNullAndEmpty(usersToShareWith),
SSUri.asListWithoutNullAndEmpty(),
SSTextComment.asListWithoutNullAndEmpty(),
null,
false);
}catch(SSErr error){
switch(error.code){
case notServerServiceForOpAvailable: SSLogU.warn(error.getMessage()); break;
default: SSServErrReg.regErrThrow(error);
}
}catch(Exception error){
SSServErrReg.regErrThrow(error);
}
}
}
| [
"[email protected]"
] | |
f88d397dd4b81b7ea1257527105c76e69dc66297 | ae7ba37caa31a264cda3210e8f2a6360256c30c9 | /src/net/kenevans/heartmonitorsessionviewer/utils/Statistics.java | 01757f3d62cc5be7d686350f44a207fe11e8a09b | [
"MIT"
] | permissive | KennethEvans/heartmonitorsessionviewer | 5c3ec2987499bd3aeb68abd42234cfe604154bdd | 9079d5838cc59f997763c4cf2316ab26de9dd45a | refs/heads/master | 2022-01-16T15:43:03.262302 | 2022-01-09T00:56:15 | 2022-01-09T00:56:15 | 81,690,630 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,922 | java | /*
* Program to generate statistics from an array of doubles
* Created on Apr 15, 2006
* By Kenneth Evans, Jr.
*/
package net.kenevans.heartmonitorsessionviewer.utils;
/**
* Statistics calculates the max, min, mean, and standard deviation for an array
* of doubles. The standard deviation is sample-based and uses n-1, not n;
*
* @author Kenneth Evans, Jr.
*/
public class Statistics
{
private double max = 0.0;
private double min = 0.0;
private double mean = 0.0;
private double sigma = 0.0;
private double rms = 0.0;
private int maxIndex = 0;
private int minIndex = 0;
private int nPoints;
/**
* Statistics constructor
*
* @param array
*/
public Statistics(double[] array) {
int nPoints = array.length;
if(nPoints == 0) return;
max = -Double.MAX_VALUE;
min = Double.MAX_VALUE;
double sum = 0.0;
double sumsq = 0.0;
for(int i = 0; i < nPoints; i++) {
double val = array[i];
if(val > max) {
max = val;
maxIndex = i;
}
if(val < min) {
min = val;
minIndex = i;
}
sum += val;
sumsq += val * val;
}
mean = sum / nPoints;
rms = Math.sqrt(sumsq / nPoints);
sigma = (sumsq - nPoints * mean * mean) / (nPoints - 1);
sigma = Math.sqrt(sigma);
}
/**
* @return Returns the max.
*/
public double getMax() {
return max;
}
/**
* @return Returns the min.
*/
public double getMin() {
return min;
}
/**
* @return Returns the mean.
*/
public double getMean() {
return mean;
}
/**
* @return Returns the rms.
*/
public double getRms() {
return rms;
}
/**
* @return Returns the sample standard deviation, sigma, using n - 1, not n;
*/
public double getSigma() {
return sigma;
}
/**
* @return Returns the maxIndex.
*/
public int getMaxIndex() {
return maxIndex;
}
/**
* @return Returns the minIndex.
*/
public int getMinIndex() {
return minIndex;
}
/**
* @return Returns the number of points.
*/
public int getNPoints() {
return nPoints;
}
/**
* @return Returns a summary of the statistics.
*/
public String getInfo() {
String info = "";
info += "Max: " + max + " at i = " + maxIndex + "\n";
info += "Min: " + min + " at i = " + minIndex + "\n";
info += "Mean: " + mean + "\n";
info += "Sigma: " + sigma + "\n";
info += "RMS: " + rms + "\n";
return info;
}
}
| [
"[email protected]"
] | |
83dfc36f14851f66e197973adc065a9736a0db62 | 453afe85ea5608814b9fbd407854d7691e56ddc1 | /src/main/java/Representation.java | 4b0bdb72cb1694b5684be1b36afe5ea015781407 | [] | no_license | valacuga/2021_repo | 4f1f94e0ad2a87dbf555ada7806c195562c7f5f6 | 38cb3625fe693cc8b034eec8b24c505d94e352bc | refs/heads/master | 2023-02-28T08:06:37.635139 | 2021-02-08T12:18:59 | 2021-02-08T12:18:59 | 325,743,853 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 722 | java | import org.w3c.dom.ls.LSOutput;
import java.util.Arrays;
import java.util.function.DoubleToIntFunction;
public class Representation {
public static int daysRepresented (int [][] trips){
/* your code here */
int arrival=0;
int depart=0;
int days=0;
int [] arr = new int[366];
System.out.println(trips[0][0]);
Arrays.fill(arr, 1);
for (int i = 0; i < trips.length; i++) {
arrival=trips[i][0];
depart=trips[i][1];
for (int j = arrival; j <= depart; j++) {
if (arr[j]!=0){
days++;
arr[j]=0;
}
}
}
return days;
}
} | [
"[email protected]"
] | |
d85b0c1b50615334d182ebf47ac4058247e7b290 | 63f0a2e2c918db544cb58da2636f370bd80a36fe | /JavaPractice/src/org/dimigo/thread/WebServer.java | ae751962960ef99a56d0626a19c816f1e9ad9452 | [] | no_license | hd132521/old | f412d3fa717c371e820cf4eaf7a87b6b8470637b | df26870f3da914187a6bd563039aa2a24cdf573a | refs/heads/master | 2022-10-12T11:38:10.307957 | 2015-11-10T01:53:41 | 2015-11-10T01:53:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,151 | java | package org.dimigo.thread;
import java.net.ServerSocket;
import java.net.Socket;
/**
* <pre>
* org.dimigo.thread
* |_ WebServer
*
* 1. 개요 :
* 2. 작성일 : 2015. 10. 29.
* </pre>
*
* @author : 이름
* @version : 1.0
*/
public class WebServer {
public static void main(String argv[]) throws Exception {
// 서버소켓을 생성한다. 웹서버는 기본적으로 80번 포트를 사용한다..
try(ServerSocket listenSocket = new ServerSocket(80)) {
System.out.println("Webserver starting up on port 80");
System.out.println("(press ctrl-c to exit)");
Socket connectionSocket;
Thread serverThread;
// 반복문을 돌면서 클라이언트의 접속을 받는다.
while((connectionSocket = listenSocket.accept()) != null) {
// 스레드를 생성하여 실행한다.
serverThread = new Thread(new ServerThread3(connectionSocket));
serverThread.start();
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
000f68598f7a48403878e74714ed19e4fdc4e91f | ba991ce12d1800b0a869a83c91ffb3b2c72c8294 | /numInArray.java | 410689f521176341844958789ba3d671bd6281ba | [] | no_license | JasmienSCels/Java_Minerva | 9ac02120834d52b2d074c4bf0100f6909c8efb43 | 7cf85bf5384afa07eaa23a1b915e3dd4f971bfa4 | refs/heads/master | 2021-05-31T16:51:34.641359 | 2016-06-20T11:43:35 | 2016-06-20T11:43:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 744 | java | /*
* Date: June 10th, 2016
* Author: Jasmien Sofie Cels
* Purpose: Java Exercise for Beginners — Arrays, For Loops
* Program: Count how many times a number occurs in an integer array
*/
public class numInArray {
public static void main(String[] args) {
// declare an array of integers
int[] numberline;
//Set array to store X elements
numberline = new int[5];
//initialize elements
numberline[0] = 3;
numberline[1] = 5;
numberline[2] = 4;
numberline[3] = 3;
//Set counter to zero
int counter = 0;
int x = 3;
for(int i = 0; i < 5; i++){
if( numberline[i] == x) {
//Increment counter by one if the value at element i is equal to x
counter += 1;
}
}
System.out.println(counter);
}
} | [
"[email protected]"
] | |
5eebd87fd92971bc8703651aea56a9654978a72c | 529c294a081ccb3400d88e5bfa2f41d19b684520 | /src/main/java/com/cowork/service/UserService.java | d093428f4dc115412a4783f30ef82ce5023765a0 | [] | no_license | BulkSecurityGeneratorProject/cowork | f48b6abf889f90dac658d8bd5580a468bd18ca1e | 4b9429b0696a1bea51e2c320d13a5cf5dbd351ab | refs/heads/master | 2022-12-17T22:48:45.391146 | 2015-11-04T17:01:44 | 2015-11-04T17:01:44 | 296,590,958 | 0 | 0 | null | 2020-09-18T10:36:52 | 2020-09-18T10:36:51 | null | UTF-8 | Java | false | false | 6,836 | java | package com.cowork.service;
import com.cowork.domain.Authority;
import com.cowork.domain.PersistentToken;
import com.cowork.domain.User;
import com.cowork.repository.AuthorityRepository;
import com.cowork.repository.PersistentTokenRepository;
import com.cowork.repository.UserRepository;
import com.cowork.security.SecurityUtils;
import com.cowork.service.util.RandomUtil;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.inject.Inject;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
* Service class for managing users.
*/
@Service
@Transactional
public class UserService {
private final Logger log = LoggerFactory.getLogger(UserService.class);
@Inject
private PasswordEncoder passwordEncoder;
@Inject
private UserRepository userRepository;
@Inject
private PersistentTokenRepository persistentTokenRepository;
@Inject
private AuthorityRepository authorityRepository;
public Optional<User> activateRegistration(String key) {
log.debug("Activating user for activation key {}", key);
userRepository.findOneByActivationKey(key)
.map(user -> {
// activate given user for the registration key.
user.setActivated(true);
user.setActivationKey(null);
userRepository.save(user);
log.debug("Activated user: {}", user);
return user;
});
return Optional.empty();
}
public Optional<User> completePasswordReset(String newPassword, String key) {
log.debug("Reset user password for reset key {}", key);
return userRepository.findOneByResetKey(key)
.filter(user -> {
DateTime oneDayAgo = DateTime.now().minusHours(24);
return user.getResetDate().isAfter(oneDayAgo.toInstant().getMillis());
})
.map(user -> {
user.setPassword(passwordEncoder.encode(newPassword));
user.setResetKey(null);
user.setResetDate(null);
userRepository.save(user);
return user;
});
}
public Optional<User> requestPasswordReset(String mail) {
return userRepository.findOneByEmail(mail)
.filter(user -> user.getActivated() == true)
.map(user -> {
user.setResetKey(RandomUtil.generateResetKey());
user.setResetDate(DateTime.now());
userRepository.save(user);
return user;
});
}
public User createUserInformation(String login, String password, String firstName, String lastName, String email,
String langKey) {
User newUser = new User();
Authority authority = authorityRepository.findOne("ROLE_USER");
Set<Authority> authorities = new HashSet<>();
String encryptedPassword = passwordEncoder.encode(password);
newUser.setLogin(login);
// new user gets initially a generated password
newUser.setPassword(encryptedPassword);
newUser.setFirstName(firstName);
newUser.setLastName(lastName);
newUser.setEmail(email);
newUser.setLangKey(langKey);
// new user is not active
newUser.setActivated(false);
// new user gets registration key
newUser.setActivationKey(RandomUtil.generateActivationKey());
authorities.add(authority);
newUser.setAuthorities(authorities);
userRepository.save(newUser);
log.debug("Created Information for User: {}", newUser);
return newUser;
}
public void updateUserInformation(String firstName, String lastName, String email, String langKey) {
userRepository.findOneByLogin(SecurityUtils.getCurrentLogin()).ifPresent(u -> {
u.setFirstName(firstName);
u.setLastName(lastName);
u.setEmail(email);
u.setLangKey(langKey);
userRepository.save(u);
log.debug("Changed Information for User: {}", u);
});
}
public void changePassword(String password) {
userRepository.findOneByLogin(SecurityUtils.getCurrentLogin()).ifPresent(u-> {
String encryptedPassword = passwordEncoder.encode(password);
u.setPassword(encryptedPassword);
userRepository.save(u);
log.debug("Changed password for User: {}", u);
});
}
@Transactional(readOnly = true)
public Optional<User> getUserWithAuthoritiesByLogin(String login) {
return userRepository.findOneByLogin(login).map(u -> {
u.getAuthorities().size();
return u;
});
}
@Transactional(readOnly = true)
public User getUserWithAuthorities(Long id) {
User user = userRepository.findOne(id);
user.getAuthorities().size(); // eagerly load the association
return user;
}
@Transactional(readOnly = true)
public User getUserWithAuthorities() {
User user = userRepository.findOneByLogin(SecurityUtils.getCurrentLogin()).get();
user.getAuthorities().size(); // eagerly load the association
return user;
}
/**
* Persistent Token are used for providing automatic authentication, they should be automatically deleted after
* 30 days.
* <p/>
* <p>
* This is scheduled to get fired everyday, at midnight.
* </p>
*/
@Scheduled(cron = "0 0 0 * * ?")
public void removeOldPersistentTokens() {
LocalDate now = new LocalDate();
persistentTokenRepository.findByTokenDateBefore(now.minusMonths(1)).stream().forEach(token ->{
log.debug("Deleting token {}", token.getSeries());
User user = token.getUser();
user.getPersistentTokens().remove(token);
persistentTokenRepository.delete(token);
});
}
/**
* Not activated users should be automatically deleted after 3 days.
* <p/>
* <p>
* This is scheduled to get fired everyday, at 01:00 (am).
* </p>
*/
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
DateTime now = new DateTime();
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3));
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
}
}
}
| [
"[email protected]"
] | |
550e2eaec1a46a1e11b09e88a01ba13cf26bee69 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/17/17_223a41242a258a203a1bd1c93760c906dc3005a7/Article/17_223a41242a258a203a1bd1c93760c906dc3005a7_Article_t.java | d4a1f5e8756d28e6613ddbd87955a8500062d7ee | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 5,396 | java | package uk.ac.dundee.computing.aec.jBloggyAppy;
import java.net.URLDecoder;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import uk.ac.dundee.computing.aec.jBloggyAppy.Connectors.ArticleConnector;
import uk.ac.dundee.computing.aec.jBloggyAppy.Connectors.AuthorConnector;
import uk.ac.dundee.computing.aec.jBloggyAppy.Stores.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
/**
* Servlet implementation class Article
*/
public class Article extends HttpServlet {
private static final long serialVersionUID = 1L;
private HashMap FormatsMap = new HashMap();
/**
* @see HttpServlet#HttpServlet()
*/
public Article() {
super();
// TODO Auto-generated constructor stub
FormatsMap.put("Jsp", 0);
FormatsMap.put("xml", 1);
FormatsMap.put("rss", 2);
FormatsMap.put("json",3);
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//Possible Call Methods:
// case 3
// /jBloggyAppy/Article/title return article
//case 4
// /jBloggyAppy/Article/title/rss return all posts as RSS (not implemented)
// /jBloggyAppy/Article/title/json return all posts as JSON (not implemented)
// /jBloggyAppy/Article/title/xml return all posts as XML (not implemented)
String args[]=SplitRequestPath(request);
switch (args.length){
case 3:
System.out.println("Args 2 is"+args[2]);
ReturnArticle(request, response,0,args[2]);
break;
default: System.out.println("Wrong number of arguements in doGet Author "+request.getRequestURI()+" : "+args.length);
break;
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
ArticleStore Article =new ArticleStore();
Article.setauthor(request.getParameter(org.apache.commons.lang.StringEscapeUtils.escapeHtml("Author")));
Article.settitle(request.getParameter(org.apache.commons.lang.StringEscapeUtils.escapeHtml("Title")));
Article.setbody(request.getParameter(org.apache.commons.lang.StringEscapeUtils.escapeHtml("Body")));
Article.settags(request.getParameter(org.apache.commons.lang.StringEscapeUtils.escapeHtml("Tags")));
ArticleConnector au = new ArticleConnector();
au.setHost("134.36.36.151");
RequestDispatcher rd;
if (au.AddArticle(Article)== true){
ReturnArticle(request,response,0,Article.gettitle()); //Return as Jsp only
}else{
rd=request.getRequestDispatcher("RegisterUser.jsp");
}
}
/**
* @see HttpServlet#doPut(HttpServletRequest, HttpServletResponse)
*/
protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doDelete(HttpServletRequest, HttpServletResponse)
*/
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
public void ReturnArticle(HttpServletRequest request, HttpServletResponse response,int Format,String Title) throws ServletException, IOException{
/* Format is one of
* 0 jsp
* 1 xml
* 2 rss
* 3 json
*
*/
ArticleConnector atc = new ArticleConnector();
atc.setHost("134.36.36.150");
System.out.println("Return Post for"+Title);
ArticleStore Article = atc.getArticle(Title);
switch(Format){
case 0: request.setAttribute("Article", Article);
RequestDispatcher rd=null;
try {
rd=request.getRequestDispatcher("/RenderArticle.jsp");
rd.forward(request,response);
}catch(Exception et){
System.out.println("Can't forward to "+ rd.toString());
}
break;
default: System.out.println("Invalid Format in ReturnArticle ");
}
}
private String[] SplitRequestPath(HttpServletRequest request){
String args[] = null;
StringTokenizer st = SplitString(request.getRequestURI());
args = new String[st.countTokens()];
//Lets assume the number is the last argument
int argv=0;
while (st.hasMoreTokens ()) {;
args[argv]=new String();
args[argv]=st.nextToken();
try{
System.out.println("String was "+URLDecoder.decode(args[argv],"UTF-8"));
args[argv]=URLDecoder.decode(args[argv],"UTF-8");
}catch(Exception et){
System.out.println("Bad URL Encoding"+args[argv]);
}
argv++;
}
//so now they'll be in the args array.
// argv[0] should be the user directory
return args;
}
private StringTokenizer SplitString(String str){
return new StringTokenizer (str,"/");
}
}
| [
"[email protected]"
] | |
cb24e505888b08e7ea194bbd8bfb99d80000edbd | 34385ad19a998e884e68d6369dc9e49e93f29465 | /app/src/main/java/com/eugene/spacecenter/data/models/Category.java | af8230c5fa285149dbdfc0272f218563f6a0d5ec | [] | no_license | EugeneJAD/SpaceCenter | 725a8076bea31002ce3d2c39f3572ecdde9fd5b0 | 0b568a0e6383fe3059c236c338edefcdc632998f | refs/heads/master | 2020-05-23T06:23:50.647741 | 2018-10-07T16:39:08 | 2018-10-07T16:39:08 | 70,231,471 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,071 | java | package com.eugene.spacecenter.data.models;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
/**
* Created by Администратор on 08.10.2016.
*/
public class Category {
private int id;
private int imageResId;
private int name;
private Drawable rippleDrawable;
public Category(int id, @DrawableRes int imageResId, Drawable rippleDrawable, int name) {
this.id = id;
this.imageResId = imageResId;
this.name = name;
this.rippleDrawable = rippleDrawable;
}
public int getId() {return id;}
public void setId(int id) {this.id = id;}
public int getImageResId() {return imageResId;}
public void setImageResId(int imageResId) {this.imageResId = imageResId;}
public int getName() {return name;}
public void setName(int name) {this.name = name;}
public Drawable getRippleDrawable() {
return rippleDrawable;
}
public void setRippleDrawable(Drawable rippleDrawable) {
this.rippleDrawable = rippleDrawable;
}
}
| [
"[email protected]"
] | |
fa412bcac86ab9f042ae85c90d9372100f695741 | d5eecac27af6537d51008e3ea866d24c5290fbaf | /src/main/java/com/db1/conta/contaapi/domain/entity/Cliente.java | b97e3f9eb5d616351c9005b912934862514f6d9b | [] | no_license | Joao-gui/conta-api-02 | 4a0222b1c030a878d1e87c26c2d6a76fa3002f6e | 73283201a5ffe66d4d8227a071350fc0c7b38041 | refs/heads/master | 2020-06-27T09:42:05.291091 | 2019-08-06T19:55:31 | 2019-08-06T19:55:31 | 199,916,547 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,347 | java | package com.db1.conta.contaapi.domain.entity;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.springframework.util.Assert;
@Entity
@Table(name = "cliente")
public class Cliente {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "nome", length = 80, nullable = false)
private String nome;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "cliente", fetch = FetchType.LAZY, orphanRemoval = true)
private List<Endereco> endereco = new ArrayList<Endereco>();
// @OneToMany(mappedBy = "cliente", cascade = CascadeType.ALL)
// @JoinColumn(name = "conta_id", nullable = false)
// private List<Conta> conta = new ArrayList<Conta>();
@Column(name = "cpf", length = 20, nullable = false, unique = true)
private String cpf;
protected Cliente() {}
public Cliente (String nome, String cpf) {
Assert.hasText(nome, "Nome é obrigatório.");
Assert.hasText(cpf, "CPF é obrigatório.");
this.nome = nome;
this.cpf = cpf;
}
public void addEndereco(String logradouro, String numero, Cidade cidade, TipoEndereco tipoEndereco, String complemento) {
Endereco endereco = new Endereco(this, logradouro, numero, cidade, tipoEndereco, complemento);
this.endereco.add(endereco);
}
public void addEnderecoCobranca(String logradouro, String numero, Cidade cidade, String complemento) {
this.addEndereco(logradouro, numero, cidade,TipoEndereco.COBRANCA, complemento);
}
public Long getId() {
return id;
}
public String getNome() {
return nome;
}
// public List<Conta> getConta() {
// return conta;
// }
public void setId(Long id) {
this.id = id;
}
public void setNome(String nome) {
this.nome = nome;
}
public void setEndereco(List<Endereco> endereco) {
this.endereco = endereco;
}
// public void setConta(List<Conta> conta) {
// this.conta = conta;
// }
public void setCpf(String cpf) {
this.cpf = cpf;
}
public List<Endereco> getEndereco() {
return endereco;
}
public String getCpf() {
return cpf;
}
}
| [
"[email protected]"
] | |
b2c30c89c8cb1a8e26d461c6df593133857509e1 | afdb70619280f7d6ab7b30eb144d0886e50c479c | /org/domterm/util/WTDebug.java | 46f2ea8d74998ff51868ba67cdf2a7b53c109bbc | [] | no_license | gvsurenderreddy/DomTerm | 7c990fdfff0c8f053fa90a20ba8de3390483a941 | a80f0a203c5c973ac108843c1ccfbc8c1e2e0bb1 | refs/heads/master | 2020-07-08T17:27:14.563295 | 2016-11-12T18:58:50 | 2016-11-12T18:58:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,366 | java | /*
* Copyright (c) 2011, 2014 Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*
* This file is available and licensed under the following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the distribution.
* - Neither the name of Oracle Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.domterm.util;
import java.io.*;
import org.w3c.dom.*;
/** Some debugging utilities. */
public class WTDebug {
static
PrintStream origErr;
public static void init() {
if (origErr == null)
origErr = System.err;
}
static {
init();
}
public static void print(Object obj) {
origErr.print(""+obj);
}
public static void println(Object obj) {
origErr.println(""+obj);
}
public static String pnode(org.w3c.dom.Node n) {
if (n == null) return "(null)";
if (n instanceof CharacterData)
return n.toString()+'\"'+toQuoted(((CharacterData)n).getData())+'\"'+"@"+Integer.toHexString(System.identityHashCode(n));
return n+"/"+n.getNodeName()+"@"+Integer.toHexString(System.identityHashCode(n));
}
public static String toQuoted(String str) {
int len = str.length();
StringBuilder buf = new StringBuilder();
for (int i = 0; i < len; i++) {
char ch = str.charAt(i);
if (ch == '\n')
buf.append("\\n");
else if (ch == '\r')
buf.append("\\r");
else if (ch == '\t')
buf.append("\\t");
else if (ch == '\033')
buf.append("\\E");
else if (ch < ' ' || ch >= 127)
buf.append("\\"+(char)(((ch>>6)&7)+'0')+(char)(((ch>>3)&7)+'0')+(char)((ch&7)+'0'));
else {
if (ch == '\"' || ch == '\'' || ch == '\\')
buf.append('\\');
buf.append(ch);
}
}
return buf.toString();
}
}
| [
"“[email protected]”"
] | |
3a0136c357a163a26e625b84f781abda047aa057 | eeb5728d25b92e6fe0453e1b2595a32bc973d1f7 | /untitled/src/com/prata/Source2.java | cc116ef4d59597a390476bd3a13311899524153e | [] | no_license | gkpratapsimha/Intellij-Projects | 89adcf27dfad3e975c6bcfef0921748f6e410e57 | 97505f0e133c4c8a3cdbf6b41cc9bb043c8ab8a5 | refs/heads/master | 2022-05-26T09:04:59.473117 | 2020-04-20T18:27:28 | 2020-04-20T18:27:28 | 257,372,054 | 0 | 0 | null | 2020-04-20T18:37:59 | 2020-04-20T18:37:59 | null | UTF-8 | Java | false | false | 653 | java | package com.prata;
import javax.swing.text.html.HTMLDocument;
import java.util.*;
class Source2 {
public static void main(String[] args) {
List<Integer> list = new LinkedList<>();
Scanner input = new Scanner(System.in);
int n = input.nextInt();
for(int i =0;i<n;i++){
list.add(input.nextInt());
}
reverse(list);
}
public static void reverse(List<Integer> numbers) {
//Complete the method declaration here
ListIterator<Integer> it = numbers.listIterator();
while(it.hasPrevious()){
System.out.print(it.previous() + " ");
}
}
}
| [
"[email protected]"
] | |
9ad2fcd940ac0dd0e44d14c6577c0f21972a281d | 4b184f60877e2f21746272547e63bdda60318fac | /src/main/java/gongzhonghao/spider.java | 7674e051bfb4bc1268dc4182eaa32104998d03ba | [] | no_license | sunhongyu1934/java_spider | 582313164063d50e4658c52f2b24731ee4527546 | a0e8a413c0694beb6ed8b2b9c78042ec2cd87d25 | refs/heads/master | 2022-09-25T01:23:35.468738 | 2019-10-16T03:55:54 | 2019-10-16T03:55:54 | 102,063,448 | 0 | 0 | null | 2022-09-01T22:35:18 | 2017-09-01T02:06:35 | Java | UTF-8 | Java | false | false | 19,583 | java | package gongzhonghao;
import Utils.Dup;
import Utils.JsoupUtils;
import Utils.Producer;
import Utils.RedisClu;
import org.dom4j.DocumentException;
import org.json.JSONArray;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class spider {
private static Connection conn;
private static RedisClu rd=new RedisClu();
private static Ca c=new Ca();
private static Uu u=new Uu();
private static int sa=0;
private static int sb=0;
static{
String driver1="com.mysql.jdbc.Driver";
String url1="jdbc:mysql://172.31.215.38:3306/spider?useUnicode=true&useCursorFetch=true&defaultFetchSize=100";
String username="spider";
String password="spider";
try {
Class.forName(driver1).newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
java.sql.Connection con=null;
try {
con = DriverManager.getConnection(url1, username, password);
}catch (Exception e){
while(true){
try {
con = DriverManager.getConnection(url1, username, password);
} catch (SQLException e1) {
e1.printStackTrace();
}
if(con!=null){
break;
}
}
}
conn=con;
try {
String sql = "select id,comp_full_name from innotree_data_financing.wecat_serach where mark_time='' or mark_time is null";
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs=ps.executeQuery();
Date date=new Date();
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
String time=simpleDateFormat.format(date);
String sql2="update innotree_data_financing.wecat_serach set mark_time='"+time+"' where id=?";
PreparedStatement ps2=conn.prepareStatement(sql2);
while (rs.next()){
String se=rs.getString(rs.findColumn("comp_full_name"));
String id=rs.getString(rs.findColumn("id"));
rd.set("wecat_zl",id+"###"+se);
ps2.setInt(1, Integer.parseInt(id));
ps2.executeUpdate();
}
}catch (Exception e){
}
}
public static void main(String args[]) throws IOException, InterruptedException {
Thread thread=new Thread(new Runnable() {
@Override
public void run() {
try {
getip();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
thread.start();
Thread thread1=new Thread(new Runnable() {
@Override
public void run() {
try {
conip();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
thread1.start();
ExecutorService pool= Executors.newCachedThreadPool();
for(int a=1;a<=10;a++){
pool.submit(new Runnable() {
@Override
public void run() {
try {
serach();
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
for(int b=1;b<=10;b++){
pool.submit(new Runnable() {
@Override
public void run() {
try {
detail();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
}
pool.shutdown();
while (true) {
if (pool.isTerminated()) {
System.out.println("结束了!");
System.exit(0);
}
Thread.sleep(2000);
}
}
public static void serach() throws IOException, DocumentException, InterruptedException {
Producer producer=new Producer(false);
while (true) {
try {
String key = rd.get("wecat_zl");
if (!Dup.nullor(key)) {
break;
}
for (int q = 1; q <= 10; q++) {
int pp=0;
try {
Document doc = serachGet(key.split("###")[1], String.valueOf(q));
Pattern pat = Pattern.compile("<script>var account_anti_url =.+?</script>");
Matcher mat = pat.matcher(doc.outerHtml());
String urlc = null;
while (mat.find()) {
urlc = mat.group().replace("<script>var account_anti_url = \"", "").replace("\";</script>", "");
}
String json = Dup.qujson(getShu(urlc));
//System.out.println(json);
JSONObject jsonObject1 =new JSONObject();
try {
JSONObject jsonObject = new JSONObject(json);
jsonObject1 = jsonObject.getJSONObject("msg");
}catch (Exception e){
}
Elements ele = JsoupUtils.getElements(doc, "div.news-box ul.news-list2 li");
for (Element e : ele) {
try {
String gname = JsoupUtils.getString(e, "div.gzh-box2 div.txt-box p", 0);
String url = JsoupUtils.getHref(e, "div.gzh-box2 div.txt-box p a", "href", 0);
String wei = JsoupUtils.getString(e, "div.gzh-box2 div.txt-box p label", 0);
String logo = JsoupUtils.getHref(e, "div.gzh-box2 div.img-box a img", "src", 0);
String pub_intro = JsoupUtils.getString(e, "dd", 0);
String comp = JsoupUtils.getString(e, "dd", 1);
String wenzhangshu=null; ;
try {
wenzhangshu = getValue(jsonObject1, logo.split("/")[6]) != null
? getValue(jsonObject1, logo.split("/")[6]).split(",")[0]
: null;
}catch (Exception ee1){
}
String zongwen = null;
try {
zongwen = getValue(jsonObject1, logo.split("/")[6]) != null
? getValue(jsonObject1, logo.split("/")[6]).split(",")[1]
: null;
}catch (Exception ee1){
}
u.fang(new String[]{url,wei});
JSONObject js = new JSONObject();
js.put("comp_full_name", comp);
js.put("comp_id", "createid=comp_full_name");
js.put("pub_name", gname);
js.put("pub_id", "createid=pub_name");
js.put("pub_intro", pub_intro);
js.put("pub_logo", logo);
js.put("detail_url", url);
js.put("wechart_num", wei);
js.put("title_num", wenzhangshu);
js.put("title_num_total", zongwen);
js.put("rowkey", "comp_full_name+comp_full_name###pub_name###familyname");
js.put("tablename", "public_account_info");
js.put("familyname", "sogou");
producer.send("ControlTotal", js.toString());
sa++;
System.out.println("serach "+sa+"******************************************************"+rd.getslength("wecat_zl"));
} catch (Exception e1) {
e1.printStackTrace();
}
pp++;
}
} catch (Exception e) {
e.printStackTrace();
}
if(pp<8){
break;
}
}
}catch (Exception e){
e.printStackTrace();
}
}
}
public static void detail() throws UnsupportedEncodingException, FileNotFoundException, DocumentException, InterruptedException {
Producer producer=new Producer(false);
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
while (true) {
try {
String key[] = u.qu();
if (key==null && !rd.getExists("wecat_zl")&&u.po.size()==0) {
break;
}
Document doc = detailGet(key[0]);
String gname = JsoupUtils.getString(doc, "div.profile_info strong.profile_nickname", 0);
String wei = key[1];
String jie = JsoupUtils.getString(doc, "ul.profile_desc li div.profile_desc_value", 0);
String logo = JsoupUtils.getHref(doc, "div.profile_info_group span.radius_avatar.profile_avatar img", "src", 0);
String zhuti = JsoupUtils.getString(doc, "ul.profile_desc div.profile_desc_value", 1);
Pattern pattern = Pattern.compile("var biz =.*?\".+?\"");
Matcher matcher = pattern.matcher(doc.outerHtml());
String biz = null;
while (matcher.find()) {
biz = matcher.group();
}
biz = biz.replace("var biz = \"", "").replace("\"", "");
Pattern pat = Pattern.compile("var msgList =.+?};");
Matcher mat = pat.matcher(doc.outerHtml());
String json = null;
while (mat.find()) {
json = mat.group();
}
json = json.replace("var msgList = ", "").replace(";", "");
JSONObject jsonObject = new JSONObject(json);
JSONArray jsonArray = jsonObject.getJSONArray("list");
for (int a = 0; a < jsonArray.length(); a++) {
try {
JSONObject jsonObject1 = jsonArray.getJSONObject(a).getJSONObject("app_msg_ext_info");
String title = getValue(jsonObject1, "title");
String titieurl = getValue(jsonObject1, "content_url");
String img = getValue(jsonObject1, "cover");
String jian = getValue(jsonObject1, "digest");
String shijian = jsonArray.getJSONObject(a).getJSONObject("comm_msg_info").get("datetime").toString();
shijian = simpleDateFormat.format(new Date(Long.parseLong(shijian) * 1000));
JSONObject js=new JSONObject();
js.put("rowkey", "wechart_num+wechart_num###title###familyname");
js.put("tablename", "public_title_info");
js.put("familyname", "sogou");
js.put("pub_name",gname);
js.put("pub_id","createid=pub_name");
js.put("title_id","createid=title");
js.put("title",title);
js.put("title_url",titieurl);
js.put("pub_logo",logo);
js.put("pub_intro",jie);
js.put("wechart_num",wei);
js.put("pub_develop",zhuti);
js.put("title_logo",img);
js.put("title_intro",jian);
js.put("publish_date",shijian);
js.put("b_id",biz);
producer.send("ControlTotal", js.toString());
sb++;
System.out.println("title "+sb+"****************************************************"+u.po.size());
} catch (Exception e) {
e.printStackTrace();
}
}
}catch (Exception e){
e.printStackTrace();
}
}
}
public static Document detailGet(String url){
Document doc= null;
while (true) {
try {
String ip=c.qu();
doc = Jsoup.connect(url)
.userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36")
.header("Host", "mp.weixin.qq.com")
.proxy(ip.split(":", 2)[0], Integer.parseInt(ip.split(":", 2)[1]))
.ignoreContentType(true)
.ignoreHttpErrors(true)
.timeout(3000)
.get();
if(doc!=null&&!doc.outerHtml().contains("too many request")&&doc.outerHtml().length()>46&&!doc.outerHtml().contains("请输入验证码")){
if (!c.po.contains(ip)) {
for (int x = 1; x <= 10; x++) {
c.fang(ip);
}
}
break;
}
}catch (Exception e){
}
}
return doc;
}
public static String getValue(JSONObject jsonObject,String key){
try{
return jsonObject.get(key).toString();
}catch (Exception e){
return null;
}
}
public static Document getShu(String str){
Document doc=null;
while (true) {
try {
String ip=c.qu();
doc = Jsoup.connect("http://weixin.sogou.com"+str)
.userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36")
.header("Accept", "application/json, text/javascript, */*; q=0.01")
.header("Accept-Encoding", "gzip, deflate")
.header("Accept-Language", "zh-CN,zh;q=0.9")
.header("Host", "weixin.sogou.com")
.proxy(ip.split(":", 2)[0], Integer.parseInt(ip.split(":", 2)[1]))
.ignoreContentType(true)
.ignoreHttpErrors(true)
.timeout(3000)
.get();
if(doc!=null&&!doc.outerHtml().contains("too many request")&&doc.outerHtml().length()>46){
if (!c.po.contains(ip)) {
for (int x = 1; x <= 10; x++) {
c.fang(ip);
}
}
break;
}
}catch (Exception e){
}
}
return doc;
}
public static Document serachGet(String key,String page) throws IOException {
Document doc= null;
while (true) {
try {
String ip=c.qu();
doc = Jsoup.connect("http://weixin.sogou.com/weixin?query="+URLEncoder.encode(key,"utf-8")+"&_sug_type_=&s_from=input&_sug_=y&type=1&page="+page+"&ie=utf8")
.userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36")
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
.header("Accept-Encoding", "gzip, deflate")
.header("Accept-Language", "zh-CN,zh;q=0.9")
.header("Host", "weixin.sogou.com")
.header("Referer", "http://weixin.sogou.com/")
.proxy(ip.split(":", 2)[0], Integer.parseInt(ip.split(":", 2)[1]))
.ignoreContentType(true)
.ignoreHttpErrors(true)
.timeout(3000)
.get();
if(doc!=null&&!doc.outerHtml().contains("too many request")&&doc.outerHtml().length()>9000){
if (!c.po.contains(ip)) {
for (int x = 1; x <= 10; x++) {
c.fang(ip);
}
}
break;
}
}catch (Exception e){
}
}
return doc;
}
public static void getip() throws IOException, InterruptedException {
RedisClu rd=new RedisClu();
while (true) {
try {
String ip=rd.get("ip");
c.fang(ip);
System.out.println(c.po.size()+" ip***********************************************");
Thread.sleep(4000);
}catch (Exception e){
Thread.sleep(1000);
System.out.println("ip wait");
}
}
}
public static void conip() throws InterruptedException {
while (true){
if(c.po.size()>=10) {
c.qu();
}
Thread.sleep(1000);
}
}
public static class Ca{
public BlockingQueue<String> po=new LinkedBlockingQueue<String>();
public void fang(String key) throws InterruptedException {
po.put(key);
}
public String qu() throws InterruptedException {
return po.take();
}
}
public static class Uu{
BlockingQueue<String[]> po=new LinkedBlockingQueue<>(100);
public void fang(String[] key) throws InterruptedException {
po.put(key);
}
public String[] qu() throws InterruptedException {
return po.poll(20, TimeUnit.SECONDS);
}
}
}
| [
"3961shy3961"
] | 3961shy3961 |
cd2d39cd32fd241470311e84bb5639ea8ddc224e | 7643052c3147467dc4dbada643c5efb51ed59513 | /WebGoat-Lessons/sql-injection/src/main/java/org/owasp/webgoat/plugin/sqlinjection/ListStaffSqlInjection.java | 124b61ed17b733fd6e23225958838150875ea3d9 | [
"MIT-0"
] | permissive | epakhomov/aws-modernization-with-contrastsecurity | 70c1e6160a558149957ee1932a93b8e8f7eb8dd1 | d5d9c8341cfb6084877c4a8606b99414fc0449f8 | refs/heads/master | 2022-06-21T21:00:43.028882 | 2019-09-10T22:18:36 | 2019-09-10T22:18:36 | 206,234,339 | 1 | 1 | NOASSERTION | 2019-09-05T22:00:11 | 2019-09-04T04:53:59 | Java | UTF-8 | Java | false | false | 6,342 | java |
package org.owasp.webgoat.plugin.sqlinjection;
import org.owasp.webgoat.plugin.GoatHillsFinancial.DefaultLessonAction;
import org.owasp.webgoat.plugin.GoatHillsFinancial.EmployeeStub;
import org.owasp.webgoat.plugin.GoatHillsFinancial.GoatHillsFinancial;
import org.owasp.webgoat.session.ParameterNotFoundException;
import org.owasp.webgoat.session.UnauthenticatedException;
import org.owasp.webgoat.session.UnauthorizedException;
import org.owasp.webgoat.session.WebSession;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Vector;
/***************************************************************************************************
*
*
* This file is part of WebGoat, an Open Web Application Security Project utility. For details,
* please see http://www.owasp.org/
*
* Copyright (c) 2002 - 20014 Bruce Mayhew
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Getting Source ==============
*
* Source for this application is maintained at https://github.com/WebGoat/WebGoat, a repository for free software
* projects.
*
* For details, please see http://webgoat.github.io
*/
public class ListStaffSqlInjection extends DefaultLessonAction
{
public ListStaffSqlInjection(GoatHillsFinancial lesson, String lessonName, String actionName)
{
super(lesson, lessonName, actionName);
}
public void handleRequest(WebSession s) throws ParameterNotFoundException, UnauthenticatedException,
UnauthorizedException
{
getLesson().setCurrentAction(s, getActionName());
if (isAuthenticated(s))
{
int userId = getIntSessionAttribute(s, getLessonName() + "." + SQLInjection.USER_ID);
List employees = getAllEmployees(s, userId);
setSessionAttribute(s, getLessonName() + "." + SQLInjection.STAFF_ATTRIBUTE_KEY, employees);
}
else
throw new UnauthenticatedException();
}
public String getNextPage(WebSession s)
{
return SQLInjection.LISTSTAFF_ACTION;
}
public List getAllEmployees(WebSession s, int userId) throws UnauthorizedException
{
// Query the database for all employees "owned" by the given employee
List<EmployeeStub> employees = new Vector<EmployeeStub>();
try
{
String query = "SELECT employee.userid,first_name,last_name,role FROM employee,roles WHERE employee.userid=roles.userid and employee.userid in "
+ "(SELECT employee_id FROM ownership WHERE employer_id = " + userId + ")";
try
{
Statement answer_statement = WebSession.getConnection(s)
.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet answer_results = answer_statement.executeQuery(query);
answer_results.beforeFirst();
while (answer_results.next())
{
int employeeId = answer_results.getInt("userid");
String firstName = answer_results.getString("first_name");
String lastName = answer_results.getString("last_name");
String role = answer_results.getString("role");
// System.out.println("Retrieving employee stub for role " + role);
EmployeeStub stub = new EmployeeStub(employeeId, firstName, lastName, role);
employees.add(stub);
}
} catch (SQLException sqle)
{
s.setMessage("Error getting employees");
sqle.printStackTrace();
}
} catch (Exception e)
{
s.setMessage("Error getting employees");
e.printStackTrace();
}
return employees;
}
public List getAllEmployees_BACKUP(WebSession s, int userId) throws UnauthorizedException
{
// Query the database for all employees "owned" by the given employee
List<EmployeeStub> employees = new Vector<EmployeeStub>();
try
{
String query = "SELECT employee.userid,first_name,last_name,role FROM employee,roles WHERE employee.userid=roles.userid and employee.userid in "
+ "(SELECT employee_id FROM ownership WHERE employer_id = " + userId + ")";
try
{
Statement answer_statement = WebSession.getConnection(s)
.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet answer_results = answer_statement.executeQuery(query);
answer_results.beforeFirst();
while (answer_results.next())
{
int employeeId = answer_results.getInt("userid");
String firstName = answer_results.getString("first_name");
String lastName = answer_results.getString("last_name");
String role = answer_results.getString("role");
// System.out.println("Retrieving employee stub for role " + role);
EmployeeStub stub = new EmployeeStub(employeeId, firstName, lastName, role);
employees.add(stub);
}
} catch (SQLException sqle)
{
s.setMessage("Error getting employees");
sqle.printStackTrace();
}
} catch (Exception e)
{
s.setMessage("Error getting employees");
e.printStackTrace();
}
return employees;
}
}
| [
"[email protected]"
] | |
1393ebd701cff0789a8a74b4bf3822a5b03b1439 | 1e745771758bef5b8de72ad01d0a2bfa3abb1ed4 | /han2/app/src/main/java/com/example/han2/RecWrite/RecUpdate.java | 956eadf6b27cdb36c627470d8cef7a42b2512ad3 | [] | no_license | im0523/Hanboltaegi-Android-Studio | 2253e5bef9dbfffe9acdc4b7cce897ba57d3e0c6 | 1be7ca3b82bb8d8188bd6f9d5ad874a63f390999 | refs/heads/master | 2020-12-09T03:10:19.212611 | 2020-01-11T04:09:09 | 2020-01-11T04:09:09 | 233,173,989 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 40,069 | java | package com.example.han2.RecWrite;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.han2.Atask.ListUpdate;
import com.example.han2.Dto.MyRecipeDTO;
import com.example.han2.Main.SubActivity;
import com.example.han2.R;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class RecUpdate extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
TextView rec_save;
EditText et_title, et_subtitle;
View rec_update_0,rec_update_1,rec_update_2,rec_update_3,rec_update_4,stuff_update_0,stuff_update_1,stuff_update_2,stuff_update_3,stuff_update_4;
View frame_0,frame_1,frame_2,frame_3,frame_4,frame_5,frame_6,frame_7,frame_8,frame_9;
EditText spic_et_name0,spic_et_name1,spic_et_name2,spic_et_name3,spic_et_name4;
EditText spic_et_unit0,spic_et_unit1,spic_et_unit2,spic_et_unit3,spic_et_unit4;
EditText stuff_et_name0,stuff_et_name1,stuff_et_name2,stuff_et_name3,stuff_et_name4;
EditText stuff_et_unit0,stuff_et_unit1,stuff_et_unit2,stuff_et_unit3,stuff_et_unit4;
TextView pro_tv0,pro_tv1,pro_tv2,pro_tv3,pro_tv4,pro_tv5,pro_tv6,pro_tv7,pro_tv8,pro_tv9;
EditText pro_et0,pro_et1,pro_et2,pro_et3,pro_et4,pro_et5,pro_et6,pro_et7,pro_et8,pro_et9;
ImageView pro_iv0,pro_iv1,pro_iv2,pro_iv3,pro_iv4,pro_iv5,pro_iv6,pro_iv7,pro_iv8,pro_iv9;
Bitmap bitmap1,bitmap2,bitmap3,bitmap4,bitmap5,bitmap6,bitmap7,bitmap8,bitmap9,bitmap10;
String rec_title_up, rec_subtitle_up ,rec_id,cat1_c,cat2_c,cat3_c,cat4_c;
String material_name0, material_name1, material_name2, material_name3, material_name4, material_name5, material_name6, material_name7, material_name8, material_name9;
String material_unit0, material_unit1, material_unit2, material_unit3, material_unit4, material_unit5, material_unit6, material_unit7, material_unit8, material_unit9;
String text1, text2, text3 ,text4 ,text5,text6,text7,text8,text9,text10;
//대표이미지
Bitmap bitmap0;
ImageView rec_image;
TextView stuff_tv_name0,material_tv_name0;
//요리정보
TextView cok_portion_tv_up, cok_time_tv_up, cok_degree_tv_up;
String portion,time,degree;
TextView rec_update;
private ProgressDialog progressDialog;
//이미지 실제주소 가져오기
public static String image0,image1,image2,image3,image4,image5,image6,image7,image8,image9,image10;
//완성사진
public static String imagepath1,imagepath2,imagepath3,imagepath4;
Bitmap bitpath1,bitpath2,bitpath3,bitpath4;
ImageView pathimage1,pathimage2,pathimage3,pathimage4;
String id;
//카테고리
EditText cat1_up,cat2_up,cat3_up,cat4_up;
ArrayAdapter<CharSequence> adapter_cat1, adapter_cat2, adapter_cat3, adapter_cat4;
Spinner cat1,cat2,cat3,cat4;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update);
//레시피 수정
et_title = findViewById(R.id.rec_title_up);
et_subtitle = findViewById(R.id.rec_subtitle_up);
/*
cat1_up = findViewById(R.id.cat1_up);
cat2_up = findViewById(R.id.cat2_up);
cat3_up = findViewById(R.id.cat3_up);
cat4_up = findViewById(R.id.cat4_up);
*/
//재료
spic_et_name0 = findViewById(R.id.spic_et_name0);
spic_et_name1 = findViewById(R.id.spic_et_name1);
spic_et_name2 = findViewById(R.id.spic_et_name2);
spic_et_name3 = findViewById(R.id.spic_et_name3);
spic_et_name4 = findViewById(R.id.spic_et_name4);
spic_et_unit0 = findViewById(R.id.spic_et_unit0);
spic_et_unit1 = findViewById(R.id.spic_et_unit1);
spic_et_unit2 = findViewById(R.id.spic_et_unit2);
spic_et_unit3 = findViewById(R.id.spic_et_unit3);
spic_et_unit4 = findViewById(R.id.spic_et_unit4);
//양념
stuff_et_name0 = findViewById(R.id.stuff_et_name0);
stuff_et_name1 = findViewById(R.id.stuff_et_name1);
stuff_et_name2 = findViewById(R.id.stuff_et_name2);
stuff_et_name3 = findViewById(R.id.stuff_et_name3);
stuff_et_name4 = findViewById(R.id.stuff_et_name4);
stuff_et_unit0 = findViewById(R.id.stuff_et_unit0);
stuff_et_unit1 = findViewById(R.id.stuff_et_unit1);
stuff_et_unit2 = findViewById(R.id.stuff_et_unit2);
stuff_et_unit3 = findViewById(R.id.stuff_et_unit3);
stuff_et_unit4 = findViewById(R.id.stuff_et_unit4);
//요리소개
pro_et0 = findViewById(R.id.pro_et0);
pro_et1 = findViewById(R.id.pro_et1);
pro_et2 = findViewById(R.id.pro_et2);
pro_et3 = findViewById(R.id.pro_et3);
pro_et4 = findViewById(R.id.pro_et4);
pro_et5 = findViewById(R.id.pro_et5);
pro_et6 = findViewById(R.id.pro_et6);
pro_et7 = findViewById(R.id.pro_et7);
pro_et8 = findViewById(R.id.pro_et8);
pro_et9 = findViewById(R.id.pro_et9);
pro_tv0 = findViewById(R.id.pro_tv0);
pro_tv1 = findViewById(R.id.pro_tv1);
pro_tv2 = findViewById(R.id.pro_tv2);
pro_tv3 = findViewById(R.id.pro_tv3);
pro_tv4 = findViewById(R.id.pro_tv4);
pro_tv5 = findViewById(R.id.pro_tv5);
pro_tv6 = findViewById(R.id.pro_tv6);
pro_tv7 = findViewById(R.id.pro_tv7);
pro_tv8 = findViewById(R.id.pro_tv8);
pro_tv9 = findViewById(R.id.pro_tv9);
pro_iv0 = findViewById(R.id.pro_iv0);
pro_iv1 = findViewById(R.id.pro_iv1);
pro_iv2 = findViewById(R.id.pro_iv2);
pro_iv3 = findViewById(R.id.pro_iv3);
pro_iv4 = findViewById(R.id.pro_iv4);
pro_iv5 = findViewById(R.id.pro_iv5);
pro_iv6 = findViewById(R.id.pro_iv6);
pro_iv7 = findViewById(R.id.pro_iv7);
pro_iv8 = findViewById(R.id.pro_iv8);
pro_iv9 = findViewById(R.id.pro_iv9);
//레이아웃
frame_0 = findViewById(R.id.frame_0);
frame_1 = findViewById(R.id.frame_1);
frame_2 = findViewById(R.id.frame_2);
frame_3 = findViewById(R.id.frame_3);
frame_4 = findViewById(R.id.frame_4);
frame_5 = findViewById(R.id.frame_5);
frame_6 = findViewById(R.id.frame_6);
frame_7 = findViewById(R.id.frame_7);
frame_8 = findViewById(R.id.frame_8);
frame_9 = findViewById(R.id.frame_9);
rec_update_0 = findViewById(R.id.rec_update_0);
rec_update_1 = findViewById(R.id.rec_update_1);
rec_update_2 = findViewById(R.id.rec_update_2);
rec_update_3 = findViewById(R.id.rec_update_3);
rec_update_4 = findViewById(R.id.rec_update_4);
stuff_update_0 = findViewById(R.id.stuff_update_0);
stuff_update_1 = findViewById(R.id.stuff_update_1);
stuff_update_2 = findViewById(R.id.stuff_update_2);
stuff_update_3 = findViewById(R.id.stuff_update_3);
stuff_update_4 = findViewById(R.id.stuff_update_4);
//요리정보
cok_portion_tv_up = findViewById(R.id.cok_portion_tv_up);
cok_time_tv_up = findViewById(R.id.cok_time_tv_up);
cok_degree_tv_up = findViewById(R.id.cok_degree_tv_up);
// 보내온 값 파싱
Intent intent = getIntent();
//final RecipeDTO selItem = (RecipeDTO) intent.getSerializableExtra("selItem");
final MyRecipeDTO selItem = (MyRecipeDTO) intent.getSerializableExtra("selItem");
rec_title_up = selItem.getTitle();
rec_subtitle_up = selItem.getSubtitle();
rec_id = selItem.getRecipe_id();
cat1_c = selItem.getCat1();
cat2_c = selItem.getCat2();
cat3_c = selItem.getCat3();
cat4_c = selItem.getCat4();
portion = selItem.getPortion();
time = selItem.getTime();
degree = selItem.getDegree();
material_name0 = selItem.getMaterial_name0();
material_name1 = selItem.getMaterial_name1();
material_name2 = selItem.getMaterial_name2();
material_name3 = selItem.getMaterial_name3();
material_name4 = selItem.getMaterial_name4();
material_name5 = selItem.getMaterial_name5();
material_name6 = selItem.getMaterial_name6();
material_name7 = selItem.getMaterial_name7();
material_name8 = selItem.getMaterial_name8();
material_name9 = selItem.getMaterial_name9();
material_unit0 = selItem.getMaterial_unit0();
material_unit1 = selItem.getMaterial_unit1();
material_unit2 = selItem.getMaterial_unit2();
material_unit3 = selItem.getMaterial_unit3();
material_unit4 = selItem.getMaterial_unit4();
material_unit5 = selItem.getMaterial_unit5();
material_unit6 = selItem.getMaterial_unit6();
material_unit7 = selItem.getMaterial_unit7();
material_unit8 = selItem.getMaterial_unit8();
material_unit9 = selItem.getMaterial_unit9();
text1 = selItem.getText1();
text2 = selItem.getText2();
text3 = selItem.getText3();
text4 = selItem.getText4();
text5 = selItem.getText5();
text6 = selItem.getText6();
text7 = selItem.getText7();
text8 = selItem.getText8();
text9 = selItem.getText9();
text10 = selItem.getText10();
/*
rec_id = intent.getStringExtra("id");
rec_title = intent.getStringExtra("title");
rec_subtitle = intent.getStringExtra("subtitle");
*/
// 가져온 값 써 넣기
et_title.setText(rec_title_up);
et_subtitle.setText(rec_subtitle_up);
cok_portion_tv_up.setText(portion);
cok_time_tv_up.setText(time);
cok_degree_tv_up.setText(degree);
if( material_unit0.equals("") ) stuff_update_0.setVisibility(View.GONE);
if( material_unit1.equals("") ) stuff_update_1.setVisibility(View.GONE);
if( material_unit2.equals("") ) stuff_update_2.setVisibility(View.GONE);
if( material_unit3.equals("") ) stuff_update_3.setVisibility(View.GONE);
if( material_unit4.equals("") ) stuff_update_4.setVisibility(View.GONE);
if( material_unit5.equals("") ) rec_update_0.setVisibility(View.GONE);
if( material_unit6.equals("") ) rec_update_1.setVisibility(View.GONE);
if( material_unit7.equals("") ) rec_update_2.setVisibility(View.GONE);
if( material_unit8.equals("") ) rec_update_3.setVisibility(View.GONE);
if( material_unit9.equals("") ) rec_update_4.setVisibility(View.GONE);
if ( text1.equals("") || pro_iv0.equals("") ) frame_0.setVisibility(View.GONE);
if ( text2.equals("") || pro_iv1.equals("") ) frame_1.setVisibility(View.GONE);
if ( text3.equals("") || pro_iv2.equals("") ) frame_2.setVisibility(View.GONE);
if ( text4.equals("")|| pro_iv3.equals("") ) frame_3.setVisibility(View.GONE);
if ( text5.equals("") || pro_iv4.equals("") ) frame_4.setVisibility(View.GONE);
if ( text6.equals("") || pro_iv5.equals("") ) frame_5.setVisibility(View.GONE);
if ( text7.equals("") || pro_iv6.equals("") ) frame_6.setVisibility(View.GONE);
if ( text8.equals("") || pro_iv7.equals("") ) frame_7.setVisibility(View.GONE);
if ( text9.equals("") || pro_iv8.equals("") ) frame_8.setVisibility(View.GONE);
if ( !text10.equals("") || pro_iv9.equals("") ) frame_9.setVisibility(View.GONE);
stuff_tv_name0 = findViewById(R.id.stuff_tv_name0);
material_tv_name0 = findViewById(R.id.material_tv_name0);
if( material_name5.equals("") && material_name6.equals("") && material_name7.equals("") && material_name8.equals("") && material_name9.equals("") )
stuff_tv_name0.setVisibility(View.GONE);
if (material_name0.equals("") && material_name1.equals("") )
material_tv_name0.setVisibility(View.GONE);
/*
cat1_up.setText(cat1_c);
cat2_up.setText(cat2_c);
cat3_up.setText(cat3_c);
cat4_up.setText(cat4_c);
*/
//카테고리
cat1 = findViewById(R.id.cat1);
adapter_cat1 = ArrayAdapter.createFromResource(this, R.array.cat1, android.R.layout.simple_spinner_item);
adapter_cat1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cat1.setAdapter(adapter_cat1);
cat1.setOnItemSelectedListener(this);
cat2 = findViewById(R.id.cat2);
adapter_cat2 = ArrayAdapter.createFromResource(this, R.array.cat2, android.R.layout.simple_spinner_item);
adapter_cat2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cat2.setAdapter(adapter_cat2);
cat2.setOnItemSelectedListener(this);
cat3 = findViewById(R.id.cat3);
adapter_cat3 = ArrayAdapter.createFromResource(this, R.array.cat3, android.R.layout.simple_spinner_item);
adapter_cat3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cat3.setAdapter(adapter_cat3);
cat3.setOnItemSelectedListener(this);
cat4 = findViewById(R.id.cat4);
adapter_cat4 = ArrayAdapter.createFromResource(this, R.array.cat4, android.R.layout.simple_spinner_item);
adapter_cat4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cat4.setAdapter(adapter_cat4);
cat4.setOnItemSelectedListener(this);
spic_et_name0.setText(material_name0);
spic_et_unit0.setText(material_unit0);
spic_et_name1.setText(material_name1);
spic_et_unit1.setText(material_unit1);
spic_et_name2.setText(material_name2);
spic_et_unit2.setText(material_unit2);
spic_et_name3.setText(material_name3);
spic_et_unit3.setText(material_unit3);
spic_et_name4.setText(material_name4);
spic_et_unit4.setText(material_unit4);
//양념
stuff_et_name0.setText(material_name5);
stuff_et_unit0.setText(material_unit5);
stuff_et_name1.setText(material_name6);
stuff_et_unit1.setText(material_unit6);
stuff_et_name2.setText(material_name7);
stuff_et_unit2.setText(material_unit7);
stuff_et_name3.setText(material_name8);
stuff_et_unit3.setText(material_unit8);
stuff_et_name4.setText(material_name9);
stuff_et_unit4.setText(material_unit9);
//요리소개
pro_et0.setText(text1);
pro_et1.setText(text2);
pro_et2.setText(text3);
pro_et3.setText(text4);
pro_et4.setText(text5);
pro_et5.setText(text6);
pro_et6.setText(text7);
pro_et7.setText(text8);
pro_et8.setText(text9);
pro_et9.setText(text10);
pro_tv0.setText("1");
pro_tv1.setText("2");
pro_tv2.setText("3");
pro_tv3.setText("4");
pro_tv4.setText("5");
pro_tv5.setText("6");
pro_tv6.setText("7");
pro_tv7.setText("8");
pro_tv8.setText("9");
pro_tv9.setText("10");
//요리ㅅ사진 가지고오는곳
getimge();
rec_update = findViewById(R.id.rec_update);
rec_update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//데이터 다시 쓰는곳
rec_title_up = et_title.getText().toString();
rec_subtitle_up = et_subtitle.getText().toString();
/*
cat1_c = cat1_up.getText().toString();
cat2_c = cat2_up.getText().toString();
cat3_c = cat3_up.getText().toString();
cat4_c = cat4_up.getText().toString();
*/
portion = cok_portion_tv_up.getText().toString();
time = cok_time_tv_up.getText().toString();
degree = cok_degree_tv_up.getText().toString();
material_name0 = spic_et_name0.getText().toString();
material_name1 = spic_et_name1.getText().toString();
material_name2 = spic_et_name2.getText().toString();
material_name3 = spic_et_name3.getText().toString();
material_name4 = spic_et_name4.getText().toString();
material_name5 = stuff_et_name0.getText().toString();
material_name6 = stuff_et_name1.getText().toString();
material_name7 = stuff_et_name2.getText().toString();
material_name8 = stuff_et_name3.getText().toString();
material_name9 = stuff_et_name4.getText().toString();
material_unit0 = spic_et_unit0.getText().toString();
material_unit1 = spic_et_unit1.getText().toString();
material_unit2 = spic_et_unit2.getText().toString();
material_unit3 = spic_et_unit3.getText().toString();
material_unit4 = spic_et_unit4.getText().toString();
material_unit5 = stuff_et_unit0.getText().toString();
material_unit6 = stuff_et_unit1.getText().toString();
material_unit7 = stuff_et_unit2.getText().toString();
material_unit8 = stuff_et_unit3.getText().toString();
material_unit9 = stuff_et_unit4.getText().toString();
text1 = pro_et0.getText().toString();
text2 = pro_et1.getText().toString();
text3 = pro_et2.getText().toString();
text4 = pro_et3.getText().toString();
text5 = pro_et4.getText().toString();
text6 = pro_et5.getText().toString();
text7 = pro_et6.getText().toString();
text8 = pro_et7.getText().toString();
text9 = pro_et8.getText().toString();
text10 = pro_et9.getText().toString();
imagepath1 = selItem.getImagepath1();
imagepath2 = selItem.getImagepath2();
imagepath3 = selItem.getImagepath3();
imagepath4 = selItem.getImagepath4();
image0 = selItem.getImagepath();
image1 = selItem.getImage1();
image2 = selItem.getImage2();
image3 = selItem.getImage3();
image4 = selItem.getImage4();
image5 = selItem.getImage5();
image6 = selItem.getImage6();
image7 = selItem.getImage7();
image8 = selItem.getImage8();
image9 = selItem.getImage9();
image10 = selItem.getImage10();
ListUpdate listUpdate = new ListUpdate(rec_id,rec_title_up, rec_subtitle_up,
cat1_c,cat2_c,cat3_c,cat4_c,
portion,time,degree,
material_name0, material_name1, material_name2,
material_name3, material_name4, material_name5,
material_name6, material_name7, material_name8,
material_name9,material_unit0, material_unit1,
material_unit2, material_unit3, material_unit4,
material_unit5, material_unit6, material_unit7,
material_unit8, material_unit9,
text1, text2, text3 ,text4 ,text5,text6,text7,text8,text9,text10,
imagepath1,imagepath2,imagepath3,imagepath4,
image0,image1,image2,image3,image4,image5,image6,image7,image8,image9,image10);
Log.d("itemselected", "onClick: "+ cat1_c + ", " + cat2_c + ", " + cat3_c + ", " + cat4_c);
listUpdate.execute();
Toast.makeText(getApplicationContext(), "수정성공", Toast.LENGTH_LONG).show();
Log.d("수정했니2", rec_id);
Intent showIntent = new Intent(getApplicationContext(), SubActivity.class);
showIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | // 이 엑티비티 플래그를 사용하여 엑티비티를 호출하게 되면 새로운 태스크를 생성하여 그 태스크안에 엑티비티를 추가하게 됩니다. 단, 기존에 존재하는 태스크들중에 생성하려는 엑티비티와 동일한 affinity(관계, 유사)를 가지고 있는 태스크가 있다면 그곳으로 새 엑티비티가 들어가게됩니다.
Intent.FLAG_ACTIVITY_SINGLE_TOP | // 엑티비티를 호출할 경우 호출된 엑티비티가 현재 태스크의 최상단에 존재하고 있었다면 새로운 인스턴스를 생성하지 않습니다. 예를 들어 ABC가 엑티비티 스택에 존재하는 상태에서 C를 호출하였다면 여전히 ABC가 존재하게 됩니다.
Intent.FLAG_ACTIVITY_CLEAR_TOP); // 만약에 엑티비티스택에 호출하려는 엑티비티의 인스턴스가 이미 존재하고 있을 경우에 새로운 인스턴스를 생성하는 것 대신에 존재하고 있는 엑티비티를 포그라운드로 가져옵니다. 그리고 엑티비티스택의 최상단 엑티비티부터 포그라운드로 가져올 엑티비티까지의 모든 엑티비티를 삭제합니다.
startActivity(showIntent);
finish();
}
});
}
private void getimge(){
Intent intent = getIntent();
//RecipeDTO selItem = (RecipeDTO) intent.getSerializableExtra("selItem");
MyRecipeDTO selItem = (MyRecipeDTO) intent.getSerializableExtra("selItem");
//요리소개 사진넣는곳
rec_image = findViewById(R.id.rec_ImageView_up);
pro_iv0 = findViewById(R.id.pro_iv0);
pro_iv1 = findViewById(R.id.pro_iv1);
pro_iv2 = findViewById(R.id.pro_iv2);
pro_iv3 = findViewById(R.id.pro_iv3);
pro_iv4 = findViewById(R.id.pro_iv4);
pro_iv5 = findViewById(R.id.pro_iv5);
pro_iv6 = findViewById(R.id.pro_iv6);
pro_iv7 = findViewById(R.id.pro_iv7);
pro_iv8 = findViewById(R.id.pro_iv8);
pro_iv9 = findViewById(R.id.pro_iv9);
pathimage1 = findViewById(R.id.image1);
pathimage2 = findViewById(R.id.image2);
pathimage3 = findViewById(R.id.image3);
pathimage4 = findViewById(R.id.image4);
image0 = selItem.getImagepath();
image1 = selItem.getImage1();
image2 = selItem.getImage2();
image3 = selItem.getImage3();
image4 = selItem.getImage4();
image5 = selItem.getImage5();
image6 = selItem.getImage6();
image7 = selItem.getImage7();
image8 = selItem.getImage8();
image9 = selItem.getImage9();
image10 = selItem.getImage10();
imagepath1 =selItem.getImagepath1();
imagepath2 = selItem.getImagepath2();
imagepath3 = selItem.getImagepath3();
imagepath4 = selItem.getImagepath4();
Log.d("imagepathupdate", "getimge: " + image0 + image1);
Thread mThread0 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image0); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap0 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread0.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread0.join();
rec_image.setImageBitmap(bitmap0);
} catch (InterruptedException e) {
}
Thread mThread1 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image1); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap1 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread1.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread1.join();
pro_iv0.setImageBitmap(bitmap1);
} catch (InterruptedException e) {
}
Thread mThread2 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image2); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap2 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread2.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread2.join();
pro_iv1.setImageBitmap(bitmap2);
} catch (InterruptedException e) {
}
Thread mThread3 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image3); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap3 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread3.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread3.join();
pro_iv2.setImageBitmap(bitmap3);
} catch (InterruptedException e) {
}
Thread mThread10 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image10); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap10 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread10.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread10.join();
pro_iv9.setImageBitmap(bitmap10);
} catch (InterruptedException e) {
}
Thread mThread4 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image4); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap4 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread4.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread4.join();
pro_iv3.setImageBitmap(bitmap4);
} catch (InterruptedException e) {
}
Thread mThread5 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image5); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap5 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread5.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread5.join();
pro_iv4.setImageBitmap(bitmap5);
} catch (InterruptedException e) {
}
Thread mThread6 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image6); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap6 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread6.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread6.join();
pro_iv5.setImageBitmap(bitmap6);
} catch (InterruptedException e) {
}
Thread mThread7 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image7); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap7 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread7.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread7.join();
pro_iv6.setImageBitmap(bitmap7);
} catch (InterruptedException e) {
}
Thread mThread8 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image8); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap8 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread8.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread8.join();
pro_iv7.setImageBitmap(bitmap8);
} catch (InterruptedException e) {
}
Thread mThread9 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(image9); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap9 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
mThread9.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
mThread9.join();
pro_iv8.setImageBitmap(bitmap9);
} catch (InterruptedException e) {
}
//완성사진
Thread cookThread1 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(imagepath1); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitpath1 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
Log.d("imagepathupdate", "getimge: " + imagepath1);
cookThread1.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
cookThread1.join();
pathimage1.setImageBitmap(bitpath1);
} catch (InterruptedException e) {
}
Thread cookThread2 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(imagepath2); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitpath2 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
cookThread2.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
cookThread2.join();
pathimage2.setImageBitmap(bitpath2);
} catch (InterruptedException e) {
}
Thread cookThread3 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(imagepath3); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitpath3 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
cookThread3.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
cookThread3.join();
pathimage3.setImageBitmap(bitpath3);
} catch (InterruptedException e) {
}
Thread cookThread4 = new Thread() {
@Override
public void run() {
try {
URL url = new URL(imagepath4); // URL 주소를 이용해서 URL 객체 생성
// 아래 코드는 웹에서 이미지를 가져온 뒤
// 이미지 뷰에 지정할 Bitmap을 생성하는 과정
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitpath4 = BitmapFactory.decodeStream(is);
} catch(Exception e) {
}
}
};
cookThread4.start(); // 웹에서 이미지를 가져오는 작업 스레드 실행.
try {
cookThread4.join();
pathimage4.setImageBitmap(bitpath4);
} catch (InterruptedException e) {
}
}
//카테고리 선택 됐을 경우 Toast
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
switch (adapterView.getId()) {
case R.id.cat1:
if (adapterView.getSelectedItemPosition() > 0) {
/*cat1_c = String.valueOf(adapterView.getSelectedItemPosition());*/
cat1_c = adapterView.getItemAtPosition(position).toString();
Log.d("itemselect", "onItemSelected: " + cat1_c);
}
break;
case R.id.cat2:
if (adapterView.getSelectedItemPosition() > 0) {
/*cat2_c = String.valueOf(adapterView.getSelectedItemPosition());*/
cat2_c = adapterView.getItemAtPosition(position).toString();
Log.d("itemselect", "onItemSelected: " + cat2_c);
}
break;
case R.id.cat3:
if (adapterView.getSelectedItemPosition() > 0) {
/*cat3_c = String.valueOf(adapterView.getSelectedItemPosition());*/
cat3_c = adapterView.getItemAtPosition(position).toString();
Log.d("itemselect", "onItemSelected: " + cat3_c);
}
break;
case R.id.cat4:
if (adapterView.getSelectedItemPosition() > 0) {
/*cat4_c = String.valueOf(adapterView.getSelectedItemPosition());*/
cat4_c = adapterView.getItemAtPosition(position).toString();
Log.d("itemselect", "onItemSelected: " + cat4_c);
}
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
} | [
"[email protected]"
] | |
7ae73fb520f8db17118d421276bab0ed1cdc3a7e | 73b7f4f8e28d9af364e27b3c26c8c6fd42c1c4fd | /exercicios/src/oo/composicao/Item.java | 97219bfd3172c02bae1af8191695ea634cba40cf | [] | no_license | MarcalFilosofo/ExerciciosJava | 28167bc9be0e93ea290ae2a910940b18cda5e075 | a5b859f105f13891bdc4bc6d702fc4c8f46b5dfc | refs/heads/main | 2023-06-22T14:17:47.691795 | 2021-07-21T20:01:43 | 2021-07-21T20:01:43 | 370,516,624 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 239 | java | package oo.composicao;
public class Item {
String nome;
int quantidade;
double preco;
Compra compra;
Item (String nome, int quantidade, double preco){
this.nome = nome;
this.quantidade = quantidade;
this.preco = preco;
}
}
| [
"[email protected]"
] | |
a56901d7c8de4c6f0713823629fe6dcaa39a8204 | 0b0dc352693521d844292a0a5eef097b89837b36 | /src/io/github/rytb2009/homework/ListNode.java | eb936bd6454c89725f1bd9d345f0101ca8c0a44b | [] | no_license | rytb2009/CIS7124X | 22ef610a97915467678897235c09d67b32c10ea4 | 3605359756f267f6d51bb48aaa573e8b385e3456 | refs/heads/master | 2020-12-26T09:38:21.680513 | 2020-05-01T16:00:38 | 2020-05-01T16:00:38 | 237,468,617 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,891 | java | package io.github.rytb2009.homework;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ListNode<T> {
T data;
ListNode<T> next;
public ListNode(T data) {
this.data = data;
next = null;
}
public ListNode(T data, ListNode<T> next) {
this.data = data;
this.next = next;
}
public boolean isSortedAscending() {
if (!(data instanceof Comparable)) {
return false;
}
Comparable preData = null;
ListNode<T> cur = this;
while (cur != null) {
Comparable curData = (Comparable) cur.data;
if (preData != null && preData.compareTo(curData) >= 1) {
return false;
}
preData = curData;
cur = cur.next;
}
return true;
}
public <S extends Comparable> ListNode<S> merge(ListNode<S> ln) {
if (!(data instanceof Comparable)) {
throw new RuntimeException("Node must be Comparable");
}
ListNode<S> c = (ListNode<S>) this;
return sortedMerge(c, ln);
}
private static <S extends Comparable> ListNode<S> sortedMerge(ListNode<S> a, ListNode<S> b) {
if (b == null) {
return a;
}
if (a == null) {
return b;
}
ListNode<S> result = null;
if (a.data.compareTo(b.data) <= 0) {
result = new ListNode<>(a.data, sortedMerge(a.next, b));
} else {
result = new ListNode<>(b.data, sortedMerge(a, b.next));
}
return result;
}
public boolean hasCycle() {
Set<ListNode<T>> set = new HashSet<>();
ListNode<T> cur = this;
while (cur != null) {
if (set.contains(cur)) {
return true;
}
set.add(cur);
cur = cur.next;
}
return false;
}
// Could use Mark and Sweep method adding additional information during traversal
public void removeDuplicate() {
Set<T> set = new HashSet<>();
ListNode<T> pre = null;
ListNode<T> cur = this;
while (cur != null) {
if (set.contains(cur.data)) {
pre.next = cur.next;
} else {
set.add(cur.data);
pre = cur;
}
cur = cur.next;
}
}
public boolean isPalindromic() {
List<T> valueList = new ArrayList<>();
ListNode<T> cur = this;
while (cur != null) {
valueList.add(cur.data);
cur = cur.next;
}
int size = valueList.size();
for (int i = 0; i < size / 2; i++) {
if (!valueList.get(i).equals(valueList.get(size - i - 1))) {
return false;
}
}
return true;
}
}
| [
"[email protected]"
] | |
1f54f22eff9c6b700df59152f39f8bfa5049d2b1 | 7a316de9bc7c86a67bdab1bb924dad917efe34e8 | /Core/src/main/java/org/sece/core/common/repo/DAO.java | e31ae288440fe52a1e2876d064fe61a3a0cf4892 | [
"Apache-2.0"
] | permissive | mirzahmad/sece | 5afac2dc3c2c59450ffcdb0543d322871290ca06 | 9bb3507e82dbbaa1a4ec9e1fb5833c98631b8c4c | refs/heads/master | 2021-01-10T06:46:25.780946 | 2016-01-20T23:14:38 | 2016-01-20T23:14:38 | 48,963,591 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 795 | java | package org.sece.core.common.repo;
import org.sece.core.common.model.jpa.AbstractEntity;
import javax.persistence.Query;
import java.io.Serializable;
import java.util.List;
/**
* TODO
* We should add generic methods for CriteriaQuery and TypedQuery
* Created by mirza on 1/14/16.
*/
public interface DAO<T extends AbstractEntity, PK extends Serializable> {
T create(T t);
T find(Class type, PK id);
T update(T t);
void delete(Class type, PK id);
List<T> findWithNamedQuery(String queryName, JPAQueryBuilder jpaQueryBuilder);
List<T> findByQuery(String jpaQuery, JPAQueryBuilder jpaQueryBuilder);
int execute(String jpaQuery, JPAQueryBuilder jpaQueryBuilder);
abstract class JPAQueryBuilder {
public abstract void build(Query query);
}
} | [
"[email protected]"
] | |
6ad73cb440bd02ceb722a106dce83d163317cb44 | 5b54763218df9058679f7249ff734cdb2b4521be | /org.nightlabs.vestigo.childvm.webapp/src/main/java/org/nightlabs/vestigo/childvm/webapp/persistenceengine/jdo/Transaction.java | 9a5ba155a4fc4dbad78b8395b3ad5a71f0e3b72b | [] | no_license | vestigo/vestigo | 6a8ee1329166e2d834040052460fb25811d73ee4 | fd1a4f26ec5c54db29f3c6a2eaec42236da946ab | refs/heads/master | 2021-01-18T13:41:54.891634 | 2013-12-19T04:01:18 | 2013-12-19T04:01:18 | 29,386,880 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,325 | java | /*
* Vestigo - The JDO/JPA Query Tool And Browser - http://vestigo.nightlabs.com
* Copyright © 2011-2012 NightLabs Consulting GmbH. All rights reserved.
*
* This program and all its libraries in the namespace "*.nightlabs.vestigo.*"
* are proprietary software. Their source codes are trade secrets and therefore
* must be kept confidential.
*
* The use of this software is subject to licence terms.
*
* Please see LICENCE.txt or
* http://vestigo.nightlabs.com/latest-stable/about/licence.html for
* more details.
*
* For further information, please contact NightLabs Consulting GmbH:
* http://nightlabs.com
*/
package org.nightlabs.vestigo.childvm.webapp.persistenceengine.jdo;
import org.nightlabs.vestigo.childvm.webapp.persistenceengine.PersistenceEngineWrapper;
public class Transaction extends PersistenceEngineWrapper
{
// private PersistenceManager persistenceManager;
public Transaction(PersistenceManager persistenceManager, Object wrappedObject) {
super(persistenceManager, wrappedObject);
// this.persistenceManager = persistenceManager;
}
// public PersistenceManager getPersistenceManager() {
// return persistenceManager;
// }
public void begin() {
invoke(1, "begin");
}
public void commit() {
invoke(2, "commit");
}
public void rollback() {
invoke(3, "rollback");
}
}
| [
"[email protected]"
] | |
e157686fd32b1cd63aa96bfbecf9f86a02775dad | 7808f87a08347d3d9b41f87f9449f79cf2908d69 | /WEB-INF/classes/nms/monitoring/vo/DataReceviedTableDataVO.java | 6b5ed528614028f231c1af953fb387a83a928e54 | [] | no_license | Yongminlee2/NMS | beb4c584d32b44b7512e4d2122f08698ee32e261 | ca1ac2e9ba7f9f091495939e22dec50d1a818036 | refs/heads/master | 2020-07-01T10:25:38.563327 | 2019-08-29T00:46:25 | 2019-08-29T00:46:25 | 201,145,107 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 666 | java | package nms.monitoring.vo;
public class DataReceviedTableDataVO {
private String tablename;
private int epochtime;
private String color;
private String maptype;
public String getTablename() {
return tablename;
}
public void setTablename(String tablename) {
this.tablename = tablename;
}
public int getEpochtime() {
return epochtime;
}
public void setEpochtime(int epochtime) {
this.epochtime = epochtime;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getMaptype() {
return maptype;
}
public void setMaptype(String maptype) {
this.maptype = maptype;
}
}
| [
"[email protected]"
] | |
824df8707419af87355205dfa56283ddc7e69c47 | a830a4dbb8a0065d7678109427e8b0afc449f90d | /src/com/github/saka1029/obscure/core/Applicable.java | cb69725e8e433161da94cab65c81b58c324fd1c7 | [] | no_license | saka1029/Obscure | 5906b770c3979260d150f2c9d53f3dc45fe93ed5 | 1b00af8a753c8274b4f1f70256ba89b1b0c62474 | refs/heads/master | 2021-01-19T03:18:26.914316 | 2020-09-28T08:26:27 | 2020-09-28T08:26:27 | 49,537,154 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 133 | java | package com.github.saka1029.obscure.core;
public interface Applicable {
Object apply(Object self, List args, Env env);
}
| [
"[email protected]"
] | |
3f459471260aabec35a7fe9947929c79d427fa30 | b18632be9bb40b4097534e58e0b2d69dc7230fe5 | /overloadaio/skills/woodcutting/WoodcuttingTask.java | 576f9ba97a9f41b52be5acf59c00968b239f4372 | [] | no_license | OSBot-Transporter/com.acescripts.scripts | ed1d96626f644c50d9692f5b1e657e5d58096f5a | 452b15e59db4419d0aa2aff2df33269b9c4423de | refs/heads/master | 2020-09-23T08:33:07.212205 | 2016-08-26T08:49:46 | 2016-08-26T08:49:46 | 66,629,238 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,145 | java | package com.acescripts.scripts.overloadaio.skills.woodcutting;
import com.acescripts.scripts.overloadaio.OverloadAIO;
import com.acescripts.scripts.overloadaio.framework.Task;
import com.acescripts.scripts.overloadaio.framework.BankLocations;
import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;
import static org.osbot.rs07.script.MethodProvider.random;
import static org.osbot.rs07.script.MethodProvider.sleep;
/**
* Created by Transporter on 26/07/2016 at 01:23.
*/
public class WoodcuttingTask implements Task {
private Script script;
private String toChop;
private int stopLevel;
private Area choppingArea;
private boolean shouldBank = false;
public WoodcuttingTask(Script script, String toChop, int stopLevel, Area choppingArea, boolean shouldBank) {
this.script = script;
this.toChop = toChop;
this.stopLevel = stopLevel;
this.choppingArea = choppingArea;
this.shouldBank = shouldBank;
}
private enum State {
BANK, CHOP, DROP, WALK_TO_TREES, WAIT
}
private State getState() {
Entity tree = script.objects.closest(toChop);
if(script.inventory.isFull() && shouldBank || !script.inventory.contains(1351)) {
return State.BANK;
}
if(!script.inventory.isFull() && tree != null && !script.myPlayer().isAnimating() && choppingArea.contains(script.myPlayer())) {
return State.CHOP;
}
if(script.inventory.isFull() && !shouldBank) {
return State.DROP;
}
if(!script.inventory.isFull() && !choppingArea.contains(script.myPlayer())) {
return State.WALK_TO_TREES;
}
return State.WAIT;
}
public void proceed() throws InterruptedException {
switch (getState()) {
case BANK:
//OverloadAIO.status = "Banking";
OverloadAIO.status = "WAITING..." + script.configs.get(406);
Area currentBank = BankLocations.closestTo(script.myPlayer());
if(currentBank.contains(script.myPlayer())) {
if(script.getBank().isOpen()) {
if(script.inventory.contains(1351)) {
script.getBank().depositAllExcept(1351);
script.getBank().close();
} else {
if(!script.getInventory().isEmptyExcept(1351)) {
script.getBank().depositAll();
}
script.getBank().withdraw(1351, 1);
}
} else {
script.getBank().open();
}
sleep(random(1000, 1400));
} else {
script.walking.webWalk(currentBank);
}
break;
case CHOP:
RS2Object tree = script.getObjects().closest(new Filter<RS2Object>(){
@Override
public boolean match(RS2Object object) {
return object != null && object.getName().equals(toChop) && choppingArea.contains(object.getPosition());
}
});
OverloadAIO.status = "Chop";
if (tree != null && tree.isVisible()) {
tree.interact("Chop down");
new ConditionalSleep(2000) {
@Override
public boolean condition() {
return script.myPlayer().isAnimating() && script.myPlayer().isMoving();
}
}.sleep();
} else {
if(tree != null) {
if (script.myPosition().distance(tree.getPosition()) > 3) {
Position spec = new Position(tree.getPosition().getX(), tree.getPosition().getY() - 2, tree.getPosition().getZ());
if(!WoodcuttingLocations.EDGEVILLE.getArea().contains(tree)) {
script.walking.walk(spec);
}
}
script.camera.toPosition(tree.getPosition());
}
}
break;
case DROP:
OverloadAIO.status = "Drop";
script.inventory.dropAll("Oak logs");
break;
case WALK_TO_TREES:
OverloadAIO.status = "Walking To Trees";
script.walking.webWalk(choppingArea);
break;
case WAIT:
OverloadAIO.status = "Waiting...";
break;
}
}
public boolean isFinished() {
return script.skills.getDynamic(Skill.WOODCUTTING) >= stopLevel;
}
}
| [
"[email protected]"
] | |
cf658624489115c8a9b87c3c6efe0a59811d390d | 2ce34e174794035e9aadd7f75e297cb13b055cf6 | /SSMStudy/src/test/java/com/ht/service/UserServiceTest.java | 9dea127d5ab25da783049c1066ed08da6cce0ffd | [] | no_license | NDCFL/MyProject | 3940c41d0e2849c589c3d2c4760e00a9e8a04ace | 4bfa0551a3276323cf9011522d99e52f87a7c3ea | refs/heads/master | 2021-04-26T04:52:09.688809 | 2017-10-15T12:30:43 | 2017-10-15T12:30:43 | 107,008,511 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 789 | java | package com.ht.service;
import com.ht.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
/**
* Created by Administrator on 2017/9/28.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(value = {"classpath:/config/spring-applicationContext.xml", "classpath:/config/spring-mybatis.xml"})
public class UserServiceTest{
@Resource
private UserService userService;
@Test
public void testAddUser(){
User user = new User();
user.setName("刘红");
user.setAge(25);
for(int i=0;i<200000;i++){
userService.add(user);
}
}
}
| [
"[email protected]"
] | |
3e019b2c064b8d12835060913a55da5841afe028 | 0e4e779e6e214fb05d753aae0477b3d3931e97ad | /cc-spring-boot-starter-parent/cc-spring-sys/cc-spring-sys-server/src/main/java/cc/cc4414/spring/sys/service/IUserDeptService.java | c898924d7ae931c619ad7f2639598abbec70583c | [
"Apache-2.0"
] | permissive | cc4414/cc-spring | f3b2b294eab2715ed15d17ea18c3ec3197e906e1 | 1fc6edcc5a692774cdd08fd7fb5bf6715c14188c | refs/heads/master | 2020-08-06T18:12:15.910672 | 2020-03-25T03:51:22 | 2020-03-25T03:51:22 | 213,102,744 | 11 | 1 | null | null | null | null | UTF-8 | Java | false | false | 298 | java | package cc.cc4414.spring.sys.service;
import com.baomidou.mybatisplus.extension.service.IService;
import cc.cc4414.spring.sys.entity.UserDept;
/**
* 用户部门表 服务类
*
* @author cc 2019年11月15日
*/
public interface IUserDeptService extends IService<UserDept> {
}
| [
"[email protected]"
] | |
7d396d9659da70430591325561dd0bb40a4c4475 | 3062f0dfb2fdd25adc903a9a09b273a496d8a29e | /core/src/main/java/edu/nyu/cascade/c/preprocessor/steenscfs/BlankType.java | 95d55d945c334e7c74e2a32a52783784d9005cc7 | [] | no_license | wei-wang-523/cascade | 7fe86ebdb4c1b8eb798d96ea297a47aa20e58299 | c0751fb37d33631f825548a7810744843f654a2a | refs/heads/master | 2021-03-24T10:21:11.708671 | 2016-02-03T02:16:13 | 2016-02-03T02:16:13 | 50,804,900 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,291 | java | package edu.nyu.cascade.c.preprocessor.steenscfs;
class BlankType extends ValueType {
private Parent parent;
private final Size size;
private boolean op;
BlankType(Size size, Parent parent, boolean op) {
this.size = size;
this.parent = parent;
this.op = op;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder().append("BLANK (")
.append(size)
.append(", ")
.append(parent)
.append(", ")
.append(op)
.append(')');
return sb.toString();
}
@Override
public boolean equals(Object o) {
if(!(o instanceof BlankType)) return false;
BlankType that = (BlankType) o;
if(!size.equals(that.size)) return false;
if(!parent.equals(that.parent)) return false;
if(op != that.op) return false;
return true;
}
/**
* Get Blank(T, {})
* @return
*/
static BlankType getTop() {
return new BlankType(
Size.getTop(),
Parent.getBottom(),
false);
}
@Override
ValueTypeKind getKind() {
return ValueTypeKind.BLANK;
}
@Override
void setParent(Parent parent) {
this.parent = parent;
}
@Override
Size getSize() {
return size;
}
@Override
Parent getParent() {
return parent;
}
@Override
boolean hasOpTag() {
return op;
}
@Override
void enableOpTag() {
op = true;
}
}
| [
"wwang1109@0979de3b-1556-0410-81eb-980c3fe2c0d2"
] | wwang1109@0979de3b-1556-0410-81eb-980c3fe2c0d2 |
3ee9d9246336392df0ae23da6c9a3222779acccc | dbf901f3bbf40bdfeaaab7008073eb929895a984 | /search-core/src/main/java/com/xiu/search/core/service/impl/.svn/text-base/SimilarGoodsSolrServiceImpl.java.svn-base | 8f3de170bee43827b5d0d52933cdacce92ce7488 | [] | no_license | tomdev2008/search-1 | 9f204b634100334ec0fdd869e6557ac34c3a09e6 | b42fd51bffbc1c1c7761a8ebc3305f79ca90a1b5 | refs/heads/master | 2021-05-31T22:14:24.523282 | 2016-06-08T02:51:17 | 2016-06-08T02:51:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,884 | package com.xiu.search.core.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiu.search.core.service.GoodsSolrService;
import com.xiu.search.core.service.MemCachedService;
import com.xiu.search.core.service.SimilarGoodsSolrService;
import com.xiu.search.core.solr.enumeration.SearchSortOrderEnum;
import com.xiu.search.core.solr.index.GoodsIndexFieldEnum;
import com.xiu.search.core.solr.model.GoodsSolrModel;
import com.xiu.search.core.solr.params.SearchFatParams;
import com.xiu.search.dao.XiuItemInfoDAO;
import com.xiu.search.dao.cache.CacheManage;
import com.xiu.search.dao.cache.CacheTypeEnum;
import com.xiu.search.solrj.service.SearchResult;
@Service("similarGoodsSolrService")
public class SimilarGoodsSolrServiceImpl implements SimilarGoodsSolrService {
private Logger logger = Logger.getLogger(getClass());
@Autowired
private GoodsSolrService goodsSolrService;
@Autowired
private XiuItemInfoDAO xiuItemInfoDAO;
@Autowired
private MemCachedService memCachedService;
private final String MEMCACHE_KEY = "search";
@SuppressWarnings("unchecked")
@Override
public List<Map<String, String>> findSimilarGoodsByPartNumber(
String partNumber) {
Object obj = CacheManage.get(partNumber, CacheTypeEnum.SIMILAR_ITEMS);
if (null != obj) {
List<Map<String, String>> goodsList = (List<Map<String, String>>) obj;
List<String> keys = new ArrayList<String>();
for (Map<String, String> item : goodsList) {
String partNum = item.get(GoodsIndexFieldEnum.PART_NUMBER
.fieldName());
keys.add(MEMCACHE_KEY + partNum);
}
// 查询memcache商品价格
queryMemcacheForItemPrice(goodsList, keys);
return goodsList;
}
// TODO 查询相似商品组ID select * from xiu_similar_products
String similarGroupId = null;
try {
similarGroupId = xiuItemInfoDAO
.selectByPartNumberForSimilarGroupId(partNumber);
if (null == similarGroupId)
return null;
} catch (Exception e) {
logger.error("query similar goods for similar group id fail", e);
return null;
}
SearchFatParams solrParams = new SearchFatParams();
solrParams.setSimilarGroupId(similarGroupId);
solrParams.setBuyableFlag(true);
solrParams.setSort(SearchSortOrderEnum.SIMILAR_DESC);
SearchResult<GoodsSolrModel> goodsResult = this.goodsSolrService
.findSearchXiuSolr(solrParams, false, null);
if (null != goodsResult && goodsResult.getBeanList().size() > 0) {
List<Map<String, String>> goodsList = new ArrayList<Map<String, String>>();
// 缓存key,从memcache取价格
List<String> keys = new ArrayList<String>();
for (GoodsSolrModel goods : goodsResult.getBeanList()) {
Map<String, String> goodsMap = new HashMap<String, String>();
goodsMap.put(GoodsIndexFieldEnum.ITEM_ID.fieldName(),
goods.getItemId());
goodsMap.put(GoodsIndexFieldEnum.ITEM_NAME.fieldName(),
goods.getItemName());
goodsMap.put(GoodsIndexFieldEnum.PART_NUMBER.fieldName(),
goods.getPartNumber());
goodsMap.put(GoodsIndexFieldEnum.IMG_URL.fieldName(),
goods.getImgUrl());
goodsMap.put(GoodsIndexFieldEnum.PRICE_FINAL.fieldName(),
goods.getPriceFinal() + "");
String itemColor = "";
if (null != goods.getItemColor()) {
Set<String> colorSet = new HashSet<String>();
// 去重
for (String color : goods.getItemColor()) {
colorSet.add(color);
}
for (String color : colorSet) {
itemColor += itemColor.length() > 0 ? color + "|"
: color;
}
}
String itemSize = "";
if (null != goods.getItemSize()) {
Set<String> sizeSet = new TreeSet<String>();
// 去重加排序
for (String size : goods.getItemSize()) {
sizeSet.add(size);
}
for (String size : sizeSet) {
itemSize += itemSize.length() > 0 ? size + "|" : size;
}
}
goodsMap.put(GoodsIndexFieldEnum.ITEM_COLOR.fieldName(),
itemColor);
goodsMap.put(GoodsIndexFieldEnum.ITEM_SIZE.fieldName(),
itemSize);
keys.add(MEMCACHE_KEY + goods.getPartNumber());
goodsList.add(goodsMap);
}
// 查询memcache商品价格
queryMemcacheForItemPrice(goodsList, keys);
//是否存在此走秀码
boolean flag=false;
for (String key : keys) {
if(key.equals(MEMCACHE_KEY+partNumber)){
flag=true;
break;
}
}
//如果不存在添加剩余的商品
if(!flag){
CacheManage.put(partNumber, goodsList,CacheTypeEnum.SIMILAR_ITEMS);
}
// 克隆放入缓存
for (int i = 0; i < goodsList.size(); i++) {
ArrayList<Map<String, String>> similarGoodsList = cloneGoodsList(goodsList);
String partNum = similarGoodsList.get(i).get(
GoodsIndexFieldEnum.PART_NUMBER.fieldName());
similarGoodsList.remove(i);
CacheManage.put(partNum, similarGoodsList,
CacheTypeEnum.SIMILAR_ITEMS);
}
obj = CacheManage.get(partNumber, CacheTypeEnum.SIMILAR_ITEMS);
if (null != obj)
return (List<Map<String, String>>) obj;
}
return null;
}
private void queryMemcacheForItemPrice(List<Map<String, String>> goodsList,
List<String> keys) {
// 查询memcache缓存的价格
try {
Map<String, Object> itemsMap = memCachedService.getMulti(keys);
if (null != itemsMap && itemsMap.size() > 0) {
for (Map<String, String> itemMap : goodsList) {
String partNum = itemMap
.get(GoodsIndexFieldEnum.PART_NUMBER.fieldName());
Object price = itemsMap.get(MEMCACHE_KEY + partNum);
if (null == price || StringUtils.isEmpty(price.toString())) {
continue;
}
BigDecimal priceDecimal = new BigDecimal(price.toString())
.divide(new BigDecimal(100));
itemMap.put(GoodsIndexFieldEnum.PRICE_FINAL.fieldName(),
priceDecimal.toString());
}
}
} catch (Exception e) {
logger.error("query memcache similar goods for goods price fail", e);
e.printStackTrace();
}
}
private ArrayList<Map<String, String>> cloneGoodsList(
List<Map<String, String>> goodsList) {
ArrayList<Map<String, String>> goodsListClone = new ArrayList<Map<String, String>>();
for (Map<String, String> goodsMap : goodsList) {
try {
goodsListClone.add(goodsMap);
} catch (Exception e) {
logger.error("query similar goods for clone goods list fail", e);
e.printStackTrace();
}
}
return goodsListClone;
}
@Override
public long selectCountForId() {
try{
return xiuItemInfoDAO.selectCountForId();
}catch (Exception e) {
logger.error("operated selectCountForId() fail:", e);
e.printStackTrace();
return -1l;
}
}
}
| [
"[email protected]"
] | ||
c9ffc051539a6b4631e5ccf3adab325a0edb9f05 | 0ef601b4c49c7efd3ea469598d93a787dc1cd9c5 | /app/src/main/java/com/example/example_bipolar_factory/Urls.java | 48fe03e4293e0deb1d8f7e2af7cce0347e41d3ab | [] | no_license | Raj1803/exaple_unsplace | 5cc80c034dfdbc7c366f62e08a32ca4cee10eeb0 | f068ed207929deef4ffb00cff4561532f1d8172c | refs/heads/master | 2022-11-15T02:45:39.434358 | 2020-07-09T18:08:23 | 2020-07-09T18:08:23 | 278,434,181 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,046 | java | package com.example.example_bipolar_factory;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Urls {
@SerializedName("raw")
@Expose
private String raw;
@SerializedName("full")
@Expose
private String full;
@SerializedName("regular")
@Expose
private String regular;
@SerializedName("small")
@Expose
private String small;
@SerializedName("thumb")
@Expose
private String thumb;
public String getFull() {
return full;
}
public void setFull(String full) {
this.full = full;
}
public String getRegular() {
return regular;
}
public void setRegular(String regular) {
this.regular = regular;
}
public String getSmall() {
return small;
}
public void setSmall(String small) {
this.small = small;
}
public String getThumb() {
return thumb;
}
public void setThumb(String thumb) {
this.thumb = thumb;
}
}
| [
"[email protected]"
] | |
61ea083b932c3de6b302209054eea2a902374f07 | 54409512544118c8113c3f6a8520dcd54adf3479 | /Reservation-app/src/main/java/ma/youcode/reservation/Security/MyUserDetails.java | dc34a7f6ced70c04b473ef3d0525704ec54ea75d | [] | no_license | kamal1-cloud/Application-Reservation-de-place | 548688faf055ded823ebd10d5f4bb719b416b7d8 | 1dd09b544f9d9154d7222af6f4e01271d2845138 | refs/heads/main | 2023-03-26T05:41:46.933514 | 2021-03-31T11:36:01 | 2021-03-31T11:36:01 | 345,319,433 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,734 | java | package ma.youcode.reservation.Security;
import ma.youcode.reservation.Models.UsersEntity;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collection;
public class MyUserDetails implements UserDetails {
private UsersEntity user;
public MyUserDetails(UsersEntity user) {
this.user = user;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
SimpleGrantedAuthority authority = new SimpleGrantedAuthority(user.getRole());
return Arrays.asList(authority);
}
@Override
public String getPassword() {
return user.getPassword();
}
@Override
public String getUsername() {
return user.getEmail();
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
if(this.getStatus() == false) return false;
return true;
}
public Boolean getStatus(){
return user.getStatus();
}
public String getNom(){
return user.getNom();
}
public String getPrenom(){
return user.getPrenom();
}
public String getCin(){
return user.getCin();
}
public Timestamp getCurrentdate(){
return user.getCurrentdate();
}
public UsersEntity getUser() {
return user;
}
}
| [
"[email protected]"
] | |
5b96fc25e5e6ea02ae27d2c24dde3a1263b3351d | 8fd083defa49669108c9ce36a9875fe2ccb9b573 | /src/main/java/ua/com/timetracker/repository/BacklogRepository.java | 9f6d959e529d46e60a075a45523bf81a5c771540 | [] | no_license | ivolchkov/TimetrackerSpring | 478d8251097ab724b54f520f4f39c27363345c88 | 355099711bc734fbb6f17dff5e28396cef7e71b9 | refs/heads/master | 2020-09-10T15:32:57.677025 | 2019-12-10T14:47:15 | 2019-12-10T14:47:15 | 221,740,559 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 298 | java | package ua.com.timetracker.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import ua.com.timetracker.entity.BacklogEntity;
@Repository
public interface BacklogRepository extends JpaRepository<BacklogEntity, Integer> {
}
| [
"[email protected]"
] | |
974b8e92bae343a37bc24ef3540d60553767bb51 | cb1e25645c88267e5933113e3463782a9cef63ea | /src/test/java/org/test/DnsTest.java | 8569b1debf2c91fd3cc8c12f224870432b39a466 | [] | no_license | mazurkin/test-netty-dns | b4a14f82787e7a623c0e6a33ee8e0d00332dbc0c | e18ef2fd63c97a442941bd0255b7cd2478d54152 | refs/heads/master | 2021-04-25T20:20:30.083730 | 2017-11-13T13:33:56 | 2017-11-13T13:33:56 | 109,232,298 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,782 | java | package org.test;
import com.sun.jna.Platform;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.EpollDatagramChannel;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.resolver.ResolvedAddressTypes;
import io.netty.resolver.dns.DnsNameResolver;
import io.netty.resolver.dns.DnsNameResolverBuilder;
import io.netty.resolver.dns.SingletonDnsServerAddressStreamProvider;
import io.netty.util.concurrent.DefaultThreadFactory;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.test.jna.CLibAdapter;
import org.test.direct.NameServices;
import org.xbill.DNS.ARecord;
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.Resolver;
import org.xbill.DNS.SimpleResolver;
import org.xbill.DNS.TextParseException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.zip.GZIPInputStream;
public class DnsTest {
private static final Logger LOGGER = LoggerFactory.getLogger(DnsTest.class);
private static final InetSocketAddress DNS_ADDRESS_GOOGLE_PUBLIC = new InetSocketAddress("8.8.8.8", 53);
private static final InetSocketAddress DNS_ADDRESS_PRIVATE = new InetSocketAddress("10.201.50.60", 53);
private static final InetSocketAddress DNS_ADDRESS_LOCAL_UBUNTU = new InetSocketAddress("127.0.1.1", 53);
private static final InetSocketAddress DNS_ADDRESS_LOCAL_PDNSD = new InetSocketAddress("127.0.0.1", 10053);
private static final InetSocketAddress DNS_ADDRESS = DNS_ADDRESS_GOOGLE_PUBLIC;
private static final int NETTY_POOL_THREADS = 1;
private static final int TIMEOUT_SEC = 20;
private static final int MAX_QUERIES = 20;
private static final int MAX_PAYLOAD = 64 * 1024;
private static final int DOMAIN_COUNT = 1000;
private static final int CONCURRENCY = 64;
private static List<String> domains;
private EventLoopGroup nettyGroup;
private DnsNameResolver nettyResolver;
private SimpleResolver dnsJavaTcpResolver;
private SimpleResolver dnsJavaUdpResolver;
@BeforeClass
public static void setUpClass() throws Exception {
try (InputStream is = DnsTest.class.getResourceAsStream("/crawler_domains.txt.gz")) {
try (GZIPInputStream gis = new GZIPInputStream(is)) {
domains = IOUtils.readLines(gis, StandardCharsets.UTF_8);
}
}
}
@Before
public void setUp() throws Exception {
nettyGroup = new EpollEventLoopGroup(NETTY_POOL_THREADS, new DefaultThreadFactory("DNS pool"));
SingletonDnsServerAddressStreamProvider dnsServerProvider =
new SingletonDnsServerAddressStreamProvider(DNS_ADDRESS);
nettyResolver = new DnsNameResolverBuilder(nettyGroup.next())
.channelType(EpollDatagramChannel.class)
.queryTimeoutMillis(TimeUnit.SECONDS.toMillis(TIMEOUT_SEC))
.maxQueriesPerResolve(MAX_QUERIES)
.maxPayloadSize(MAX_PAYLOAD)
.resolvedAddressTypes(ResolvedAddressTypes.IPV4_ONLY)
.nameServerProvider(dnsServerProvider)
.build();
dnsJavaTcpResolver = new SimpleResolver();
dnsJavaTcpResolver.setAddress(DNS_ADDRESS);
dnsJavaTcpResolver.setTimeout(TIMEOUT_SEC);
dnsJavaTcpResolver.setTCP(true);
dnsJavaUdpResolver = new SimpleResolver();
dnsJavaUdpResolver.setAddress(DNS_ADDRESS);
dnsJavaUdpResolver.setTimeout(TIMEOUT_SEC);
dnsJavaUdpResolver.setTCP(false);
}
@After
public void tearDown() throws Exception {
if (nettyGroup != null) {
nettyGroup.shutdownGracefully().sync();
}
if (nettyResolver != null) {
nettyResolver.close();
}
}
@Test
public void remoteNettyAsyncDns() throws Exception {
resolveDnsAsync(domain -> resolveNettyAsync(domain, nettyResolver));
}
@Test
public void systemJavaSyncDns() throws Exception {
resolveDnsSync(DnsTest::resolveSystemSync);
}
@Test
public void systemDirectSyncDns() throws Exception {
resolveDnsSync(DnsTest::resolveSystemSyncDirect);
}
@Test
public void systemJnaSyncDns1() throws Exception {
Assume.assumeTrue(Platform.isLinux());
resolveDnsSync(DnsTest::resolveSystemSyncJna1);
}
@Test
public void systemJnaSyncDns2() throws Exception {
Assume.assumeTrue(Platform.isLinux());
resolveDnsSync(DnsTest::resolveSystemSyncJna2);
}
@Test
public void remoteJavaLibTcpSyncDns() throws Exception {
resolveDnsSync(domain -> resolveSimpleSync(domain, dnsJavaTcpResolver));
}
@Test
public void remoteJavaLibUdpSyncDns() throws Exception {
resolveDnsSync(domain -> resolveSimpleSync(domain, dnsJavaUdpResolver));
}
@Ignore("run `src/test/resources/crawler_domains-adnshost.sh`")
@Test
public void systemADnsHostCommandDns() throws Exception {
// see the comment above
}
private static void resolveDnsSync(Function<String, InetAddress> resolver)
throws InterruptedException
{
LOGGER.info("Started resolving {} domains", DOMAIN_COUNT);
ExecutorService executorService = Executors.newFixedThreadPool(CONCURRENCY);
AtomicInteger succeed = new AtomicInteger(0);
for (String domain : domains.subList(0, DOMAIN_COUNT)) {
executorService.submit(() -> {
InetAddress address = resolver.apply(domain);
if (address != null) {
succeed.incrementAndGet();
LOGGER.trace("{} = [{}]", domain, address.getHostAddress());
} else {
LOGGER.trace("{} = NONE", domain);
}
return true;
});
}
executorService.shutdown();
executorService.awaitTermination(30, TimeUnit.MINUTES);
LOGGER.info("Succeed {} domains", succeed.get());
}
private static void resolveDnsAsync(Function<String, CompletableFuture<InetAddress>> resolver)
throws InterruptedException
{
LOGGER.info("Started resolving {} domains", DOMAIN_COUNT);
BlockingQueue<DnsResult> queue = new LinkedBlockingDeque<>();
Semaphore semaphore = new Semaphore(CONCURRENCY);
// Schedule async DNS resolves
for (String domain : domains.subList(0, DOMAIN_COUNT)) {
semaphore.acquire();
CompletableFuture<InetAddress> future = resolver.apply(domain);
future.whenComplete((address, ex) -> {
semaphore.release();
DnsResult result = new DnsResult();
result.domain = domain;
if (ex == null) {
result.resolved = true;
result.message = address.getHostAddress();
} else {
result.resolved = false;
result.message = ex.getClass().getCanonicalName() + " / " + ex.getLocalizedMessage();
}
queue.add(result);
});
}
LOGGER.info("All requests are published");
// Wait pending results and check
int fn = 0;
int tn = 0;
int p = 0;
for (int i = 0; i < DOMAIN_COUNT; i++) {
DnsResult result = queue.take();
if (result.resolved) {
LOGGER.trace("{} Y {} : [{}]", i, result.domain, result.message);
p++;
} else {
LOGGER.trace("{} N {} : {}", i, result.domain, result.message);
InetAddress realAddress = resolveSystemSync(result.domain);
if (realAddress != null) {
fn++;
LOGGER.trace(" !!! SYNC [{}]", realAddress.getHostAddress());
} else {
tn++;
}
}
}
// Output statistics
LOGGER.info("False negatives : {}", fn);
LOGGER.info("True negatives : {}", tn);
LOGGER.info("Succeed : {}", p);
}
private static CompletableFuture<InetAddress> resolveNettyAsync(String domain, DnsNameResolver nettyResolver) {
return future(nettyResolver.resolve(domain));
}
private static InetAddress resolveSystemSync(String domain) {
// Uses JVM/system DNS resolver
try {
return InetAddress.getByName(domain);
} catch (UnknownHostException e) {
return null;
}
}
private static InetAddress resolveSystemSyncDirect(String domain) {
// Uses JVM/system DNS resolver (no caching, no sync)
try {
InetAddress[] addresses = NameServices.resolve(domain);
if (addresses != null && addresses.length > 0) {
return addresses[0];
} else {
return null;
}
} catch (UnknownHostException e) {
return null;
}
}
private static InetAddress resolveSystemSyncJna1(String domain) {
// Uses JVM/system DNS resolver (no caching, no sync)
try {
InetAddress[] addresses = CLibAdapter.resolve1(domain);
return addresses[0];
} catch (UnknownHostException e) {
return null;
}
}
private static InetAddress resolveSystemSyncJna2(String domain) {
// Uses JVM/system DNS resolver (no caching, no sync)
try {
InetAddress[] addresses = CLibAdapter.resolve2(domain);
return addresses[0];
} catch (UnknownHostException e) {
return null;
}
}
private static InetAddress resolveSimpleSync(String domain, Resolver resolver) {
Lookup lookup;
try {
lookup = new Lookup(domain);
} catch (TextParseException e) {
return null;
}
lookup.setResolver(resolver);
Record[] records = lookup.run();
if (lookup.getResult() == Lookup.SUCCESSFUL && records != null && records.length > 0) {
return ((ARecord) records[0]).getAddress();
} else {
return null;
}
}
private static <T> CompletableFuture<T> future(io.netty.util.concurrent.Future<T> future) {
CompletableFuture<T> result = new CompletableFuture<T>() {
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return super.cancel(mayInterruptIfRunning) && future.cancel(mayInterruptIfRunning);
}
};
future.addListener((f) -> {
if (future.isSuccess()) {
result.complete(future.get());
} else if (!future.isCancelled()) {
result.completeExceptionally(future.cause());
}
});
return result;
}
private static final class DnsResult {
private String domain;
private String message;
private boolean resolved;
}
}
| [
"[email protected]"
] | |
d8066c8be74cdd82a0ddec13be4143bf9cc509b5 | cc18a58f076dbb68da9956a48cc147523b5a98e9 | /src/main/java/net/karatek/tgbot/exampleToken.java | 46b0f46c172848ccf6028a4d20cabeed3278c0d6 | [] | no_license | KaratekHD/NemesisJava | 9c1a47d8e59848be2bc4bfc8399fc6e031dd1c50 | edf6ff2b4efbb665e55afa356260bb8aeed0bcb8 | refs/heads/master | 2020-11-27T18:13:03.115030 | 2020-08-15T07:44:06 | 2020-08-15T07:44:06 | 229,556,694 | 0 | 0 | null | 2020-07-04T10:00:20 | 2019-12-22T11:21:29 | Java | UTF-8 | Java | false | false | 183 | java | package net.karatek.tgbot;
public class exampleToken {
/*
Insert your API Token here
Rename this class to 'Token'
*/
public static final String TOKEN = "";
}
| [
"[email protected]"
] | |
5eabb69dda5694fceed048f3d3a9ab1ecbdb0edf | f6872cf8c3ace0d3d332463e251ea3375cba1919 | /cyklotron-ui/src/main/java/net/cyklotron/cms/modules/actions/search/UpdateConfiguration.java | e258b03d7ede557367f7d40762447215880fc573 | [] | no_license | objectledge/cyklotron | a04870bca4d5ce21e073347312af1785d9578ce6 | d82857595377d745d03a4d3386fec3e7240d57ff | refs/heads/master | 2020-04-05T19:10:49.283763 | 2016-01-05T17:17:17 | 2016-01-05T17:17:17 | 6,192,701 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,711 | java | package net.cyklotron.cms.modules.actions.search;
import org.jcontainer.dna.Logger;
import org.objectledge.context.Context;
import org.objectledge.coral.security.Subject;
import org.objectledge.coral.session.CoralSession;
import org.objectledge.coral.store.Resource;
import org.objectledge.parameters.Parameters;
import org.objectledge.pipeline.ProcessingException;
import org.objectledge.templating.TemplatingContext;
import org.objectledge.web.HttpContext;
import org.objectledge.web.mvc.MVCContext;
import net.cyklotron.cms.CmsData;
import net.cyklotron.cms.CmsDataFactory;
import net.cyklotron.cms.search.RootResource;
import net.cyklotron.cms.search.SearchException;
import net.cyklotron.cms.search.SearchService;
import net.cyklotron.cms.site.SiteResource;
import net.cyklotron.cms.structure.NavigationNodeResource;
import net.cyklotron.cms.structure.StructureException;
import net.cyklotron.cms.structure.StructureService;
/**
* Updates search application configuration.
*
* @author <a href="mailto:[email protected]">Damian Gajda</a>
* @version $Id: UpdateConfiguration.java,v 1.5 2007-02-25 14:15:27 pablo Exp $
*/
public class UpdateConfiguration extends BaseSearchAction
{
public UpdateConfiguration(Logger logger, StructureService structureService,
CmsDataFactory cmsDataFactory, SearchService searchService)
{
super(logger, structureService, cmsDataFactory, searchService);
}
/**
* Performs the action.
*/
public void execute(Context context, Parameters parameters, MVCContext mvcContext, TemplatingContext templatingContext, HttpContext httpContext, CoralSession coralSession)
throws ProcessingException
{
Subject subject = coralSession.getUserSubject();
SiteResource site = getSite(context);
try
{
String path = parameters.get("searchNodePath","");
NavigationNodeResource searchNode = null;
if(!path.equals(""))
{
Resource parent = structureService.getRootNode(coralSession, site).getParent();
Resource[] ress = coralSession.getStore().getResourceByPath(parent.getPath()+path);
if(ress.length == 1)
{
searchNode = (NavigationNodeResource)ress[0];
}
else if(ress.length > 1)
{
throw new ProcessingException("multiple nodes with path="+path);
}
else // length == 0
{
templatingContext.put("result", "no_node_with_given_path");
return;
}
}
RootResource searchRoot = searchService.getSearchRoot(coralSession, site);
searchRoot.setSearchNode(searchNode);
searchRoot.update();
}
catch(SearchException e)
{
throw new ProcessingException("cannot get search root", e);
}
catch(StructureException e)
{
throw new ProcessingException("cannot get search node", e);
}
templatingContext.put("result","updated_successfully");
}
public boolean checkAccessRights(Context context)
throws ProcessingException
{
CmsData cmsData = cmsDataFactory.getCmsData(context);
if(!cmsData.isApplicationEnabled("search"))
{
logger.debug("Application 'search' not enabled in site");
return false;
}
CoralSession coralSession = (CoralSession)context.getAttribute(CoralSession.class);
return checkPermission(context, coralSession, "cms.search.configure");
}
}
| [
"[email protected]"
] | |
acb9e7d0ccb8bc1d03bcbd0f83b72134d9747824 | a1c22f872f6f9eab431d430385741b0884204b25 | /src/com/charpter4/E01.java | 6287321486cd3e0c15a92c5e13209740dbd4f8ef | [] | no_license | ztang-660/ZT_1802 | d2851465ff2959258d32efdfccd6856184387f7e | dccb12b4beb4fc7879b890ee2c8aeea014c2fc84 | refs/heads/master | 2020-11-25T18:11:33.272626 | 2019-12-18T07:49:01 | 2019-12-18T07:49:01 | 228,787,888 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 626 | java | package com.charpter4;
class Animal{
//Field:成员变量
String name;
//Method:成员方法
void shout() {
System.out.println("动物发出的叫声");
}
}
class Dog extends Animal{
//继承了Animal类的所有成员变量和成员方法
public void printName() {
System.out.println("name="+name);
}
void shout() {
System.out.println("旺旺旺");
}
public void printname() {
System.out.println("name="+name);
}
}
public class E01 {
public static void main(String[] args) {
Dog dog=new Dog();
dog.name="哈士奇";
dog.printName();
dog.shout();
}
}
| [
"[email protected]"
] | |
4b9867894587d30ec58cbce4705bf873a9c48f8e | bf0ba27a77a3f69e13424a288b9ec947b112d7d8 | /addressbook-web-test/src/test/java/ru/stqa/pft/addressbook/tests/GroupDeleteTests.java | 053f03eb20e5ed6f2e481a5940a6e5f7a96ee0ba | [
"Apache-2.0"
] | permissive | AlexAZakharov/java_school | 0534a3776b48c3a6610c6bc04585211882a802f7 | 1b43eaaa64fdff134fb55bf08c15e48ae0669212 | refs/heads/master | 2021-01-16T18:26:09.006403 | 2020-05-04T17:49:34 | 2020-05-04T17:49:34 | 100,073,074 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,094 | java | package ru.stqa.pft.addressbook.tests;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.GroupDate;
import ru.stqa.pft.addressbook.model.Groups;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.testng.Assert.assertEquals;
public class GroupDeleteTests extends TestBase {
@BeforeMethod
public void ensurePreconditions(){
if ( app.db().groups("").size() ==0){
app.goTo().groupPage();
app.group().create(new GroupDate().withName("test1").withHeader("test3"));
}
}
@Test
public void testsGroupDelete() {
Groups before = app.db().groups("");
GroupDate deletedGroup = before.iterator().next();
app.goTo().groupPage();
app.group().delete(deletedGroup);
assertEquals(app.group().count(),before.size()-1);
Groups after = app.db().groups("");
assertThat(after, equalTo(before.withOut(deletedGroup)));
verifyGroupListInUi();
}
}
| [
"[email protected]"
] | |
f5847b98e621d5db6b857377863d2c0698570b36 | 56ec756bbb223482bed9367cc28ae1f12f330107 | /src/day02_printStatements/helloCybertek.java | 88ed10cb64ae97f60b07672b4e38a11e5d167398 | [] | no_license | kadyrkuloff/Summer20 | b969d22b0a7728e04b9bfc779f0003fe8005b4c1 | 7788e908a45d94acc8df316e53538135dcbd4864 | refs/heads/master | 2022-12-05T20:53:25.780893 | 2020-08-02T16:59:39 | 2020-08-02T16:59:39 | 284,329,016 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 290 | java | package day02_printStatements;
public class helloCybertek {
public static void main(String[] args){
System.out.println("Hello Batch 20");
System.out.println("Hello Cybertek!");
System.out.println(" I Love Java Programming Language");
}
}
| [
"[email protected]"
] | |
0ca3b3e08b93729d86ec2b4a932e04b7f9fcb59f | 131844cd77b8758e3b2e13de88453ae42f2e3d46 | /XMVideoCollocation/src/main/java/cn/xm/xmvideoplayer/ui/act_Splash.java | f937933cb98d08ac2abc166f31434ce102e1f8bc | [
"Apache-2.0"
] | permissive | moto998/XMVideo | 1aa5c4ce5dbe552b919269f7255d0753cb88cfdd | 5a1feac7437b859657bb367516db68adeda2ecee | refs/heads/master | 2021-01-21T06:46:49.887575 | 2016-11-02T15:50:51 | 2016-11-02T15:50:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,269 | java | package cn.xm.xmvideoplayer.ui;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.qq.e.ads.splash.SplashAD;
import com.qq.e.ads.splash.SplashADListener;
import org.lzh.framework.updatepluginlib.UpdateBuilder;
import org.lzh.framework.updatepluginlib.callback.UpdateCheckCB;
import org.lzh.framework.updatepluginlib.callback.UpdateDownloadCB;
import org.lzh.framework.updatepluginlib.model.Update;
import org.lzh.framework.updatepluginlib.strategy.UpdateStrategy;
import java.io.File;
import butterknife.Bind;
import butterknife.ButterKnife;
import cn.xm.xmvideoplayer.R;
import cn.xm.xmvideoplayer.constant.AdConstant;
import cn.xm.xmvideoplayer.core.BaseActivity;
import cn.xm.xmvideoplayer.ui.activity.act_home;
public class act_Splash extends BaseActivity implements SplashADListener {
@SuppressWarnings("unused")
private SplashAD splashAD;
private ViewGroup container;
private Handler handler = new Handler();
public boolean canJump = false;
@Bind(R.id.app_logo)
ImageView app_log;
@Override
public String setUmengTag() {
return "act_splash";
}
@Override
public int getLayoutId() {
return R.layout.act_launch;
}
@Override
public void initViews(Bundle savedInstanceState) {
container = ButterKnife.findById(act_Splash.this, R.id.splash_container);
Glide.with(this)
.load(R.drawable.background)
.fitCenter()
.into(app_log);
}
/**
* 检查版本更新
*/
private void checkUpdate() {
//检查更新
UpdateBuilder.create()
.checkCB(new UpdateCheckCB() {
@Override
public void onCheckError(int code, String errorMsg) {
//Toast.makeText(act_Splash.this, "更新失败:code:" + code, Toast.LENGTH_SHORT).show();
starAd();
}
@Override
public void onUserCancel() {
Toast.makeText(act_Splash.this, "取消更新", Toast.LENGTH_SHORT).show();
starAd();
}
@Override
public void onCheckIgnore(Update update) {}
@Override
public void hasUpdate(Update update) {}
@Override
public void noUpdate() {
//Toast.makeText(act_Splash.this, "最新版本", Toast.LENGTH_SHORT).show();
starAd();
}
})
// apk下载的回调
.downloadCB(new UpdateDownloadCB() {
@Override
public void onUpdateStart() {
}
@Override
public void onUpdateComplete(File file) {
}
@Override
public void onUpdateProgress(long current, long total) {
}
@Override
public void onUpdateError(int code, String errorMsg) {
//Toast.makeText(act_Splash.this, "下载失败:code:" + code, Toast.LENGTH_SHORT).show();
starAd();
}
})
.strategy(new UpdateStrategy() {
@Override
public boolean isShowUpdateDialog(Update update) {
// 有新更新直接展示
return true;
}
@Override
public boolean isAutoInstall() {
return true;
}
@Override
public boolean isShowDownloadDialog() {
// 展示下载进度
return true;
}
})
.check(act_Splash.this);
}
/**
* 开始广告
*/
public void starAd() {
splashAD = new SplashAD(this, container, AdConstant.APPID, AdConstant.SplashPosID, this);
}
@Override
public void initToolBar() {
}
/**
* 开屏广告现已增加新的接口,可以由开发者在代码中设置开屏的超时时长
* SplashAD(Activity activity, ViewGroup container, String appId, String posId, SplashADListener adListener, int fetchDelay)
* fetchDelay参数表示开屏的超时时间,单位为ms,取值范围[3000, 5000]。设置为0时表示使用广点通的默认开屏超时配置
* <p/>
* splashAD = new SplashAD(this, container, AdConstant.APPID, AdConstant.SplashPosID, this, 3000);可以设置超时时长为3000ms
*/
@Override
public void onADPresent() {
Log.i("AD_DEMO", "SplashADPresent");
}
@Override
public void onADClicked() {
Log.i("AD_DEMO", "SplashADClicked");
}
@Override
public void onADDismissed() {
Log.i("AD_DEMO", "SplashADDismissed");
next();
}
@Override
public void onNoAD(int errorCode) {
Log.i("AD_DEMO", "LoadSplashADFail, eCode=" + errorCode);
handler.postDelayed(new Runnable() {
@Override
public void run() {
/** 如果加载广告失败,则直接跳转 */
act_Splash.this.startActivity(new Intent(act_Splash.this, act_home.class));
overridePendingTransition(R.anim.slide_right_in, R.anim.slide_left_out);
act_Splash.this.finish();
}
}, 1500);
}
/**
* 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后,
* 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。
*/
private void next() {
if (canJump) {
this.startActivity(new Intent(this, act_home.class));
overridePendingTransition(R.anim.slide_right_in, R.anim.slide_left_out);
this.finish();
} else {
canJump = true;
}
}
@Override
protected void onPause() {
super.onPause();
canJump = false;
}
@Override
protected void onResume() {
super.onResume();
checkUpdate();
if (canJump) {
next();
}
canJump = true;
}
/**
* 开屏页最好禁止用户对返回按钮的控制
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) {
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacksAndMessages(null);
}
}
| [
"[email protected]"
] | |
4d35687ba1a9adf8ed0c2f632610ebe8bcfa1b8b | d0c12b80e80ef4e51cc9043ef95810bc67320cc4 | /jva-p1-for-students/toStudents/m1/tasks/m1-jva007/src/com/luxoft/basics/part1/text/E7_NPE.java | 4f3597461286bee3e93955156a172ebf9a2e512f | [] | no_license | kosnko/JavaTraining | ef2f2cc605569922e83bbb70c20734b19bb1846d | d4f713d8908585ad91253695d7628c2e286611a1 | refs/heads/master | 2020-04-24T08:47:40.752406 | 2019-03-12T14:36:36 | 2019-03-12T14:36:36 | 171,841,803 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 266 | java | package com.luxoft.basics.part1.text;
public class E7_NPE
{
public static void main(String[] args)
{
String str = "abcdefg...";
System.out.println("0: " + str);
str = null;
System.out.println("1: " + str.length());
}
}
| [
"[email protected]"
] | |
4e5029c66bbd547958294e47cd8d1913d326fb80 | a61d677b3a8c996189238b873a982157f86ba0cc | /src/main/java/com/starfall/ssm/entity/Department.java | cbc6d66c3b1e74ce68f7960ae28fa6f43e1b79ab | [] | no_license | Star-Fall/SSM | 4a3d17352e4c2404cbc7e8efc1800b4e55bbda23 | a7dd24923fffbe77fa1076f1a427fd475097ccb3 | refs/heads/master | 2020-04-26T07:51:46.350628 | 2019-03-18T14:53:30 | 2019-03-18T14:53:30 | 173,406,277 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 992 | java | package com.starfall.ssm.entity;
/**
* @name:Department
* @description: Department
* @author: StarFall
* @data: 2019年3月18日下午9:09:58
*/
public class Department {
private Integer departmentId;
private String departmentName;
private Integer managerId;
private Integer locationId;
public Integer getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Integer departmentId) {
this.departmentId = departmentId;
}
public String getDepartmentName() {
return departmentName;
}
public void setDepartmentName(String departmentName) {
this.departmentName = departmentName == null ? null : departmentName.trim();
}
public Integer getManagerId() {
return managerId;
}
public void setManagerId(Integer managerId) {
this.managerId = managerId;
}
public Integer getLocationId() {
return locationId;
}
public void setLocationId(Integer locationId) {
this.locationId = locationId;
}
} | [
"[email protected]"
] | |
adacd39c006383260e68ef9eed2cd8996c833fa1 | d2798388180b926e131b9b5e5c542de5b5dbd607 | /src/by/it/sinkevich/project/java/CommandPlaceBet.java | d6e6768eaab66c685571ccfe35f4e6719c627c69 | [] | no_license | VasilevichSergey/JD2016 | 14a22a5c31ded3783014b9d89cdddf0eb6ad4398 | dfb8e38a6c4022677708dc03d0047d76bc801bfd | refs/heads/master | 2020-12-24T20:25:06.458871 | 2016-10-04T10:35:49 | 2016-10-04T10:35:49 | 58,029,314 | 0 | 0 | null | 2016-05-04T06:46:27 | 2016-05-04T06:46:27 | null | UTF-8 | Java | false | false | 263 | java | package by.it.sinkevich.project.java;
import javax.servlet.http.HttpServletRequest;
public class CommandPlaceBet implements ActionCommand {
@Override
public String execute(HttpServletRequest request) {
return Action.PLACE_BET.startPage;
}
}
| [
"[email protected]"
] | |
1b342a4b1cc43a937b5a17635f3796064aa91343 | 5a0d31cb783643c52e82c85ed28f3a4564e1043e | /src/main/java/com/social/socialmedia/controllers/RegistrationController.java | 184c1bfc6a3f883142e2585b80fdac172bca4907 | [] | no_license | KirillAmber/SocialMedia | b9cd8b148ef3cdafe03f5dfe4f3c336388187b38 | 2325c757a03a6728fa06d773a838f8b492f28ac1 | refs/heads/master | 2023-03-17T06:44:59.900962 | 2021-03-13T09:12:38 | 2021-03-13T09:12:38 | 344,971,052 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,476 | java | package com.social.socialmedia.controllers;
import com.social.socialmedia.domain.User;
import com.social.socialmedia.domain.dto.CaptchaResponseDto;
import com.social.socialmedia.repos.UserRepo;
import com.social.socialmedia.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.validation.Valid;
import java.util.Collections;
import java.util.Map;
@Controller
public class RegistrationController {
private static String CAPTCHA_URL="https://www.google.com/recaptcha/api/siteverify?secret=%s&response=%s";
private UserService userService;
private RestTemplate restTemplate;
@Value("${recaptcha.secret}")
private String secret;
@Autowired
public void setUserService(UserService userService) {
this.userService = userService;
}
@Autowired
public void setRestTemplate(RestTemplate restTemplate){
this.restTemplate = restTemplate;
}
@GetMapping("/registration")
public String registration(){
return "registration";
}
@PostMapping("/registration")
public String create(@RequestParam("password2") String passwordConfirm,
@RequestParam("g-recaptcha-response") String captchaResponse,
@Valid User user, BindingResult bindingResult,
Model model){
String endpoint = String.format(CAPTCHA_URL, secret, captchaResponse);
CaptchaResponseDto responseDto = restTemplate.postForObject(endpoint, Collections.emptyList(), CaptchaResponseDto.class);
if (responseDto != null && !responseDto.isSuccess()) {
model.addAttribute("captchaError", "Fill captcha");
}
boolean isConfirmEmpty = StringUtils.isEmpty(passwordConfirm);
if(isConfirmEmpty){
model.addAttribute("password2Error", "Password cannot be empty");
}
if(user.getPassword()!=null && !user.getPassword().equals(passwordConfirm)){
model.addAttribute("passwordError", "Passwords aren't equal!");
return "registration";
}
if(isConfirmEmpty || bindingResult.hasErrors() || !responseDto.isSuccess()){
Map<String, String> errors = UtilsController.getErrors(bindingResult);
model.mergeAttributes(errors);
System.out.println(bindingResult);
return "registration";
}
if(!userService.create(user)){
model.addAttribute("usernameError", "User exists");
return "registration";
}
return "redirect:/login";
}
@GetMapping("/activate/{code}")
public String activate(@PathVariable String code, Model model){
boolean isActivated = userService.activateUser(code);
if(isActivated){
model.addAttribute("message", "User successfully activated");
model.addAttribute("messageType", "alert alert-success");
} else{
model.addAttribute("message", "Activation code isn't found!");
model.addAttribute("messageType", "alert alert-danger");
}
return "login";
}
}
| [
"[email protected]"
] | |
a8cf5b3c0bd17c416dfd9dabd829ae02db47d917 | e1ee2640717f31f79cf4d265107e521b0a177686 | /doing/assignment/src/com/gyh/part1/day19/Solution1.java | 097ad810b927f87dd5feb5addfad36735376839d | [] | no_license | Googleearth/wdxly | 2f5450870bf9b2d18b17a1bf8b9267da07f8507a | 5941d02cc6a5e431577cdc88054fb6de961e9bcf | refs/heads/master | 2022-11-10T01:43:11.794650 | 2020-06-20T02:36:02 | 2020-06-20T02:36:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 948 | java | package com.gyh.part1.day19;
import java.io.*;
public class Solution1 {
public static void main(String[] args) throws IOException {
String[] words = {"verb:eat","verb:drink","verb:sleep","verb:play",
"noun:rice","noun:meat","noun:hand","noun:hair"};
OutputStream outVerb = new BufferedOutputStream(
new FileOutputStream("verb.txt"));
OutputStream outNoun = new BufferedOutputStream(
new FileOutputStream("noun.txt"));
for (String s : words) {
if (s.substring(0, 4).equals("verb")) { // 判断
byte[] bytesVerb = (s.substring(5, s.length()) + '\n').getBytes();
outVerb.write(bytesVerb);
} else {
byte[] bytesNoun = (s.substring(5, s.length()) + '\n').getBytes();
outNoun.write(bytesNoun);
}
}
outVerb.close();
outNoun.close();
}
}
| [
"[email protected]"
] | |
9d93c0f957dbf16d8bdbc7f79f35ffbd019dea62 | 7517432ec8b94e0d02ed1d50409b3bb402e82420 | /org.xtext.example.skem/src-gen/org/xtext/example/mydsl/myDsl/util/MyDslAdapterFactory.java | b8ff1069351c63eb078462e79b38679d0fdfc4d0 | [] | no_license | alexandrebing/T2LinguagensDeProgramacao | 27569018e2b4b6a0f5dded0e460bb0f03ec7f2b8 | 9045c68abd3347bc40ccbcd1b9825aa2f7d5ddc4 | refs/heads/master | 2020-05-04T14:32:27.511817 | 2019-04-15T11:57:18 | 2019-04-15T11:57:18 | 178,304,615 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,248 | java | /**
* generated by Xtext 2.13.0
*/
package org.xtext.example.mydsl.myDsl.util;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
import org.eclipse.emf.ecore.EObject;
import org.xtext.example.mydsl.myDsl.*;
/**
* <!-- begin-user-doc -->
* The <b>Adapter Factory</b> for the model.
* It provides an adapter <code>createXXX</code> method for each class of the model.
* <!-- end-user-doc -->
* @see org.xtext.example.mydsl.myDsl.MyDslPackage
* @generated
*/
public class MyDslAdapterFactory extends AdapterFactoryImpl
{
/**
* The cached model package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static MyDslPackage modelPackage;
/**
* Creates an instance of the adapter factory.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MyDslAdapterFactory()
{
if (modelPackage == null)
{
modelPackage = MyDslPackage.eINSTANCE;
}
}
/**
* Returns whether this factory is applicable for the type of the object.
* <!-- begin-user-doc -->
* This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
* <!-- end-user-doc -->
* @return whether this factory is applicable for the type of the object.
* @generated
*/
@Override
public boolean isFactoryForType(Object object)
{
if (object == modelPackage)
{
return true;
}
if (object instanceof EObject)
{
return ((EObject)object).eClass().getEPackage() == modelPackage;
}
return false;
}
/**
* The switch that delegates to the <code>createXXX</code> methods.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MyDslSwitch<Adapter> modelSwitch =
new MyDslSwitch<Adapter>()
{
@Override
public Adapter caseModel(Model object)
{
return createModelAdapter();
}
@Override
public Adapter caseArguments(Arguments object)
{
return createArgumentsAdapter();
}
@Override
public Adapter caseVariable(Variable object)
{
return createVariableAdapter();
}
@Override
public Adapter caseFunction(Function object)
{
return createFunctionAdapter();
}
@Override
public Adapter defaultCase(EObject object)
{
return createEObjectAdapter();
}
};
/**
* Creates an adapter for the <code>target</code>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param target the object to adapt.
* @return the adapter for the <code>target</code>.
* @generated
*/
@Override
public Adapter createAdapter(Notifier target)
{
return modelSwitch.doSwitch((EObject)target);
}
/**
* Creates a new adapter for an object of class '{@link org.xtext.example.mydsl.myDsl.Model <em>Model</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
* it's useful to ignore a case when inheritance will catch all the cases anyway.
* <!-- end-user-doc -->
* @return the new adapter.
* @see org.xtext.example.mydsl.myDsl.Model
* @generated
*/
public Adapter createModelAdapter()
{
return null;
}
/**
* Creates a new adapter for an object of class '{@link org.xtext.example.mydsl.myDsl.Arguments <em>Arguments</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
* it's useful to ignore a case when inheritance will catch all the cases anyway.
* <!-- end-user-doc -->
* @return the new adapter.
* @see org.xtext.example.mydsl.myDsl.Arguments
* @generated
*/
public Adapter createArgumentsAdapter()
{
return null;
}
/**
* Creates a new adapter for an object of class '{@link org.xtext.example.mydsl.myDsl.Variable <em>Variable</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
* it's useful to ignore a case when inheritance will catch all the cases anyway.
* <!-- end-user-doc -->
* @return the new adapter.
* @see org.xtext.example.mydsl.myDsl.Variable
* @generated
*/
public Adapter createVariableAdapter()
{
return null;
}
/**
* Creates a new adapter for an object of class '{@link org.xtext.example.mydsl.myDsl.Function <em>Function</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
* it's useful to ignore a case when inheritance will catch all the cases anyway.
* <!-- end-user-doc -->
* @return the new adapter.
* @see org.xtext.example.mydsl.myDsl.Function
* @generated
*/
public Adapter createFunctionAdapter()
{
return null;
}
/**
* Creates a new adapter for the default case.
* <!-- begin-user-doc -->
* This default implementation returns null.
* <!-- end-user-doc -->
* @return the new adapter.
* @generated
*/
public Adapter createEObjectAdapter()
{
return null;
}
} //MyDslAdapterFactory
| [
"[email protected]"
] | |
50a5b83a867c4833d2ac5ad4f28738246eef4638 | 065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be | /eclipsejdt_cluster/2396/tar_1.java | e3e0a067d9c38bbc87a8fa47bb10cbfac5a4a558 | [] | no_license | martinezmatias/GenPat-data-C3 | 63cfe27efee2946831139747e6c20cf952f1d6f6 | b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4 | refs/heads/master | 2022-04-25T17:59:03.905613 | 2020-04-15T14:41:34 | 2020-04-15T14:41:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 579,812 | java | /*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.core.tests.dom;
import java.util.*;
import junit.framework.Test;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.core.jdom.*;
import org.eclipse.jdt.core.util.IModifierConstants;
public class ASTConverterTest extends ConverterTestSetup {
/** @deprecated using deprecated code */
public void setUpSuite() throws Exception {
super.setUpSuite();
this.ast = AST.newAST(AST.JLS2);
}
public ASTConverterTest(String name) {
super(name);
}
static {
// TESTS_NUMBERS = new int[] { 305 };
}
public static Test suite() {
return buildModelTestSuite(ASTConverterTest.class);
}
/** @deprecated using deprecated code */
public void test0001() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0001", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
// check that we have the right tree
CompilationUnit unit = this.ast.newCompilationUnit();
PackageDeclaration packageDeclaration = this.ast.newPackageDeclaration();
packageDeclaration.setName(this.ast.newSimpleName("test0001"));//$NON-NLS-1$
unit.setPackage(packageDeclaration);
ImportDeclaration importDeclaration = this.ast.newImportDeclaration();
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newSimpleName("java"),//$NON-NLS-1$
this.ast.newSimpleName("util"));//$NON-NLS-1$
importDeclaration.setName(name);
importDeclaration.setOnDemand(true);
unit.imports().add(importDeclaration);
TypeDeclaration type = this.ast.newTypeDeclaration();
type.setInterface(false);
type.setModifiers(Modifier.PUBLIC);
type.setName(this.ast.newSimpleName("Test"));//$NON-NLS-1$
MethodDeclaration methodDeclaration = this.ast.newMethodDeclaration();
methodDeclaration.setConstructor(false);
methodDeclaration.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
methodDeclaration.setName(this.ast.newSimpleName("main"));//$NON-NLS-1$
methodDeclaration.setReturnType(this.ast.newPrimitiveType(PrimitiveType.VOID));
SingleVariableDeclaration variableDeclaration = this.ast.newSingleVariableDeclaration();
variableDeclaration.setModifiers(Modifier.NONE);
variableDeclaration.setType(this.ast.newArrayType(this.ast.newSimpleType(this.ast.newSimpleName("String"))));//$NON-NLS-1$
variableDeclaration.setName(this.ast.newSimpleName("args"));//$NON-NLS-1$
methodDeclaration.parameters().add(variableDeclaration);
org.eclipse.jdt.core.dom.Block block = this.ast.newBlock();
MethodInvocation methodInvocation = this.ast.newMethodInvocation();
name =
this.ast.newQualifiedName(
this.ast.newSimpleName("System"),//$NON-NLS-1$
this.ast.newSimpleName("out"));//$NON-NLS-1$
methodInvocation.setExpression(name);
methodInvocation.setName(this.ast.newSimpleName("println")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.PLUS);
StringLiteral literal = this.ast.newStringLiteral();
literal.setLiteralValue("Hello");//$NON-NLS-1$
infixExpression.setLeftOperand(literal);
literal = this.ast.newStringLiteral();
literal.setLiteralValue(" world");//$NON-NLS-1$
infixExpression.setRightOperand(literal);//$NON-NLS-1$
methodInvocation.arguments().add(infixExpression);
ExpressionStatement expressionStatement = this.ast.newExpressionStatement(methodInvocation);
block.statements().add(expressionStatement);
methodDeclaration.setBody(block);
type.bodyDeclarations().add(methodDeclaration);
unit.types().add(type);
assertTrue("Both AST trees should be identical", result.subtreeMatch(new ASTMatcher(), unit));//$NON-NLS-1$
String expected =
"package test0001;\n" +
"import java.util.*;\n" +
"public class Test {\n" +
" public static void main(String[] args) {\n" +
" System.out.println(\"Hello\" + \" world\");\n" +
" }\n" +
"}";
checkSourceRange(result, expected, source);
}
/**
* Test allocation expression: new Object() ==> ClassInstanceCreation
* @deprecated using deprecated code
*/
public void test0002() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0002", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
classInstanceCreation.setName(this.ast.newSimpleName("Object")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new Object()", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new java.lang.Object() ==> ClassInstanceCreation
* @deprecated using deprecated code
*/
public void test0003() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0003", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newQualifiedName(
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Object"));//$NON-NLS-1$
classInstanceCreation.setName(name);
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new java.lang.Object()", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new java.lang.Exception("ERROR") ==> ClassInstanceCreation
* @deprecated using deprecated code
*/
public void test0004() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0004", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newQualifiedName(
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Exception"));//$NON-NLS-1$
classInstanceCreation.setName(name);
StringLiteral literal = this.ast.newStringLiteral();
literal.setLiteralValue("ERROR"); //$NON-NLS-1$
classInstanceCreation.arguments().add(literal);
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new java.lang.Exception(\"ERROR\")", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new java.lang.Object() {} ==> ClassInstanceCreation
* @deprecated using deprecated code
*/
public void test0005() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0005", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newQualifiedName(
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Object"));//$NON-NLS-1$
classInstanceCreation.setName(name);
AnonymousClassDeclaration anonymousClassDeclaration = this.ast.newAnonymousClassDeclaration();
classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new java.lang.Object() {}", source); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation2 = (ClassInstanceCreation) expression;
Name name2 = classInstanceCreation2.getName();
checkSourceRange(name2, "java.lang.Object", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new java.lang.Runnable() { public void run() {}} ==> ClassInstanceCreation
* @deprecated using deprecated code
*/
public void test0006() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0006", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newQualifiedName(
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Runnable"));//$NON-NLS-1$
classInstanceCreation.setName(name);
MethodDeclaration methodDeclaration = this.ast.newMethodDeclaration();
methodDeclaration.setBody(this.ast.newBlock());
methodDeclaration.setConstructor(false);
methodDeclaration.setModifiers(Modifier.PUBLIC);
methodDeclaration.setName(this.ast.newSimpleName("run"));//$NON-NLS-1$
methodDeclaration.setReturnType(this.ast.newPrimitiveType(PrimitiveType.VOID));
AnonymousClassDeclaration anonymousClassDeclaration = this.ast.newAnonymousClassDeclaration();
anonymousClassDeclaration.bodyDeclarations().add(methodDeclaration);
classInstanceCreation.setAnonymousClassDeclaration(anonymousClassDeclaration);
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new java.lang.Runnable() { public void run() {}}", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new Test().new D() ==> ClassInstanceCreation
* @deprecated using deprecated code
*/
public void test0007() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0007", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
ASTNode expression = (ASTNode) ((MethodInvocation) expressionStatement.getExpression()).arguments().get(0);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = this.ast.newClassInstanceCreation();
classInstanceCreation.setName(this.ast.newSimpleName("D")); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreationExpression = this.ast.newClassInstanceCreation();
classInstanceCreationExpression.setName(this.ast.newSimpleName("Test")); //$NON-NLS-1$
classInstanceCreation.setExpression(classInstanceCreationExpression);
assertTrue("Both AST trees should be identical", classInstanceCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new Test().new D()", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new int[] {1, 2, 3, 4} ==> ArrayCreation
*/
public void test0008() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0008", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ArrayCreation arrayCreation = this.ast.newArrayCreation();
arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
ArrayInitializer arrayInitializer = this.ast.newArrayInitializer();
arrayInitializer.expressions().add(this.ast.newNumberLiteral("1"));//$NON-NLS-1$
arrayInitializer.expressions().add(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
arrayInitializer.expressions().add(this.ast.newNumberLiteral("3"));//$NON-NLS-1$
arrayInitializer.expressions().add(this.ast.newNumberLiteral("4"));//$NON-NLS-1$
arrayCreation.setInitializer(arrayInitializer);
assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new int[] {1, 2, 3, 4}", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new int[][] {{1}, {2}} ==> ArrayCreation
*/
public void test0009() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0009", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ArrayCreation arrayCreation = this.ast.newArrayCreation();
arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 2));
ArrayInitializer arrayInitializer = this.ast.newArrayInitializer();
ArrayInitializer innerArrayInitializer = this.ast.newArrayInitializer();
innerArrayInitializer.expressions().add(this.ast.newNumberLiteral("1"));//$NON-NLS-1$
arrayInitializer.expressions().add(innerArrayInitializer);
innerArrayInitializer = this.ast.newArrayInitializer();
innerArrayInitializer.expressions().add(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
arrayInitializer.expressions().add(innerArrayInitializer);
arrayCreation.setInitializer(arrayInitializer);
assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new int[][] {{1}, {2}}", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new int[3] ==> ArrayCreation
*/
public void test0010() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0010", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ArrayCreation arrayCreation = this.ast.newArrayCreation();
arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
arrayCreation.dimensions().add(this.ast.newNumberLiteral("3")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new int[3]", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new int[3][] ==> ArrayCreation
*/
public void test0011() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0011", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ArrayCreation arrayCreation = this.ast.newArrayCreation();
arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 2));
arrayCreation.dimensions().add(this.ast.newNumberLiteral("3")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new int[3][]", source); //$NON-NLS-1$
}
/**
* Test allocation expression: new int[][] {{},{}} ==> ArrayCreation
*/
public void test0012() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0012", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
ArrayCreation arrayCreation = this.ast.newArrayCreation();
arrayCreation.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 2));
ArrayInitializer arrayInitializer = this.ast.newArrayInitializer();
ArrayInitializer innerArrayInitializer = this.ast.newArrayInitializer();
arrayInitializer.expressions().add(innerArrayInitializer);
innerArrayInitializer = this.ast.newArrayInitializer();
arrayInitializer.expressions().add(innerArrayInitializer);
arrayCreation.setInitializer(arrayInitializer);
assertTrue("Both AST trees should be identical", arrayCreation.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "new int[][] {{}, {}}", source); //$NON-NLS-1$
}
/**
* int i; ==> VariableDeclarationFragment
* @deprecated using deprecated code
*/
public void test0013() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0013", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int i;", source); //$NON-NLS-1$
}
/**
* int i = 0; ==> VariableDeclarationFragment
* @deprecated using deprecated code
*/
public void test0014() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0014", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int i = 0;", source); //$NON-NLS-1$
}
/**
* i = 1; ==> ExpressionStatement(Assignment)
*/
public void test0015() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0015", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("1")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i = 1;", source); //$NON-NLS-1$
}
/**
* i += 2; ==> ExpressionStatement(Assignment)
*/
public void test0016() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0016", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.PLUS_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i += 2;", source); //$NON-NLS-1$
}
/**
* i -= 2; ==> ExpressionStatement(Assignment)
*/
public void test0017() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0017", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.MINUS_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i -= 2;", source); //$NON-NLS-1$
}
/**
* i *= 2; ==> ExpressionStatement(Assignment)
*/
public void test0018() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0018", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.TIMES_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i *= 2;", source); //$NON-NLS-1$
}
/**
* i /= 2; ==> ExpressionStatement(Assignment)
*/
public void test0019() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0019", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.DIVIDE_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i /= 2;", source); //$NON-NLS-1$
}
/**
* i &= 2 ==> ExpressionStatement(Assignment)
*/
public void test0020() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0020", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.BIT_AND_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i &= 2;", source); //$NON-NLS-1$
}
/**
* i |= 2; ==> ExpressionStatement(Assignment)
*/
public void test0021() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0021", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.BIT_OR_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i |= 2;", source); //$NON-NLS-1$
}
/**
* i ^= 2; ==> ExpressionStatement(Assignment)
*/
public void test0022() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0022", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.BIT_XOR_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i ^= 2;", source); //$NON-NLS-1$
}
/**
* i %= 2; ==> ExpressionStatement(Assignment)
*/
public void test0023() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0023", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.REMAINDER_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i %= 2;", source); //$NON-NLS-1$
}
/**
* i <<= 2; ==> ExpressionStatement(Assignment)
*/
public void test0024() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0024", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.LEFT_SHIFT_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i <<= 2;", source); //$NON-NLS-1$
}
/**
* i >>= 2; ==> ExpressionStatement(Assignment)
*/
public void test0025() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0025", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_SIGNED_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i >>= 2;", source); //$NON-NLS-1$
}
/**
* i >>>= 2; ==> ExpressionStatement(Assignment)
*/
public void test0026() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0026", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Assignment assignment = this.ast.newAssignment();
assignment.setLeftHandSide(this.ast.newSimpleName("i")); //$NON-NLS-1$
assignment.setRightHandSide(this.ast.newNumberLiteral("2")); //$NON-NLS-1$
assignment.setOperator(Assignment.Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN);
ExpressionStatement statement = this.ast.newExpressionStatement(assignment);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i >>>= 2;", source); //$NON-NLS-1$
}
/**
* --i; ==> ExpressionStatement(PrefixExpression)
*/
public void test0027() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0027", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
prefixExpression.setOperator(PrefixExpression.Operator.DECREMENT);//$NON-NLS-1$
ExpressionStatement statement = this.ast.newExpressionStatement(prefixExpression);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "--i;", source); //$NON-NLS-1$
}
/**
* --i; ==> ExpressionStatement(PrefixExpression)
*/
public void test0028() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0028", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT);//$NON-NLS-1$
ExpressionStatement statement = this.ast.newExpressionStatement(prefixExpression);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "++i;", source); //$NON-NLS-1$
}
/**
* i--; ==> ExpressionStatement(PostfixExpression)
*/
public void test0029() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0029", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
PostfixExpression postfixExpression = this.ast.newPostfixExpression();
postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
postfixExpression.setOperator(PostfixExpression.Operator.DECREMENT);//$NON-NLS-1$
ExpressionStatement statement = this.ast.newExpressionStatement(postfixExpression);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i--;", source); //$NON-NLS-1$
}
/**
* i++; ==> ExpressionStatement(PostfixExpression)
*/
public void test0030() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0030", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
PostfixExpression postfixExpression = this.ast.newPostfixExpression();
postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);//$NON-NLS-1$
ExpressionStatement statement = this.ast.newExpressionStatement(postfixExpression);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "i++;", source); //$NON-NLS-1$
}
/**
* (String) o; ==> ExpressionStatement(CastExpression)
* @deprecated using deprecated code
*/
public void test0031() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0031", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
CastExpression castExpression = this.ast.newCastExpression();
castExpression.setExpression(this.ast.newSimpleName("o"));//$NON-NLS-1$
castExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(castExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "String s = (String) o;", source); //$NON-NLS-1$
}
/**
* (int) d; ==> ExpressionStatement(CastExpression)
* @deprecated using deprecated code
*/
public void test0032() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0032", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
CastExpression castExpression = this.ast.newCastExpression();
castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(castExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int i = (int) d;", source); //$NON-NLS-1$
}
/**
* (float) d; ==> ExpressionStatement(CastExpression)
* @deprecated using deprecated code
*/
public void test0033() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0033", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("f")); //$NON-NLS-1$
CastExpression castExpression = this.ast.newCastExpression();
castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.FLOAT));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(castExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.FLOAT));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "float f = (float) d;", source); //$NON-NLS-1$
}
/**
* (byte) d; ==> ExpressionStatement(CastExpression)
* @deprecated using deprecated code
*/
public void test0034() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0034", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b")); //$NON-NLS-1$
CastExpression castExpression = this.ast.newCastExpression();
castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.BYTE));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(castExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BYTE));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "byte b = (byte) d;", source); //$NON-NLS-1$
}
/**
* (short) d; ==> ExpressionStatement(CastExpression)
* @deprecated using deprecated code
*/
public void test0035() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0035", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
CastExpression castExpression = this.ast.newCastExpression();
castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.SHORT));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(castExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.SHORT));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "short s = (short) d;", source); //$NON-NLS-1$
}
/**
* (long) d; ==> ExpressionStatement(CastExpression)
* @deprecated using deprecated code
*/
public void test0036() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0036", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("l")); //$NON-NLS-1$
CastExpression castExpression = this.ast.newCastExpression();
castExpression.setExpression(this.ast.newSimpleName("d"));//$NON-NLS-1$
castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.LONG));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(castExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.LONG));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "long l = (long) d;", source); //$NON-NLS-1$
}
/**
* (char) i; ==> ExpressionStatement(CastExpression)
* @deprecated using deprecated code
*/
public void test0037() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0037", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
CastExpression castExpression = this.ast.newCastExpression();
castExpression.setExpression(this.ast.newSimpleName("i"));//$NON-NLS-1$
castExpression.setType(this.ast.newPrimitiveType(PrimitiveType.CHAR));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(castExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.CHAR));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "char c = (char) i;", source); //$NON-NLS-1$
}
/**
* int.class; ==> ExpressionStatement(TypeLiteral)
* @deprecated using deprecated code
*/
public void test0038() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0038", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
TypeLiteral typeLiteral = this.ast.newTypeLiteral();
typeLiteral.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
variableDeclarationFragment.setInitializer(typeLiteral);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("Class")));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(((VariableDeclarationFragment)((VariableDeclarationStatement)node).fragments().get(0)).getInitializer(), "int.class", source); //$NON-NLS-1$
}
/**
* void.class; ==> ExpressionStatement(TypeLiteral)
* @deprecated using deprecated code
*/
public void test0039() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0039", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
TypeLiteral typeLiteral = this.ast.newTypeLiteral();
typeLiteral.setType(this.ast.newPrimitiveType(PrimitiveType.VOID));
variableDeclarationFragment.setInitializer(typeLiteral);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("Class")));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(((VariableDeclarationFragment)((VariableDeclarationStatement)node).fragments().get(0)).getInitializer(), "void.class", source); //$NON-NLS-1$
}
/**
* double.class; ==> ExpressionStatement(TypeLiteral)
* @deprecated using deprecated code
*/
public void test0040() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0040", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
TypeLiteral typeLiteral = this.ast.newTypeLiteral();
typeLiteral.setType(this.ast.newPrimitiveType(PrimitiveType.DOUBLE));
variableDeclarationFragment.setInitializer(typeLiteral);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("Class")));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(((VariableDeclarationFragment)((VariableDeclarationStatement)node).fragments().get(0)).getInitializer(), "double.class", source); //$NON-NLS-1$
}
/**
* long.class; ==> ExpressionStatement(TypeLiteral)
* @deprecated using deprecated code
*/
public void test0041() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0041", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("c")); //$NON-NLS-1$
TypeLiteral typeLiteral = this.ast.newTypeLiteral();
typeLiteral.setType(this.ast.newPrimitiveType(PrimitiveType.LONG));
variableDeclarationFragment.setInitializer(typeLiteral);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newSimpleType(this.ast.newSimpleName("Class")));//$NON-NLS-1$
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(((VariableDeclarationFragment)((VariableDeclarationStatement)node).fragments().get(0)).getInitializer(), "long.class", source); //$NON-NLS-1$
}
/**
* false ==> BooleanLiteral
*/
public void test0042() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0042", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
BooleanLiteral literal = this.ast.newBooleanLiteral(false);
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "false", source); //$NON-NLS-1$
}
/**
* true ==> BooleanLiteral
*/
public void test0043() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0043", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
BooleanLiteral literal = this.ast.newBooleanLiteral(true);
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "true", source); //$NON-NLS-1$
}
/**
* null ==> NullLiteral
*/
public void test0044() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0044", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
NullLiteral literal = this.ast.newNullLiteral();
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "null", source); //$NON-NLS-1$
}
/**
* CharLiteral ==> CharacterLiteral
*/
public void test0045() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0045", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
CharacterLiteral literal = this.ast.newCharacterLiteral();
literal.setEscapedValue("'c'"); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "'c'", source); //$NON-NLS-1$
}
/**
* DoubleLiteral ==> NumberLiteral
*/
public void test0046() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0046", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral("1.00001");//$NON-NLS-1$
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "1.00001", source); //$NON-NLS-1$
}
/**
* FloatLiteral ==> NumberLiteral
*/
public void test0047() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0047", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral("1.00001f");//$NON-NLS-1$
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "1.00001f", source); //$NON-NLS-1$
}
/**
* IntLiteral ==> NumberLiteral
*/
public void test0048() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0048", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral("30000");//$NON-NLS-1$
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "30000", source); //$NON-NLS-1$
}
/**
* IntLiteralMinValue ==> NumberLiteral
*/
public void test0049() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0049", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral("-2147483648");//$NON-NLS-1$
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "-2147483648", source); //$NON-NLS-1$
}
/**
* LongLiteral ==> NumberLiteral
*/
public void test0050() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0050", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral("2147483648L");//$NON-NLS-1$
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "2147483648L", source); //$NON-NLS-1$
}
/**
* LongLiteral ==> NumberLiteral (negative value)
*/
public void test0051() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0051", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral("2147483648L");//$NON-NLS-1$
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperand(literal);
prefixExpression.setOperator(PrefixExpression.Operator.MINUS);
assertTrue("Both AST trees should be identical", prefixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "-2147483648L", source); //$NON-NLS-1$
}
/**
* LongLiteralMinValue ==> NumberLiteral
*/
public void test0052() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0052", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral("-9223372036854775808L");//$NON-NLS-1$
assertTrue("Both AST trees should be identical", literal.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "-9223372036854775808L", source); //$NON-NLS-1$
}
/**
* ExtendedStringLiteral ==> StringLiteral
*/
public void test0053() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0053", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
/*
StringLiteral literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue("Hello World");*/
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.PLUS);
StringLiteral literal = this.ast.newStringLiteral();
literal.setLiteralValue("Hello");//$NON-NLS-1$
infixExpression.setLeftOperand(literal);
literal = this.ast.newStringLiteral();
literal.setLiteralValue(" World");//$NON-NLS-1$
infixExpression.setRightOperand(literal);//$NON-NLS-1$
assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "\"Hello\" + \" World\"", source); //$NON-NLS-1$
}
/**
* AND_AND_Expression ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0054() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0054", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b3")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("b2")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b3 = b && b2;", source); //$NON-NLS-1$
}
/**
* OR_OR_Expression ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0055() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0055", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b3")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("b2")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.CONDITIONAL_OR);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b3 = b || b2;", source); //$NON-NLS-1$
}
/**
* EqualExpression ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0056() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0056", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b3")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("b2")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.EQUALS);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b3 = b == b2;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (+) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0057() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0057", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.PLUS);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = i + j;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (-) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0058() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0058", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.MINUS);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = i - j;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (*) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0059() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0059", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.TIMES);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = i * j;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (/) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0060() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0060", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.DIVIDE);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = i / j;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (%) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0061() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0061", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.REMAINDER);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = i % j;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (^) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0062() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0062", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.XOR);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = i ^ j;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (&) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0063() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0063", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.AND);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = i & j;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (|) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0064() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0064", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("j")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.OR);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = i | j;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (<) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0065() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0065", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.LESS);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b2 = b < b1;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (<=) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0066() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0066", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.LESS_EQUALS);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b2 = b <= b1;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (>) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0067() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0067", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.GREATER);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b2 = b > b1;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (>=) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0068() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0068", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.GREATER_EQUALS);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b2 = b >= b1;", source); //$NON-NLS-1$
}
/**
* BinaryExpression (!=) ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0069() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0069", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 2);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b2")); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("b")); //$NON-NLS-1$
infixExpression.setRightOperand(this.ast.newSimpleName("b1")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.NOT_EQUALS);
variableDeclarationFragment.setInitializer(infixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b2 = b != b1;", source); //$NON-NLS-1$
}
/**
* InstanceofExpression ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0070() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0070", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b")); //$NON-NLS-1$
InstanceofExpression instanceOfExpression = this.ast.newInstanceofExpression();
instanceOfExpression.setLeftOperand(this.ast.newSimpleName("o"));//$NON-NLS-1$
SimpleType simpleType = this.ast.newSimpleType(this.ast.newSimpleName("Integer"));//$NON-NLS-1$
instanceOfExpression.setRightOperand(simpleType);
variableDeclarationFragment.setInitializer(instanceOfExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b = o instanceof Integer;", source); //$NON-NLS-1$
}
/**
* InstanceofExpression ==> InfixExpression
* @deprecated using deprecated code
*/
public void test0071() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0071", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b")); //$NON-NLS-1$
InstanceofExpression instanceOfExpression = this.ast.newInstanceofExpression();
instanceOfExpression.setLeftOperand(this.ast.newSimpleName("o")); //$NON-NLS-1$
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newQualifiedName(
this.ast.newSimpleName("java"), //$NON-NLS-1$
this.ast.newSimpleName("lang")), //$NON-NLS-1$
this.ast.newSimpleName("Integer")); //$NON-NLS-1$
Type type = ast.newSimpleType(name);
instanceOfExpression.setRightOperand(type);
variableDeclarationFragment.setInitializer(instanceOfExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b = o instanceof java.lang.Integer;", source); //$NON-NLS-1$
}
/**
* UnaryExpression (!) ==> PrefixExpression
* @deprecated using deprecated code
*/
public void test0072() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0072", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b1")); //$NON-NLS-1$
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperator(PrefixExpression.Operator.NOT);
prefixExpression.setOperand(this.ast.newSimpleName("b"));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(prefixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b1 = !b;", source); //$NON-NLS-1$
}
/**
* UnaryExpression (~) ==> PrefixExpression
* @deprecated using deprecated code
*/
public void test0073() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0073", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("n")); //$NON-NLS-1$
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperator(PrefixExpression.Operator.COMPLEMENT);
prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(prefixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int n = ~i;", source); //$NON-NLS-1$
}
/**
* UnaryExpression (+) ==> PrefixExpression
* @deprecated using deprecated code
*/
public void test0074() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0074", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperator(PrefixExpression.Operator.PLUS);
prefixExpression.setOperand(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(prefixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int i = +2;", source); //$NON-NLS-1$
}
/**
* UnaryExpression (-) ==> PrefixExpression
* @deprecated using deprecated code
*/
public void test0075() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0075", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperator(PrefixExpression.Operator.MINUS);
prefixExpression.setOperand(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(prefixExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int i = -2;", source); //$NON-NLS-1$
}
/**
* ConditionalExpression ==> ConditionalExpression
* @deprecated using deprecated code
*/
public void test0076() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0076", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("b")); //$NON-NLS-1$
ConditionalExpression conditionalExpression = this.ast.newConditionalExpression();
InfixExpression condition = this.ast.newInfixExpression();
condition.setLeftOperand(this.ast.newSimpleName("args")); //$NON-NLS-1$
condition.setRightOperand(this.ast.newNullLiteral()); //$NON-NLS-1$
condition.setOperator(InfixExpression.Operator.NOT_EQUALS);
conditionalExpression.setExpression(condition);
conditionalExpression.setThenExpression(this.ast.newBooleanLiteral(true));
conditionalExpression.setElseExpression(this.ast.newBooleanLiteral(false));
variableDeclarationFragment.setInitializer(conditionalExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.BOOLEAN));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "boolean b = args != null ? true : false;", source); //$NON-NLS-1$
}
/**
* ConditionalExpression ==> ConditionalExpression
* @deprecated using deprecated code
*/
public void test0077() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0077", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
ConditionalExpression conditionalExpression = this.ast.newConditionalExpression();
conditionalExpression.setExpression(this.ast.newBooleanLiteral(true));
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newSimpleName("args"), //$NON-NLS-1$
this.ast.newSimpleName("length")); //$NON-NLS-1$
conditionalExpression.setThenExpression(name);
conditionalExpression.setElseExpression(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(conditionalExpression);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setModifiers(Modifier.NONE);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int i = true ? args.length: 0;", source); //$NON-NLS-1$
}
/**
* MessageSend ==> SuperMethodInvocation
*/
public void test0078() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0078", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
SuperMethodInvocation superMethodInvocation = this.ast.newSuperMethodInvocation();
superMethodInvocation.setName(this.ast.newSimpleName("bar")); //$NON-NLS-1$
ExpressionStatement statement = this.ast.newExpressionStatement(superMethodInvocation);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "super.bar();", source); //$NON-NLS-1$
}
/**
* MessageSend ==> SuperMethodInvocation
*/
public void test0079() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0079", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
SuperMethodInvocation superMethodInvocation = this.ast.newSuperMethodInvocation();
superMethodInvocation.setName(this.ast.newSimpleName("bar")); //$NON-NLS-1$
superMethodInvocation.arguments().add(this.ast.newNumberLiteral("4"));//$NON-NLS-1$
ExpressionStatement statement = this.ast.newExpressionStatement(superMethodInvocation);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "super.bar(4);", source); //$NON-NLS-1$
}
/**
* MessageSend ==> MethodInvocation
*/
public void test0080() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0080", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
MethodInvocation methodInvocation = this.ast.newMethodInvocation();
methodInvocation.setName(this.ast.newSimpleName("bar")); //$NON-NLS-1$
methodInvocation.arguments().add(this.ast.newNumberLiteral("4"));//$NON-NLS-1$
ExpressionStatement statement = this.ast.newExpressionStatement(methodInvocation);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "bar(4);", source); //$NON-NLS-1$
}
/**
* MessageSend ==> MethodInvocation
*/
public void test0081() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0081", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
MethodInvocation methodInvocation = this.ast.newMethodInvocation();
methodInvocation.setName(this.ast.newSimpleName("bar")); //$NON-NLS-1$
methodInvocation.setExpression(this.ast.newThisExpression());
methodInvocation.arguments().add(this.ast.newNumberLiteral("4"));//$NON-NLS-1$
ExpressionStatement statement = this.ast.newExpressionStatement(methodInvocation);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "this.bar(4);", source); //$NON-NLS-1$
}
/**
* ForStatement ==> ForStatement
*/
public void test0082() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0082", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
forStatement.setBody(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (;;);", source); //$NON-NLS-1$
}
/**
* ForStatement ==> ForStatement
* @deprecated using deprecated code
*/
public void test0083() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0083", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setModifiers(Modifier.NONE);
variableDeclarationExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
forStatement.initializers().add(variableDeclarationExpression);
PostfixExpression postfixExpression = this.ast.newPostfixExpression();
postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(postfixExpression);
forStatement.setBody(this.ast.newBlock());
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.LESS);
infixExpression.setRightOperand(this.ast.newNumberLiteral("10")); //$NON-NLS-1$
forStatement.setExpression(infixExpression);
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (int i = 0; i < 10; i++) {}", source); //$NON-NLS-1$
}
/**
* ForStatement ==> ForStatement
* @deprecated using deprecated code
*/
public void test0084() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0084", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setModifiers(Modifier.NONE);
variableDeclarationExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
forStatement.initializers().add(variableDeclarationExpression);
PostfixExpression postfixExpression = this.ast.newPostfixExpression();
postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(postfixExpression);
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.LESS);
infixExpression.setRightOperand(this.ast.newNumberLiteral("10")); //$NON-NLS-1$
forStatement.setExpression(infixExpression);
forStatement.setBody(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (int i = 0; i < 10; i++);", source); //$NON-NLS-1$
}
/**
* ForStatement ==> ForStatement
* @deprecated using deprecated code
*/
public void test0085() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0085", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setModifiers(Modifier.NONE);
variableDeclarationExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
forStatement.initializers().add(variableDeclarationExpression);
PostfixExpression postfixExpression = this.ast.newPostfixExpression();
postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(postfixExpression);
forStatement.setBody(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (int i = 0;; i++);", source); //$NON-NLS-1$
}
/**
* ForStatement ==> ForStatement
*/
public void test0086() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0086", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
PostfixExpression postfixExpression = this.ast.newPostfixExpression();
postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(postfixExpression);
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.LESS);
infixExpression.setRightOperand(this.ast.newNumberLiteral("10")); //$NON-NLS-1$
forStatement.setExpression(infixExpression);
forStatement.setBody(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (; i < 10; i++);", source); //$NON-NLS-1$
}
/**
* ForStatement ==> ForStatement
*/
public void test0087() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0087", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
PostfixExpression postfixExpression = this.ast.newPostfixExpression();
postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(postfixExpression);
forStatement.setBody(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (;;i++);", source); //$NON-NLS-1$
}
/**
* LocalDeclaration ==> VariableDeclarationStatement
* @deprecated using deprecated code
*/
public void test0088() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0088", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
statement.setModifiers(Modifier.NONE);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int i;", source); //$NON-NLS-1$
}
/**
* LocalDeclaration ==> VariableDeclarationStatement
* @deprecated using deprecated code
*/
public void test0089() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0089", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newQualifiedName(
this.ast.newSimpleName("java"),//$NON-NLS-1$
this.ast.newSimpleName("lang")//$NON-NLS-1$
),
this.ast.newSimpleName("String") //$NON-NLS-1$
);
statement.setType(this.ast.newSimpleType(name));
statement.setModifiers(Modifier.NONE);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "java.lang.String s;", source); //$NON-NLS-1$
}
/**
* LocalDeclaration ==> VariableDeclarationStatement
* @deprecated using deprecated code
*/
public void test0090() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0090", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
ArrayInitializer initializer = this.ast.newArrayInitializer();
initializer.expressions().add(this.ast.newNumberLiteral("1"));//$NON-NLS-1$
initializer.expressions().add(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
variableDeclarationFragment.setInitializer(initializer);
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(variableDeclarationFragment);
statement.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
statement.setModifiers(Modifier.NONE);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int[] tab = {1, 2};", source); //$NON-NLS-1$
}
/**
* Argument ==> SingleVariableDeclaration
* @deprecated using deprecated code
*/
public void test0091() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0091", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
MethodDeclaration method = (MethodDeclaration)((TypeDeclaration) ((CompilationUnit) result).types().get(0)).bodyDeclarations().get(0);
SingleVariableDeclaration node = (SingleVariableDeclaration) method.parameters().get(0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
SingleVariableDeclaration variableDeclaration = this.ast.newSingleVariableDeclaration();
variableDeclaration.setModifiers(Modifier.NONE);
variableDeclaration.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
variableDeclaration.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", variableDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "String s", source); //$NON-NLS-1$
}
/**
* Argument ==> SingleVariableDeclaration
* @deprecated using deprecated code
*/
public void test0092() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0092", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
MethodDeclaration method = (MethodDeclaration)((TypeDeclaration) ((CompilationUnit) result).types().get(0)).bodyDeclarations().get(0);
SingleVariableDeclaration node = (SingleVariableDeclaration) method.parameters().get(0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
SingleVariableDeclaration variableDeclaration = this.ast.newSingleVariableDeclaration();
variableDeclaration.setModifiers(Modifier.FINAL);
variableDeclaration.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
variableDeclaration.setName(this.ast.newSimpleName("s")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", variableDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "final String s", source); //$NON-NLS-1$
assertEquals("Wrong dimension", 0, node.getExtraDimensions()); //$NON-NLS-1$
}
/**
* Break ==> BreakStatement
*/
public void test0093() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0093", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
ForStatement forStatement = (ForStatement) node;
BreakStatement statement = (BreakStatement) ((Block) forStatement.getBody()).statements().get(0);
assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
BreakStatement breakStatement = this.ast.newBreakStatement();
assertTrue("Both AST trees should be identical", breakStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
checkSourceRange(statement, "break;", source); //$NON-NLS-1$
}
/**
* Continue ==> ContinueStatement
*/
public void test0094() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0094", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
ForStatement forStatement = (ForStatement) node;
ContinueStatement statement = (ContinueStatement) ((Block) forStatement.getBody()).statements().get(0);
assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
ContinueStatement continueStatement = this.ast.newContinueStatement();
assertTrue("Both AST trees should be identical", continueStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
checkSourceRange(statement, "continue;", source); //$NON-NLS-1$
}
/**
* Continue with Label ==> ContinueStatement
*/
public void test0095() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0095", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
LabeledStatement labeledStatement = (LabeledStatement) getASTNode((CompilationUnit) result, 0, 0, 0);
ForStatement forStatement = (ForStatement) labeledStatement.getBody();
ContinueStatement statement = (ContinueStatement) ((Block) forStatement.getBody()).statements().get(0);
assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
ContinueStatement continueStatement = this.ast.newContinueStatement();
continueStatement.setLabel(this.ast.newSimpleName("label")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", continueStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
checkSourceRange(statement, "continue label;", source); //$NON-NLS-1$
}
/**
* Break + label ==> BreakStatement
*/
public void test0096() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0096", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
LabeledStatement labeledStatement = (LabeledStatement) getASTNode((CompilationUnit) result, 0, 0, 0);
ForStatement forStatement = (ForStatement) labeledStatement.getBody();
BreakStatement statement = (BreakStatement) ((Block) forStatement.getBody()).statements().get(0);
assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
BreakStatement breakStatement = this.ast.newBreakStatement();
breakStatement.setLabel(this.ast.newSimpleName("label")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", breakStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
checkSourceRange(statement, "break label;", source); //$NON-NLS-1$
}
/**
* SwitchStatement ==> SwitchStatement
*/
public void test0097() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0097", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
SwitchStatement switchStatement = this.ast.newSwitchStatement();
switchStatement.setExpression(this.ast.newSimpleName("i"));//$NON-NLS-1$
SwitchCase _case = this.ast.newSwitchCase();
_case.setExpression(this.ast.newNumberLiteral("1"));//$NON-NLS-1$
switchStatement.statements().add(_case);
switchStatement.statements().add(this.ast.newBreakStatement());
_case = this.ast.newSwitchCase();
_case.setExpression(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
switchStatement.statements().add(_case);
MethodInvocation methodInvocation = this.ast.newMethodInvocation();
QualifiedName name =
this.ast.newQualifiedName(
this.ast.newSimpleName("System"),//$NON-NLS-1$
this.ast.newSimpleName("out"));//$NON-NLS-1$
methodInvocation.setExpression(name);
methodInvocation.setName(this.ast.newSimpleName("println")); //$NON-NLS-1$
methodInvocation.arguments().add(this.ast.newNumberLiteral("2"));//$NON-NLS-1$
ExpressionStatement expressionStatement = this.ast.newExpressionStatement(methodInvocation);
switchStatement.statements().add(expressionStatement);
switchStatement.statements().add(this.ast.newBreakStatement());
_case = this.ast.newSwitchCase();
_case.setExpression(null);
switchStatement.statements().add(_case);
methodInvocation = this.ast.newMethodInvocation();
name =
this.ast.newQualifiedName(
this.ast.newSimpleName("System"),//$NON-NLS-1$
this.ast.newSimpleName("out"));//$NON-NLS-1$
methodInvocation.setExpression(name);
methodInvocation.setName(this.ast.newSimpleName("println")); //$NON-NLS-1$
StringLiteral literal = this.ast.newStringLiteral();
literal.setLiteralValue("default"); //$NON-NLS-1$
methodInvocation.arguments().add(literal);
expressionStatement = this.ast.newExpressionStatement(methodInvocation);
switchStatement.statements().add(expressionStatement);
assertTrue("Both AST trees should be identical", switchStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "switch(i) {\n" +//$NON-NLS-1$
" case 1: \n" +//$NON-NLS-1$
" break;\n" +//$NON-NLS-1$
" case 2:\n" +//$NON-NLS-1$
" System.out.println(2);\n" +//$NON-NLS-1$
" break;\n" +//$NON-NLS-1$
" default:\n" +//$NON-NLS-1$
" System.out.println(\"default\");\n" +//$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
SwitchStatement switchStatement2 = (SwitchStatement) node;
List statements = switchStatement2.statements();
assertEquals("wrong size", 7, statements.size()); //$NON-NLS-1$
Statement stmt = (Statement) statements.get(5);
assertTrue("Not a case statement", stmt instanceof SwitchCase); //$NON-NLS-1$
SwitchCase switchCase = (SwitchCase) stmt;
assertTrue("Not the default case", switchCase.isDefault()); //$NON-NLS-1$
}
/**
* EmptyStatement ==> EmptyStatement
*/
public void test0098() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0098", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
EmptyStatement emptyStatement = this.ast.newEmptyStatement();
assertTrue("Both AST trees should be identical", emptyStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, ";", source); //$NON-NLS-1$
}
/**
* DoStatement ==> DoStatement
*/
public void test0099() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0099", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
DoStatement doStatement = this.ast.newDoStatement();
Block block = this.ast.newBlock();
block.statements().add(this.ast.newEmptyStatement());
doStatement.setBody(block);
doStatement.setExpression(this.ast.newBooleanLiteral(true));
assertTrue("Both AST trees should be identical", doStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "do {;\n" +//$NON-NLS-1$
" } while(true);";//$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* WhileStatement ==> WhileStatement
*/
public void test0100() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0100", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
WhileStatement whileStatement = this.ast.newWhileStatement();
whileStatement.setExpression(this.ast.newBooleanLiteral(true));
whileStatement.setBody(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", whileStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "while(true);", source);//$NON-NLS-1$
}
/**
* WhileStatement ==> WhileStatement
*/
public void test0101() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0101", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
WhileStatement whileStatement = this.ast.newWhileStatement();
whileStatement.setExpression(this.ast.newBooleanLiteral(true));
whileStatement.setBody(this.ast.newBlock());
assertTrue("Both AST trees should be identical", whileStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "while(true) {}", source);//$NON-NLS-1$
}
/**
* ExtendedStringLiteral ==> StringLiteral
*/
public void test0102() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0102", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.PLUS);
StringLiteral literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue("Hello"); //$NON-NLS-1$
infixExpression.setLeftOperand(literal);
literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue(" World"); //$NON-NLS-1$
infixExpression.setRightOperand(literal);
literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue("!"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "\"Hello\" + \" World\" + \"!\"", source);//$NON-NLS-1$
}
/**
* ExtendedStringLiteral ==> StringLiteral
*/
public void test0103() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0103", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.PLUS);
StringLiteral literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue("Hello"); //$NON-NLS-1$
infixExpression.setLeftOperand(literal);
literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue(" World"); //$NON-NLS-1$
infixExpression.setRightOperand(literal);
literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue("!"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue("!"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "\"Hello\" + \" World\" + \"!\" + \"!\"", source);//$NON-NLS-1$
}
/**
* ExtendedStringLiteral ==> StringLiteral
*/
public void test0104() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0104", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.PLUS);
StringLiteral literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue("Hello"); //$NON-NLS-1$
infixExpression.setLeftOperand(literal);
literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue(" World"); //$NON-NLS-1$
infixExpression.setRightOperand(literal);
literal = this.ast.newStringLiteral();//$NON-NLS-1$
literal.setLiteralValue("!"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
NumberLiteral numberLiteral = this.ast.newNumberLiteral();//$NON-NLS-1$
numberLiteral.setToken("4"); //$NON-NLS-1$
infixExpression.extendedOperands().add(numberLiteral);
assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "\"Hello\" + \" World\" + \"!\" + 4", source);//$NON-NLS-1$
}
/**
* NumberLiteral ==> InfixExpression
*/
public void test0105() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0105", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.PLUS);
NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("4"); //$NON-NLS-1$
infixExpression.setLeftOperand(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("5"); //$NON-NLS-1$
infixExpression.setRightOperand(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("6"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("4"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "4 + 5 + 6 + 4", source);//$NON-NLS-1$
}
/**
* NumberLiteral ==> InfixExpression
*/
public void test0106() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0106", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.MINUS);
NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("4"); //$NON-NLS-1$
infixExpression.setLeftOperand(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("5"); //$NON-NLS-1$
infixExpression.setRightOperand(literal);
InfixExpression infixExpression2 = this.ast.newInfixExpression();
infixExpression2.setOperator(InfixExpression.Operator.PLUS);
infixExpression2.setLeftOperand(infixExpression);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("6"); //$NON-NLS-1$
infixExpression2.setRightOperand(literal);
InfixExpression infixExpression3 = this.ast.newInfixExpression();
infixExpression3.setOperator(InfixExpression.Operator.PLUS);
infixExpression3.setLeftOperand(infixExpression2);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("4"); //$NON-NLS-1$
infixExpression3.setRightOperand(literal);
assertTrue("Both AST trees should be identical", infixExpression3.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "4 - 5 + 6 + 4", source);//$NON-NLS-1$
}
/**
* NumberLiteral ==> InfixExpression
*/
public void test0107() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0107", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.MINUS);
NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("4"); //$NON-NLS-1$
infixExpression.setLeftOperand(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("5"); //$NON-NLS-1$
infixExpression.setRightOperand(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("6"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("4"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "4 - 5 - 6 - 4", source);//$NON-NLS-1$
}
/**
* NumberLiteral ==> InfixExpression
*/
public void test0108() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0108", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.PLUS);
StringLiteral stringLiteral = this.ast.newStringLiteral();//$NON-NLS-1$
stringLiteral.setLiteralValue("4"); //$NON-NLS-1$
infixExpression.setLeftOperand(stringLiteral);
NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("5"); //$NON-NLS-1$
infixExpression.setRightOperand(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("6"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("4"); //$NON-NLS-1$
infixExpression.extendedOperands().add(literal);
assertTrue("Both AST trees should be identical", infixExpression.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "\"4\" + 5 + 6 + 4", source);//$NON-NLS-1$
}
/**
* NumberLiteral ==> InfixExpression
*/
public void test0109() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0109", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setOperator(InfixExpression.Operator.MINUS);
StringLiteral stringLiteral = this.ast.newStringLiteral();//$NON-NLS-1$
stringLiteral.setLiteralValue("4"); //$NON-NLS-1$
infixExpression.setLeftOperand(stringLiteral);
NumberLiteral literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("5"); //$NON-NLS-1$
infixExpression.setRightOperand(literal);
InfixExpression infixExpression2 = this.ast.newInfixExpression();
infixExpression2.setOperator(InfixExpression.Operator.PLUS);
infixExpression2.setLeftOperand(infixExpression);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("6"); //$NON-NLS-1$
infixExpression2.setRightOperand(literal);
InfixExpression infixExpression3 = this.ast.newInfixExpression();
infixExpression3.setOperator(InfixExpression.Operator.PLUS);
infixExpression3.setLeftOperand(infixExpression2);
literal = this.ast.newNumberLiteral();//$NON-NLS-1$
literal.setToken("4"); //$NON-NLS-1$
infixExpression3.setRightOperand(literal);
assertTrue("Both AST trees should be identical", infixExpression3.subtreeMatch(new ASTMatcher(), expression)); //$NON-NLS-1$
checkSourceRange(expression, "\"4\" - 5 + 6 + 4", source);//$NON-NLS-1$
}
/**
* ReturnStatement ==> ReturnStatement
*/
public void test0110() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0110", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ReturnStatement returnStatement = this.ast.newReturnStatement();
NumberLiteral literal = this.ast.newNumberLiteral();
literal.setToken("2");//$NON-NLS-1$
returnStatement.setExpression(literal);
assertTrue("Both AST trees should be identical", returnStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "return 2;", source);//$NON-NLS-1$
}
/**
* ReturnStatement ==> ReturnStatement
*/
public void test0111() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0111", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ReturnStatement returnStatement = this.ast.newReturnStatement();
NumberLiteral literal = this.ast.newNumberLiteral();
literal.setToken("2");//$NON-NLS-1$
returnStatement.setExpression(literal);
assertTrue("Both AST trees should be identical", returnStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "return 2\\u003B", source);//$NON-NLS-1$
}
/**
* SynchronizedStatement ==> SynchronizedStatement
*/
public void test0112() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0112", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
SynchronizedStatement synchronizedStatement = this.ast.newSynchronizedStatement();
synchronizedStatement.setExpression(this.ast.newThisExpression());
synchronizedStatement.setBody(this.ast.newBlock());
assertTrue("Both AST trees should be identical", synchronizedStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "synchronized(this) {\n" +//$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* TryStatement ==> TryStatement
* @deprecated using deprecated code
*/
public void test0113() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0113", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
TryStatement tryStatement = this.ast.newTryStatement();
tryStatement.setBody(this.ast.newBlock());
tryStatement.setFinally(this.ast.newBlock());
CatchClause catchBlock = this.ast.newCatchClause();
catchBlock.setBody(this.ast.newBlock());
SingleVariableDeclaration exceptionVariable = this.ast.newSingleVariableDeclaration();
exceptionVariable.setModifiers(Modifier.NONE);
exceptionVariable.setName(this.ast.newSimpleName("e"));//$NON-NLS-1$
exceptionVariable.setType(this.ast.newSimpleType(this.ast.newSimpleName("Exception")));//$NON-NLS-1$
catchBlock.setException(exceptionVariable);
tryStatement.catchClauses().add(catchBlock);
assertTrue("Both AST trees should be identical", tryStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "try {\n" +//$NON-NLS-1$
" } catch(Exception e) {\n" +//$NON-NLS-1$
" } finally {\n" +//$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* TryStatement ==> TryStatement
* @deprecated using deprecated code
*/
public void test0114() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0114", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
TryStatement tryStatement = this.ast.newTryStatement();
tryStatement.setBody(this.ast.newBlock());
CatchClause catchBlock = this.ast.newCatchClause();
catchBlock.setBody(this.ast.newBlock());
SingleVariableDeclaration exceptionVariable = this.ast.newSingleVariableDeclaration();
exceptionVariable.setModifiers(Modifier.NONE);
exceptionVariable.setName(this.ast.newSimpleName("e"));//$NON-NLS-1$
exceptionVariable.setType(this.ast.newSimpleType(this.ast.newSimpleName("Exception")));//$NON-NLS-1$
catchBlock.setException(exceptionVariable);
tryStatement.catchClauses().add(catchBlock);
assertTrue("Both AST trees should be identical", tryStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "try {\n" +//$NON-NLS-1$
" } catch(Exception e) {\n" +//$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* TryStatement ==> TryStatement
* @deprecated using deprecated code
*/
public void test0115() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0115", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
TryStatement tryStatement = this.ast.newTryStatement();
Block block = this.ast.newBlock();
ReturnStatement returnStatement = this.ast.newReturnStatement();
NumberLiteral literal = this.ast.newNumberLiteral();
literal.setToken("2");//$NON-NLS-1$
returnStatement.setExpression(literal);
block.statements().add(returnStatement);
tryStatement.setBody(block);
CatchClause catchBlock = this.ast.newCatchClause();
catchBlock.setBody(this.ast.newBlock());
SingleVariableDeclaration exceptionVariable = this.ast.newSingleVariableDeclaration();
exceptionVariable.setModifiers(Modifier.NONE);
exceptionVariable.setName(this.ast.newSimpleName("e"));//$NON-NLS-1$
exceptionVariable.setType(this.ast.newSimpleType(this.ast.newSimpleName("Exception")));//$NON-NLS-1$
catchBlock.setException(exceptionVariable);
tryStatement.catchClauses().add(catchBlock);
assertTrue("Both AST trees should be identical", tryStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "try {\n" +//$NON-NLS-1$
" return 2;\n" +//$NON-NLS-1$
" } catch(Exception e) {\n" +//$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* ThrowStatement ==> ThrowStatement
*/
public void test0116() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0116", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ThrowStatement throwStatement = this.ast.newThrowStatement();
throwStatement.setExpression(this.ast.newSimpleName("e")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", throwStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "throw e \\u003B", source);//$NON-NLS-1$
}
/**
* ThrowStatement ==> ThrowStatement
*/
public void test0117() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0117", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ThrowStatement throwStatement = this.ast.newThrowStatement();
throwStatement.setExpression(this.ast.newSimpleName("e")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", throwStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "throw e /* comment in the middle of a throw */ \\u003B", source);//$NON-NLS-1$
}
/**
* ThrowStatement ==> ThrowStatement
*/
public void test0118() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0118", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ThrowStatement throwStatement = this.ast.newThrowStatement();
throwStatement.setExpression(this.ast.newSimpleName("e")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", throwStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "throw e /* comment in the middle of a throw */ \\u003B", source);//$NON-NLS-1$
}
/**
* IfStatement ==> IfStatement
*/
public void test0119() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0119", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
IfStatement ifStatement = this.ast.newIfStatement();
ifStatement.setExpression(this.ast.newBooleanLiteral(true));
ifStatement.setThenStatement(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "if (true)\\u003B", source);//$NON-NLS-1$
}
/**
* IfStatement ==> IfStatement
*/
public void test0120() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0120", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
IfStatement ifStatement = this.ast.newIfStatement();
ifStatement.setExpression(this.ast.newBooleanLiteral(true));
ifStatement.setThenStatement(this.ast.newEmptyStatement());
ifStatement.setElseStatement(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "if (true)\\u003B\n" +//$NON-NLS-1$
"\t\telse ;"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* IfStatement ==> IfStatement
*/
public void test0121() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0121", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
IfStatement ifStatement = this.ast.newIfStatement();
ifStatement.setExpression(this.ast.newBooleanLiteral(true));
ifStatement.setThenStatement(this.ast.newBlock());
ifStatement.setElseStatement(this.ast.newEmptyStatement());
assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "if (true) {}\n" +//$NON-NLS-1$
" else ;"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* IfStatement ==> IfStatement
*/
public void test0122() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0122", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
IfStatement ifStatement = this.ast.newIfStatement();
ifStatement.setExpression(this.ast.newBooleanLiteral(true));
ReturnStatement returnStatement = this.ast.newReturnStatement();
NumberLiteral literal = this.ast.newNumberLiteral();
literal.setToken("2");//$NON-NLS-1$
returnStatement.setExpression(literal);
ifStatement.setThenStatement(returnStatement);
assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "if (true) return 2\\u003B", source);//$NON-NLS-1$
}
/**
* IfStatement ==> IfStatement
*/
public void test0123() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0123", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
IfStatement ifStatement = this.ast.newIfStatement();
ifStatement.setExpression(this.ast.newBooleanLiteral(true));
ReturnStatement returnStatement = this.ast.newReturnStatement();
NumberLiteral literal = this.ast.newNumberLiteral();
literal.setToken("2");//$NON-NLS-1$
returnStatement.setExpression(literal);
ifStatement.setThenStatement(returnStatement);
returnStatement = this.ast.newReturnStatement();
literal = this.ast.newNumberLiteral();
literal.setToken("3");//$NON-NLS-1$
returnStatement.setExpression(literal);
ifStatement.setElseStatement(returnStatement);
assertTrue("Both AST trees should be identical", ifStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "if (true) return 2;\n" +//$NON-NLS-1$
" else return 3;"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* Multiple local declaration => VariabledeclarationStatement
* @deprecated using deprecated code
*/
public void test0124() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0124", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("x"));//$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral();
literal.setToken("10");//$NON-NLS-1$
fragment.setInitializer(literal);
fragment.setExtraDimensions(0);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
fragment.setInitializer(this.ast.newNullLiteral());
fragment.setExtraDimensions(1);
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
fragment.setExtraDimensions(0);
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
fragment.setExtraDimensions(2);
statement.fragments().add(fragment);
statement.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
statement.setModifiers(Modifier.NONE);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
VariableDeclarationFragment[] fragments = (VariableDeclarationFragment[])((VariableDeclarationStatement) node).fragments().toArray(new VariableDeclarationFragment[4]);
assertTrue("fragments.length != 4", fragments.length == 4); //$NON-NLS-1$
checkSourceRange(fragments[0], "x= 10", source);//$NON-NLS-1$
checkSourceRange(fragments[1], "z[] = null", source);//$NON-NLS-1$
checkSourceRange(fragments[2], "i", source);//$NON-NLS-1$
checkSourceRange(fragments[3], "j[][]", source);//$NON-NLS-1$
checkSourceRange(node, "int x= 10, z[] = null, i, j[][];", source);//$NON-NLS-1$
}
/**
* Multiple local declaration => VariabledeclarationStatement
* @deprecated using deprecated code
*/
public void test0125() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0125", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
VariableDeclarationFragment fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("x"));//$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral();
literal.setToken("10");//$NON-NLS-1$
fragment.setInitializer(literal);
fragment.setExtraDimensions(0);
VariableDeclarationStatement statement = this.ast.newVariableDeclarationStatement(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("z"));//$NON-NLS-1$
fragment.setInitializer(this.ast.newNullLiteral());
fragment.setExtraDimensions(1);
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
fragment.setExtraDimensions(0);
statement.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
fragment.setExtraDimensions(2);
statement.fragments().add(fragment);
statement.setType(this.ast.newArrayType(this.ast.newPrimitiveType(PrimitiveType.INT), 1));
statement.setModifiers(Modifier.NONE);
assertTrue("Both AST trees should be identical", statement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int[] x= 10, z[] = null, i, j[][];", source); //$NON-NLS-1$
VariableDeclarationFragment[] fragments = (VariableDeclarationFragment[])((VariableDeclarationStatement) node).fragments().toArray(new VariableDeclarationFragment[4]);
assertTrue("fragments.length != 4", fragments.length == 4); //$NON-NLS-1$
checkSourceRange(fragments[0], "x= 10", source);//$NON-NLS-1$
checkSourceRange(fragments[1], "z[] = null", source);//$NON-NLS-1$
checkSourceRange(fragments[2], "i", source);//$NON-NLS-1$
checkSourceRange(fragments[3], "j[][]", source);//$NON-NLS-1$
}
/**
* ForStatement
* @deprecated using deprecated code
*/
public void test0126() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0126", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
variableDeclarationFragment.setExtraDimensions(1);
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setModifiers(Modifier.NONE);
variableDeclarationExpression.setType(this.ast.newArrayType(this.ast.newSimpleType(this.ast.newSimpleName("String")), 1));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT);
forStatement.updaters().add(prefixExpression);
forStatement.setBody(this.ast.newBlock());
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (String[] tab[] = null;; ++i) {}", source); //$NON-NLS-1$
checkSourceRange((ASTNode) ((ForStatement) node).updaters().get(0), "++i", source); //$NON-NLS-1$
checkSourceRange((ASTNode) ((ForStatement) node).initializers().get(0), "String[] tab[] = null", source); //$NON-NLS-1$
}
/**
* ForStatement
* @deprecated using deprecated code
*/
public void test0127() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0127", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
variableDeclarationFragment.setExtraDimensions(1);
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setModifiers(Modifier.NONE);
variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
PrefixExpression prefixExpression = this.ast.newPrefixExpression();
prefixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
prefixExpression.setOperator(PrefixExpression.Operator.INCREMENT);
forStatement.updaters().add(prefixExpression);
forStatement.setBody(this.ast.newBlock());
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (String tab[] = null;; ++i) {}", source); //$NON-NLS-1$
checkSourceRange((ASTNode) ((ForStatement) node).updaters().get(0), "++i", source); //$NON-NLS-1$
checkSourceRange((ASTNode) ((ForStatement) node).initializers().get(0), "String tab[] = null", source); //$NON-NLS-1$
}
/**
* ForStatement
* @deprecated using deprecated code
*/
public void test0128() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0128", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
variableDeclarationFragment.setName(this.ast.newSimpleName("tab")); //$NON-NLS-1$
variableDeclarationFragment.setInitializer(this.ast.newNullLiteral());//$NON-NLS-1$
variableDeclarationFragment.setExtraDimensions(1);
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
variableDeclarationExpression.setModifiers(Modifier.NONE);
variableDeclarationExpression.setType(this.ast.newSimpleType(this.ast.newSimpleName("String")));//$NON-NLS-1$
forStatement.initializers().add(variableDeclarationExpression);
PostfixExpression postfixExpression = this.ast.newPostfixExpression();
postfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(postfixExpression);
forStatement.setBody(this.ast.newBlock());
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (String tab[] = null;; i++/**/) {}", source); //$NON-NLS-1$
checkSourceRange((ASTNode) ((ForStatement) node).updaters().get(0), "i++", source); //$NON-NLS-1$
checkSourceRange((ASTNode) ((ForStatement) node).initializers().get(0), "String tab[] = null", source); //$NON-NLS-1$
}
/**
* FieldDeclaration
* @deprecated using deprecated code
*/
public void test0129() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0129", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
VariableDeclarationFragment frag = (VariableDeclarationFragment) ((FieldDeclaration) node).fragments().get(0);
assertTrue("Not a declaration", frag.getName().isDeclaration()); //$NON-NLS-1$
VariableDeclarationFragment fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
fragment.setExtraDimensions(0);
FieldDeclaration fieldDeclaration = this.ast.newFieldDeclaration(fragment);
fieldDeclaration.setModifiers(Modifier.NONE);
fieldDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", fieldDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "int i;", source); //$NON-NLS-1$
}
/**
* FieldDeclaration
* @deprecated using deprecated code
*/
public void test0130() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0130", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
VariableDeclarationFragment fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("x")); //$NON-NLS-1$
NumberLiteral literal = this.ast.newNumberLiteral();
literal.setToken("10"); //$NON-NLS-1$
fragment.setInitializer(literal);
fragment.setExtraDimensions(0);
FieldDeclaration fieldDeclaration = this.ast.newFieldDeclaration(fragment);
fieldDeclaration.setModifiers(Modifier.PUBLIC);
fieldDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("y"));//$NON-NLS-1$
fragment.setExtraDimensions(1);
fragment.setInitializer(this.ast.newNullLiteral());
fieldDeclaration.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("i"));//$NON-NLS-1$
fragment.setExtraDimensions(0);
fieldDeclaration.fragments().add(fragment);
fragment = this.ast.newVariableDeclarationFragment();
fragment.setName(this.ast.newSimpleName("j"));//$NON-NLS-1$
fragment.setExtraDimensions(2);
fieldDeclaration.fragments().add(fragment);
assertTrue("Both AST trees should be identical", fieldDeclaration.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "public int x= 10, y[] = null, i, j[][];", source); //$NON-NLS-1$
VariableDeclarationFragment[] fragments = (VariableDeclarationFragment[])((FieldDeclaration) node).fragments().toArray(new VariableDeclarationFragment[4]);
assertTrue("fragments.length != 4", fragments.length == 4); //$NON-NLS-1$
checkSourceRange(fragments[0], "x= 10", source);//$NON-NLS-1$
checkSourceRange(fragments[1], "y[] = null", source);//$NON-NLS-1$
checkSourceRange(fragments[2], "i", source);//$NON-NLS-1$
checkSourceRange(fragments[3], "j[][]", source);//$NON-NLS-1$
}
/**
* Argument with final modifier
* @deprecated using deprecated code
*/
public void test0131() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0131", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
assertTrue("Not a declaration", ((MethodDeclaration) node).getName().isDeclaration()); //$NON-NLS-1$
List parameters = ((MethodDeclaration) node).parameters();
assertTrue("Parameters.length != 1", parameters.size() == 1); //$NON-NLS-1$
SingleVariableDeclaration arg = (SingleVariableDeclaration) ((MethodDeclaration) node).parameters().get(0);
SingleVariableDeclaration singleVariableDeclaration = this.ast.newSingleVariableDeclaration();
singleVariableDeclaration.setModifiers(Modifier.FINAL);
singleVariableDeclaration.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
singleVariableDeclaration.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
assertTrue("Both AST trees should be identical", singleVariableDeclaration.subtreeMatch(new ASTMatcher(), arg)); //$NON-NLS-1$
checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
checkSourceRange(arg, "final int i", source); //$NON-NLS-1$
}
/**
* Check javadoc for MethodDeclaration
* @deprecated marking deprecated since using deprecated code
*/
public void test0132() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0132", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
checkSourceRange(node, "/** JavaDoc Comment*/\n void foo(final int i) {}", source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Check javadoc for MethodDeclaration
*/
public void test0133() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0133", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
}
/**
* Check javadoc for MethodDeclaration
*/
public void test0134() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0134", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
}
/**
* Check javadoc for FieldDeclaration
* @deprecated marking deprecated since using deprecated code
*/
public void test0135() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0135", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
checkSourceRange(node, "/** JavaDoc Comment*/\n int i;", source); //$NON-NLS-1$
}
/**
* Check javadoc for FieldDeclaration
*/
public void test0136() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0136", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "int i;", source); //$NON-NLS-1$
}
/**
* Check javadoc for FieldDeclaration
*/
public void test0137() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0137", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "int i;", source); //$NON-NLS-1$
}
/**
* Check javadoc for TypeDeclaration
*/
public void test0138() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0138", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
String expectedContents = "public class Test {\n" +//$NON-NLS-1$
" int i;\n" +//$NON-NLS-1$
"}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
}
/**
* Check javadoc for TypeDeclaration
*/
public void test0139() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0139", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
String expectedContents = "public class Test {\n" +//$NON-NLS-1$
" int i;\n" +//$NON-NLS-1$
"}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
}
/**
* Check javadoc for TypeDeclaration
* @deprecated marking deprecated since using deprecated code
*/
public void test0140() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0140", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
String expectedContents =
"/** JavaDoc Comment*/\n" + //$NON-NLS-1$
"public class Test {\n" +//$NON-NLS-1$
" int i;\n" +//$NON-NLS-1$
"}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Check javadoc for MemberTypeDeclaration
* @deprecated marking deprecated since using deprecated code
*/
public void test0141() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0141", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
String expectedContents =
"/** JavaDoc Comment*/\n" + //$NON-NLS-1$
" class B {}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Check javadoc for MemberTypeDeclaration
*/
public void test0142() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0142", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "class B {}", source); //$NON-NLS-1$
}
/**
* Check javadoc for MemberTypeDeclaration
*/
public void test0143() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0143", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "public static class B {}", source); //$NON-NLS-1$
}
/**
* Check javadoc for MemberTypeDeclaration
*/
public void test0144() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0144", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "public static class B {}", source); //$NON-NLS-1$
}
/**
* Checking initializers
*/
public void test0145() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0145", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
checkSourceRange(node, "{}", source); //$NON-NLS-1$
}
/**
* Checking initializers
*/
public void test0146() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0146", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
checkSourceRange(node, "static {}", source); //$NON-NLS-1$
}
/**
* Checking initializers
* @deprecated marking deprecated since using deprecated code
*/
public void test0147() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0147", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
assertNotNull("Javadoc comment should no be null", actualJavadoc); //$NON-NLS-1$
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
String expectedContents =
"/** JavaDoc Comment*/\n" + //$NON-NLS-1$
" static {}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Checking initializers
* @deprecated marking deprecated since using deprecated code
*/
public void test0148() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0148", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
assertNotNull("Javadoc comment should not be null", actualJavadoc); //$NON-NLS-1$
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
String expectedContents =
"/** JavaDoc Comment*/\n" + //$NON-NLS-1$
" {}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Checking initializers
*/
public void test0149() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0149", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
assertNull("Javadoc comment should be null", actualJavadoc); //$NON-NLS-1$
checkSourceRange(node, "{}", source); //$NON-NLS-1$
}
/**
* Checking syntax error
*/
public void test0150() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0150", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, false);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertTrue("The compilation unit is malformed", !isMalformed(unit)); //$NON-NLS-1$
assertTrue("The package declaration is not malformed", isMalformed(unit.getPackage())); //$NON-NLS-1$
List imports = unit.imports();
assertTrue("The imports list size is not one", imports.size() == 1); //$NON-NLS-1$
assertTrue("The first import is malformed", !isMalformed((ASTNode) imports.get(0))); //$NON-NLS-1$
}
/**
* Checking syntax error
*/
public void test0151() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0151", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, false);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The compilation unit is malformed", !isMalformed(result)); //$NON-NLS-1$
}
/**
* Checking syntax error
*/
public void test0152() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0152", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, false);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The compilation unit is malformed", !isMalformed(result)); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The type is malformed", !isMalformed(node)); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The field is not malformed", isMalformed(node)); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The method is not malformed", isMalformed(node)); //$NON-NLS-1$
}
/**
* Checking syntax error
*/
public void test0153() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0153", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, false);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The compilation unit is malformed", !isMalformed(result)); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The method is not original", isOriginal(node)); //$NON-NLS-1$
assertTrue("The method is not malformed", isMalformed(node)); //$NON-NLS-1$
}
/**
* Checking binding of package declaration
*/
public void test0154() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0154", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
IBinding binding = compilationUnit.getPackage().getName().resolveBinding();
assertNotNull("The package binding is null", binding); //$NON-NLS-1$
assertTrue("The binding is not a package binding", binding instanceof IPackageBinding); //$NON-NLS-1$
IPackageBinding packageBinding = (IPackageBinding) binding;
assertEquals("The package name is incorrect", "test0154", packageBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding2 = compilationUnit.getPackage().getName().resolveBinding();
assertTrue("The package binding is not canonical", binding == binding2); //$NON-NLS-1$
}
/**
* Checking arguments positions
*/
public void test0155() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0155", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("The result is not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDecl = (MethodDeclaration) node;
List parameters = methodDecl.parameters();
assertTrue("The parameters size is different from 2", parameters.size() == 2); //$NON-NLS-1$
Object parameter = parameters.get(0);
assertTrue("The parameter is not a SingleVariableDeclaration", parameter instanceof SingleVariableDeclaration); //$NON-NLS-1$
checkSourceRange((ASTNode) parameter, "int i", source); //$NON-NLS-1$
parameter = parameters.get(1);
assertTrue("The parameter is not a SingleVariableDeclaration", parameter instanceof SingleVariableDeclaration); //$NON-NLS-1$
checkSourceRange((ASTNode) parameter, "final boolean b", source); //$NON-NLS-1$
}
/**
* Checking arguments positions
*/
public void test0156() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0156", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("The result is not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDecl = (MethodDeclaration) node;
List parameters = methodDecl.parameters();
assertTrue("The parameters size is different from 1", parameters.size() == 1); //$NON-NLS-1$
Object parameter = parameters.get(0);
assertTrue("The parameter is not a SingleVariableDeclaration", parameter instanceof SingleVariableDeclaration); //$NON-NLS-1$
checkSourceRange((ASTNode) parameter, "int i", source); //$NON-NLS-1$
Block block = methodDecl.getBody();
List statements = block.statements();
assertTrue("The statements size is different from 2", statements.size() == 2); //$NON-NLS-1$
ASTNode statement = (ASTNode) statements.get(0);
assertTrue("The statements[0] is a postfixExpression statement", statement instanceof ExpressionStatement); //$NON-NLS-1$
}
/**
* Check canonic binding for fields
*/
public void test0157() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "", "Test0157.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Type binding is null", typeBinding); //$NON-NLS-1$
assertTrue("The type binding is canonical", typeBinding == typeDeclaration.resolveBinding()); //$NON-NLS-1$
List bodyDeclarations = typeDeclaration.bodyDeclarations();
assertTrue("The body declaration list is empty", bodyDeclarations.size() != 0); //$NON-NLS-1$
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
assertTrue("This is not a field", bodyDeclaration instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) bodyDeclaration;
List variableFragments = fieldDeclaration.fragments();
assertTrue("The fragment list is empty", variableFragments.size() != 0); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableFragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
assertNotNull("the field binding is null", variableBinding); //$NON-NLS-1$
assertTrue("The field binding is not canonical", variableBinding == fragment.resolveBinding()); //$NON-NLS-1$
typeBinding = variableBinding.getType();
assertTrue("The type is not an array type", typeBinding.isArray()); //$NON-NLS-1$
assertTrue("The type binding for the field is not canonical", typeBinding == variableBinding.getType()); //$NON-NLS-1$
SimpleName name = fragment.getName();
assertTrue("is a declaration", name.isDeclaration()); //$NON-NLS-1$
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("wrong type", IBinding.VARIABLE, binding.getKind()); //$NON-NLS-1$
assertTrue("not a field", ((IVariableBinding) binding).isField()); //$NON-NLS-1$
}
/**
* Check canonic bindings for fields
*/
public void test0158() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "", "Test0158.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Type binding is null", typeBinding); //$NON-NLS-1$
assertTrue("The type binding is canonical", typeBinding == typeDeclaration.resolveBinding()); //$NON-NLS-1$
SimpleName simpleName = typeDeclaration.getName();
assertTrue("is a declaration", simpleName.isDeclaration()); //$NON-NLS-1$
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertEquals("wrong name", simpleName.getIdentifier(), binding.getName()); //$NON-NLS-1$
List bodyDeclarations = typeDeclaration.bodyDeclarations();
assertTrue("The body declaration list is empty", bodyDeclarations.size() != 0); //$NON-NLS-1$
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
assertTrue("This is not a field", bodyDeclaration instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) bodyDeclaration;
List variableFragments = fieldDeclaration.fragments();
assertTrue("The fragment list is empty", variableFragments.size() != 0); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableFragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
assertNotNull("the field binding is null", variableBinding); //$NON-NLS-1$
assertTrue("The field binding is not canonical", variableBinding == fragment.resolveBinding()); //$NON-NLS-1$
ITypeBinding typeBinding2 = variableBinding.getType();
assertTrue("The type is not an array type", typeBinding2.isArray()); //$NON-NLS-1$
assertTrue("The type binding for the field is not canonical", typeBinding2 == variableBinding.getType()); //$NON-NLS-1$
assertTrue("The type binding for the field is not canonical with the declaration type binding", typeBinding == typeBinding2.getElementType()); //$NON-NLS-1$
}
/**
* Define an anonymous type
*/
public void test0159() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0159", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
}
/**
* Check bindings for multiple field declarations
*/
public void test0160() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0160", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Type binding is null", typeBinding); //$NON-NLS-1$
assertTrue("The type binding is canonical", typeBinding == typeDeclaration.resolveBinding()); //$NON-NLS-1$
List bodyDeclarations = typeDeclaration.bodyDeclarations();
assertTrue("The body declaration list is empty", bodyDeclarations.size() != 0); //$NON-NLS-1$
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
assertTrue("This is not a field", bodyDeclaration instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) bodyDeclaration;
List variableFragments = fieldDeclaration.fragments();
assertTrue("The fragment list size is not 2", variableFragments.size() == 2); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableFragments.get(0);
IVariableBinding variableBinding1 = fragment.resolveBinding();
assertNotNull("the field binding is null", variableBinding1); //$NON-NLS-1$
assertTrue("The field binding is not canonical", variableBinding1 == fragment.resolveBinding()); //$NON-NLS-1$
ITypeBinding type1 = variableBinding1.getType();
assertNotNull("The type is null", type1); //$NON-NLS-1$
assertTrue("The field type is canonical", type1 == variableBinding1.getType()); //$NON-NLS-1$
assertTrue("The type is not an array type",type1.isArray()); //$NON-NLS-1$
assertTrue("The type dimension is 1", type1.getDimensions() == 1); //$NON-NLS-1$
fragment = (VariableDeclarationFragment) variableFragments.get(1);
IVariableBinding variableBinding2 = fragment.resolveBinding();
assertNotNull("the field binding is null", variableBinding2); //$NON-NLS-1$
assertTrue("The field binding is not canonical", variableBinding2 == fragment.resolveBinding()); //$NON-NLS-1$
ITypeBinding type2 = variableBinding2.getType();
type2 = variableBinding2.getType();
assertNotNull("The type is null", type2); //$NON-NLS-1$
assertTrue("The field type is canonical", type2 == variableBinding2.getType()); //$NON-NLS-1$
assertTrue("The type is not an array type",type2.isArray()); //$NON-NLS-1$
assertTrue("The type dimension is 2", type2.getDimensions() == 2); //$NON-NLS-1$
assertTrue("Element type is canonical", type1.getElementType() == type2.getElementType()); //$NON-NLS-1$
assertTrue("type1.id < type2.id", variableBinding1.getVariableId() < variableBinding2.getVariableId()); //$NON-NLS-1$
}
/**
* Check ITypeBinding APIs:
* - getModifiers()
* - getElementType() when it is not an array type
* - getDimensions() when it is not an array type
* - getDeclaringClass()
* - getDeclaringName()
* - getName()
* - isNested()
* - isAnonymous()
* - isLocal()
* - isMember()
* - isArray()
* - getDeclaredMethods() => returns binding for default constructor
* - isPrimitive()
* - isTopLevel()
* - getSuperclass()
*/
public void test0161() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0161", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("The type binding should not be null", typeBinding); //$NON-NLS-1$
assertEquals("The modifier is PUBLIC", Modifier.PUBLIC, typeBinding.getModifiers()); //$NON-NLS-1$
assertNull("There is no element type", typeBinding.getElementType()); //$NON-NLS-1$
assertEquals("There is no dimension", 0, typeBinding.getDimensions()); //$NON-NLS-1$
assertNull("This is not a member type", typeBinding.getDeclaringClass()); //$NON-NLS-1$
IMethodBinding[] methods = typeBinding.getDeclaredMethods();
assertEquals("Contains the default constructor", 1, methods.length); //$NON-NLS-1$
assertEquals("The name is not Test", "Test", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("An anonymous class", !typeBinding.isAnonymous()); //$NON-NLS-1$
assertTrue("A local class", !typeBinding.isLocal()); //$NON-NLS-1$
assertTrue("A nested class", !typeBinding.isNested()); //$NON-NLS-1$
assertTrue("A member class", !typeBinding.isMember()); //$NON-NLS-1$
assertTrue("An array", !typeBinding.isArray()); //$NON-NLS-1$
assertTrue("Not a class", typeBinding.isClass()); //$NON-NLS-1$
assertTrue("An interface", !typeBinding.isInterface()); //$NON-NLS-1$
assertTrue("Not from source", typeBinding.isFromSource()); //$NON-NLS-1$
assertTrue("Is nested", typeBinding.isTopLevel()); //$NON-NLS-1$
assertTrue("A primitive type", !typeBinding.isPrimitive()); //$NON-NLS-1$
ITypeBinding superclass = typeBinding.getSuperclass();
assertNotNull("No superclass", superclass); //$NON-NLS-1$
assertTrue("From source", !superclass.isFromSource()); //$NON-NLS-1$
ITypeBinding supersuperclass = superclass.getSuperclass();
assertNull("No superclass for java.lang.Object", supersuperclass); //$NON-NLS-1$
ITypeBinding[] interfaces = typeBinding.getInterfaces();
assertNotNull("No interfaces", interfaces); //$NON-NLS-1$
assertEquals("More then one super interface", 1, interfaces.length); //$NON-NLS-1$
assertTrue("is not an interface", interfaces[0].isInterface()); //$NON-NLS-1$
assertTrue("From source", !interfaces[0].isFromSource()); //$NON-NLS-1$
assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length); //$NON-NLS-1$
}
/**
* Check ITypeBinding APIs:
* - getModifiers()
* - getElementType() when it is not an array type
* - getDimensions() when it is not an array type
* - getDeclaringClass()
* - getDeclaringName()
* - getName()
* - isNested()
* - isAnonymous()
* - isLocal()
* - isMember()
* - isArray()
* - getDeclaredMethods() => returns binding for default constructor
* - isPrimitive()
* - isTopLevel()
* - getSuperclass()
*/
public void test0162() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0162", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("The type binding should not be null", typeBinding); //$NON-NLS-1$
assertEquals("The modifier is PUBLIC", Modifier.PUBLIC, typeBinding.getModifiers()); //$NON-NLS-1$
assertNull("There is no element type", typeBinding.getElementType()); //$NON-NLS-1$
assertEquals("There is no dimension", 0, typeBinding.getDimensions()); //$NON-NLS-1$
assertNull("This is not a member type", typeBinding.getDeclaringClass()); //$NON-NLS-1$
IMethodBinding[] methods = typeBinding.getDeclaredMethods();
assertEquals("Contains no methos", 0, methods.length); //$NON-NLS-1$
assertEquals("The name is not Test", "Test", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("An anonymous class", !typeBinding.isAnonymous()); //$NON-NLS-1$
assertTrue("A local class", !typeBinding.isLocal()); //$NON-NLS-1$
assertTrue("A nested class", !typeBinding.isNested()); //$NON-NLS-1$
assertTrue("A member class", !typeBinding.isMember()); //$NON-NLS-1$
assertTrue("An array", !typeBinding.isArray()); //$NON-NLS-1$
assertTrue("A class", !typeBinding.isClass()); //$NON-NLS-1$
assertTrue("Not an interface", typeBinding.isInterface()); //$NON-NLS-1$
assertTrue("Not from source", typeBinding.isFromSource()); //$NON-NLS-1$
assertTrue("Is nested", typeBinding.isTopLevel()); //$NON-NLS-1$
assertTrue("A primitive type", !typeBinding.isPrimitive()); //$NON-NLS-1$
ITypeBinding superclass = typeBinding.getSuperclass();
assertNull("No superclass", superclass); //$NON-NLS-1$
assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length); //$NON-NLS-1$
}
/**
* Test binding for anonymous declaration: new java.lang.Object() {}
*/
public void test0163() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0163", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
assertTrue("Not an anonymous type declaration", expression instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation anonymousClass = (ClassInstanceCreation) expression;
ITypeBinding typeBinding = anonymousClass.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertTrue("Not an anonymous class", typeBinding.isAnonymous()); //$NON-NLS-1$
assertEquals("The modifier is not default", Modifier.NONE, typeBinding.getModifiers()); //$NON-NLS-1$
assertNull("There is no element type", typeBinding.getElementType()); //$NON-NLS-1$
assertEquals("There is no dimension", 0, typeBinding.getDimensions()); //$NON-NLS-1$
assertNotNull("This is a member type", typeBinding.getDeclaringClass()); //$NON-NLS-1$
assertEquals("The name is not empty", "", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IMethodBinding[] methods = typeBinding.getDeclaredMethods();
assertEquals("Contains the default constructor", 1, methods.length); //$NON-NLS-1$
assertTrue("Not a local class", typeBinding.isLocal()); //$NON-NLS-1$
assertTrue("Not a nested class", typeBinding.isNested()); //$NON-NLS-1$
assertTrue("A member class", !typeBinding.isMember()); //$NON-NLS-1$
assertTrue("An array", !typeBinding.isArray()); //$NON-NLS-1$
assertTrue("Not a class", typeBinding.isClass()); //$NON-NLS-1$
assertTrue("An interface", !typeBinding.isInterface()); //$NON-NLS-1$
assertTrue("Not from source", typeBinding.isFromSource()); //$NON-NLS-1$
assertTrue("Is a top level", !typeBinding.isTopLevel()); //$NON-NLS-1$
assertTrue("A primitive type", !typeBinding.isPrimitive()); //$NON-NLS-1$
assertEquals("wrong qualified name", "", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding superclass = typeBinding.getSuperclass();
assertNotNull("No superclass", superclass); //$NON-NLS-1$
assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length); //$NON-NLS-1$
}
/**
* Test binding for member type declaration
*/
public void test0164() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0164", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("Not an type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertTrue("An anonymous class", !typeBinding.isAnonymous()); //$NON-NLS-1$
assertEquals("The modifier is not default", Modifier.PRIVATE, typeBinding.getModifiers()); //$NON-NLS-1$
assertNull("There is no element type", typeBinding.getElementType()); //$NON-NLS-1$
assertEquals("There is no dimension", 0, typeBinding.getDimensions()); //$NON-NLS-1$
assertNotNull("This is not a member type", typeBinding.getDeclaringClass()); //$NON-NLS-1$
assertEquals("The name is not 'B'", "B", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IMethodBinding[] methods = typeBinding.getDeclaredMethods();
assertEquals("Contains the default constructor", 1, methods.length); //$NON-NLS-1$
assertTrue("A local class", !typeBinding.isLocal()); //$NON-NLS-1$
assertTrue("Not a nested class", typeBinding.isNested()); //$NON-NLS-1$
assertTrue("Not a member class", typeBinding.isMember()); //$NON-NLS-1$
assertTrue("An array", !typeBinding.isArray()); //$NON-NLS-1$
assertTrue("Not a class", typeBinding.isClass()); //$NON-NLS-1$
assertTrue("An interface", !typeBinding.isInterface()); //$NON-NLS-1$
assertTrue("Not from source", typeBinding.isFromSource()); //$NON-NLS-1$
assertTrue("Is a top level", !typeBinding.isTopLevel()); //$NON-NLS-1$
assertTrue("A primitive type", !typeBinding.isPrimitive()); //$NON-NLS-1$
ITypeBinding superclass = typeBinding.getSuperclass();
assertNotNull("No superclass", superclass); //$NON-NLS-1$
assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length); //$NON-NLS-1$
}
/**
* Test binding for local type declaration
* @deprecated using deprecated code
*/
public void test0165() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0165", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("Not an type declaration", node instanceof TypeDeclarationStatement); //$NON-NLS-1$
TypeDeclarationStatement statement = (TypeDeclarationStatement) node;
TypeDeclaration typeDeclaration = statement.getTypeDeclaration();
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertTrue("An anonymous class", !typeBinding.isAnonymous()); //$NON-NLS-1$
assertEquals("The modifier is not default", Modifier.NONE, typeBinding.getModifiers()); //$NON-NLS-1$
assertNull("There is no element type", typeBinding.getElementType()); //$NON-NLS-1$
assertEquals("There is no dimension", 0, typeBinding.getDimensions()); //$NON-NLS-1$
assertNotNull("This is not a member type", typeBinding.getDeclaringClass()); //$NON-NLS-1$
assertEquals("The name is not 'C'", "C", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IMethodBinding[] methods = typeBinding.getDeclaredMethods();
assertEquals("Contains the default constructor", 1, methods.length); //$NON-NLS-1$
assertTrue("Not a local class", typeBinding.isLocal()); //$NON-NLS-1$
assertTrue("Not a nested class", typeBinding.isNested()); //$NON-NLS-1$
assertTrue("A member class", !typeBinding.isMember()); //$NON-NLS-1$
assertTrue("An array", !typeBinding.isArray()); //$NON-NLS-1$
assertTrue("Not a class", typeBinding.isClass()); //$NON-NLS-1$
assertTrue("An interface", !typeBinding.isInterface()); //$NON-NLS-1$
assertTrue("Not from source", typeBinding.isFromSource()); //$NON-NLS-1$
assertTrue("Is a top level", !typeBinding.isTopLevel()); //$NON-NLS-1$
assertTrue("A primitive type", !typeBinding.isPrimitive()); //$NON-NLS-1$
assertEquals("wrong qualified name", "", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding superclass = typeBinding.getSuperclass();
assertNotNull("No superclass", superclass); //$NON-NLS-1$
assertEquals("Has fields", 0, typeBinding.getDeclaredFields().length); //$NON-NLS-1$
}
/**
* Multiple local declaration => VariabledeclarationStatement
*/
public void test0166() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0166", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertTrue("Fragment list is not 4 ", fragments.size() == 4); //$NON-NLS-1$
VariableDeclarationFragment fragment1 = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding binding1 = fragment1.resolveBinding();
assertNotNull("Binding is null", binding1); //$NON-NLS-1$
assertEquals("wrong name for binding1", "x", binding1.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong modifier for binding1", 0, binding1.getModifiers()); //$NON-NLS-1$
assertTrue("a field", !binding1.isField()); //$NON-NLS-1$
assertNull("declaring class is not null", binding1.getDeclaringClass()); //$NON-NLS-1$
ITypeBinding typeBinding1 = binding1.getType();
assertNotNull("typeBinding1 is null", typeBinding1); //$NON-NLS-1$
assertTrue("typeBinding1 is not a primitive type", typeBinding1.isPrimitive()); //$NON-NLS-1$
assertTrue("typeBinding1 is not canonical", typeBinding1 == binding1.getType()); //$NON-NLS-1$
VariableDeclarationFragment fragment2 = (VariableDeclarationFragment) fragments.get(1);
IVariableBinding binding2 = fragment2.resolveBinding();
assertNotNull("Binding is null", binding2); //$NON-NLS-1$
assertEquals("wrong name for binding2", "z", binding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong modifier for binding2", 0, binding2.getModifiers()); //$NON-NLS-1$
assertTrue("a field", !binding2.isField()); //$NON-NLS-1$
assertNull("declaring class is not null", binding2.getDeclaringClass()); //$NON-NLS-1$
ITypeBinding typeBinding2 = binding2.getType();
assertNotNull("typeBinding2 is null", typeBinding2); //$NON-NLS-1$
assertTrue("typeBinding2 is not an array type", typeBinding2.isArray()); //$NON-NLS-1$
assertTrue("typeBinding2 is not canonical", typeBinding2 == binding2.getType()); //$NON-NLS-1$
assertTrue("primitive type is not canonical", typeBinding1 == typeBinding2.getElementType()); //$NON-NLS-1$
assertEquals("dimension is 1", 1, typeBinding2.getDimensions()); //$NON-NLS-1$
assertEquals("it is not int[]", "int[]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
VariableDeclarationFragment fragment3 = (VariableDeclarationFragment) fragments.get(2);
IVariableBinding binding3 = fragment3.resolveBinding();
assertNotNull("Binding is null", binding3); //$NON-NLS-1$
assertEquals("wrong name for binding3", "i", binding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong modifier for binding3", 0, binding3.getModifiers()); //$NON-NLS-1$
assertTrue("a field", !binding3.isField()); //$NON-NLS-1$
assertNull("declaring class is not null", binding3.getDeclaringClass()); //$NON-NLS-1$
ITypeBinding typeBinding3 = binding3.getType();
assertNotNull("typeBinding3 is null", typeBinding3); //$NON-NLS-1$
assertTrue("typeBinding3 is not an primitive type", typeBinding3.isPrimitive()); //$NON-NLS-1$
assertTrue("typeBinding3 is not canonical", typeBinding3 == binding3.getType()); //$NON-NLS-1$
assertTrue("primitive type is not canonical", typeBinding1 == typeBinding3); //$NON-NLS-1$
assertEquals("dimension is 0", 0, typeBinding3.getDimensions()); //$NON-NLS-1$
assertEquals("it is not the primitive type int", "int", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
VariableDeclarationFragment fragment4 = (VariableDeclarationFragment) fragments.get(3);
IVariableBinding binding4 = fragment4.resolveBinding();
assertNotNull("Binding is null", binding4); //$NON-NLS-1$
assertEquals("wrong name for binding4", "j", binding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong modifier for binding4", 0, binding4.getModifiers()); //$NON-NLS-1$
assertTrue("a field", !binding4.isField()); //$NON-NLS-1$
assertNull("declaring class is not null", binding4.getDeclaringClass()); //$NON-NLS-1$
ITypeBinding typeBinding4 = binding4.getType();
assertNotNull("typeBinding4 is null", typeBinding4); //$NON-NLS-1$
assertTrue("typeBinding4 is not an array type", typeBinding4.isArray()); //$NON-NLS-1$
assertTrue("typeBinding4 is not canonical", typeBinding4 == binding4.getType()); //$NON-NLS-1$
assertTrue("primitive type is not canonical", typeBinding1 == typeBinding4.getElementType()); //$NON-NLS-1$
assertEquals("dimension is 2", 2, typeBinding4.getDimensions()); //$NON-NLS-1$
assertEquals("it is not int[][]", "int[][]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("ids in the wrong order", binding1.getVariableId() < binding2.getVariableId()); //$NON-NLS-1$
assertTrue("ids in the wrong order", binding2.getVariableId() < binding3.getVariableId()); //$NON-NLS-1$
assertTrue("ids in the wrong order", binding3.getVariableId() < binding4.getVariableId()); //$NON-NLS-1$
}
/**
* Check source position for new Test[1+2].length.
*/
public void test0167() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0167", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("Instance of VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertTrue("fragment list size is not 1", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
Expression initialization = fragment.getInitializer();
assertNotNull("No initialization", initialization); //$NON-NLS-1$
assertTrue("Not a FieldAccess", initialization instanceof FieldAccess); //$NON-NLS-1$
checkSourceRange(initialization, "new Test[1+2].length", source); //$NON-NLS-1$
}
/**
* Check package binding: test0168.test
*/
public void test0168() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0168.test1", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Binding not null", typeBinding); //$NON-NLS-1$
IPackageBinding packageBinding = typeBinding.getPackage();
assertNotNull("No package binding", packageBinding); //$NON-NLS-1$
assertEquals("wrong name", "test0168.test1", packageBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
String[] components = packageBinding.getNameComponents();
assertNotNull("no components", components); //$NON-NLS-1$
assertTrue("components size != 2", components.length == 2); //$NON-NLS-1$
assertEquals("wrong component name", "test0168", components[0]); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong component name", "test1", components[1]); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong type", IBinding.PACKAGE, packageBinding.getKind()); //$NON-NLS-1$
assertTrue("Unnamed package", !packageBinding.isUnnamed()); //$NON-NLS-1$
assertTrue("Package binding is not canonical", packageBinding == typeBinding.getPackage()); //$NON-NLS-1$
}
/**
* Check package binding: test0169
*/
public void test0169() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0169", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Binding not null", typeBinding); //$NON-NLS-1$
IPackageBinding packageBinding = typeBinding.getPackage();
assertNotNull("No package binding", packageBinding); //$NON-NLS-1$
assertEquals("wrong name", "test0169", packageBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
String[] components = packageBinding.getNameComponents();
assertNotNull("no components", components); //$NON-NLS-1$
assertTrue("components size != 1", components.length == 1); //$NON-NLS-1$
assertEquals("wrong component name", "test0169", components[0]); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong type", IBinding.PACKAGE, packageBinding.getKind()); //$NON-NLS-1$
assertTrue("Unnamed package", !packageBinding.isUnnamed()); //$NON-NLS-1$
assertTrue("Package binding is not canonical", packageBinding == typeBinding.getPackage()); //$NON-NLS-1$
}
/**
* Check package binding: test0170
*/
public void test0170() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "", "Test0170.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Binding not null", typeBinding); //$NON-NLS-1$
IPackageBinding packageBinding = typeBinding.getPackage();
assertNotNull("No package binding", packageBinding); //$NON-NLS-1$
assertEquals("wrong name", "", packageBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
String[] components = packageBinding.getNameComponents();
assertNotNull("no components", components); //$NON-NLS-1$
assertTrue("components size != 0", components.length == 0); //$NON-NLS-1$
assertEquals("wrong type", IBinding.PACKAGE, packageBinding.getKind()); //$NON-NLS-1$
assertTrue("Not an unnamed package", packageBinding.isUnnamed()); //$NON-NLS-1$
assertTrue("Package binding is not canonical", packageBinding == typeBinding.getPackage()); //$NON-NLS-1$
}
/**
* Check package binding: test0171
*/
public void test0171() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0171", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() == 2); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Binding not null", typeBinding); //$NON-NLS-1$
IPackageBinding packageBinding = typeBinding.getPackage();
assertNotNull("No package binding", packageBinding); //$NON-NLS-1$
assertEquals("wrong name", "test0171", packageBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
String[] components = packageBinding.getNameComponents();
assertNotNull("no components", components); //$NON-NLS-1$
assertTrue("components size != 1", components.length == 1); //$NON-NLS-1$
assertEquals("wrong component name", "test0171", components[0]); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong type", IBinding.PACKAGE, packageBinding.getKind()); //$NON-NLS-1$
assertTrue("Unnamed package", !packageBinding.isUnnamed()); //$NON-NLS-1$
assertTrue("Package binding is not canonical", packageBinding == typeBinding.getPackage()); //$NON-NLS-1$
typeDeclaration = (TypeDeclaration) types.get(1);
typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Binding not null", typeBinding); //$NON-NLS-1$
IPackageBinding packageBinding2 = typeBinding.getPackage();
assertNotNull("No package binding", packageBinding); //$NON-NLS-1$
assertTrue("Package binding is not canonical", packageBinding == packageBinding2); //$NON-NLS-1$
}
/**
* Check method binding
*/
public void test0172() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0172", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
List types = compilationUnit.types();
assertTrue("The types list is empty", types.size() != 0); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) types.get(0);
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("Binding not null", typeBinding); //$NON-NLS-1$
IMethodBinding[] methods = typeBinding.getDeclaredMethods();
assertNotNull("No methods", methods);
assertEquals("methods.length != 4", 4, methods.length); //$NON-NLS-1$
List bodyDeclarations = typeDeclaration.bodyDeclarations();
assertEquals("body declaration size != 3", 3, bodyDeclarations.size()); //$NON-NLS-1$
MethodDeclaration method1 = (MethodDeclaration) bodyDeclarations.get(0);
IMethodBinding methodBinding1 = method1.resolveBinding();
assertNotNull("No method binding for foo", methodBinding1); //$NON-NLS-1$
SimpleName simpleName = method1.getName();
assertTrue("not a declaration", simpleName.isDeclaration()); //$NON-NLS-1$
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("wrong name", binding.getName(), simpleName.getIdentifier()); //$NON-NLS-1$
// search method foo
IMethodBinding methodBinding = null;
loop: for (int i = 0, max = methods.length; i < max; i++) {
IMethodBinding currentMethod = methods[i];
if ("foo".equals(currentMethod.getName())) {
methodBinding = currentMethod;
break loop;
}
}
assertNotNull("Cannot be null", methodBinding);
assertTrue("Canonical method binding", methodBinding1 == methodBinding); //$NON-NLS-1$
assertTrue("declaring class is canonical", typeBinding == methodBinding1.getDeclaringClass()); //$NON-NLS-1$
ITypeBinding[] exceptionTypes = methodBinding1.getExceptionTypes();
assertNotNull("No exception types", exceptionTypes); //$NON-NLS-1$
assertEquals("One exception", 1, exceptionTypes.length); //$NON-NLS-1$
assertEquals("wrong name for exception", "IOException", exceptionTypes[0].getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong modifier", Modifier.NONE, methodBinding1.getModifiers()); //$NON-NLS-1$
assertEquals("wrong name for method", "foo", methodBinding1.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding[] parameters = methodBinding1.getParameterTypes();
assertNotNull("No parameters", parameters); //$NON-NLS-1$
assertEquals("wrong size", 1, parameters.length); //$NON-NLS-1$
assertEquals("wrong type", "int[]", parameters[0].getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong return type", "void", methodBinding1.getReturnType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("A constructor", !methodBinding1.isConstructor()); //$NON-NLS-1$
MethodDeclaration method2 = (MethodDeclaration) bodyDeclarations.get(1);
IMethodBinding methodBinding2 = method2.resolveBinding();
assertNotNull("No method binding for main", methodBinding2); //$NON-NLS-1$
methodBinding = null;
loop: for (int i = 0, max = methods.length; i < max; i++) {
IMethodBinding currentMethod = methods[i];
if ("main".equals(currentMethod.getName())) {
methodBinding = currentMethod;
break loop;
}
}
assertNotNull("Cannot be null", methodBinding);
assertTrue("Canonical method binding", methodBinding2 == methodBinding); //$NON-NLS-1$
assertTrue("declaring class is canonical", typeBinding == methodBinding2.getDeclaringClass()); //$NON-NLS-1$
ITypeBinding[] exceptionTypes2 = methodBinding2.getExceptionTypes();
assertNotNull("No exception types", exceptionTypes2); //$NON-NLS-1$
assertEquals("No exception", 0, exceptionTypes2.length); //$NON-NLS-1$
assertEquals("wrong modifier", Modifier.PUBLIC | Modifier.STATIC, methodBinding2.getModifiers()); //$NON-NLS-1$
assertEquals("wrong name for method", "main", methodBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding[] parameters2 = methodBinding2.getParameterTypes();
assertNotNull("No parameters", parameters2); //$NON-NLS-1$
assertEquals("wrong size", 1, parameters2.length); //$NON-NLS-1$
assertEquals("wrong type for parameter2[0]", "String[]", parameters2[0].getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong return type", "void", methodBinding2.getReturnType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("A constructor", !methodBinding2.isConstructor()); //$NON-NLS-1$
MethodDeclaration method3 = (MethodDeclaration) bodyDeclarations.get(2);
IMethodBinding methodBinding3 = method3.resolveBinding();
assertNotNull("No method binding for main", methodBinding3); //$NON-NLS-1$
methodBinding = null;
loop: for (int i = 0, max = methods.length; i < max; i++) {
IMethodBinding currentMethod = methods[i];
if ("bar".equals(currentMethod.getName())) {
methodBinding = currentMethod;
break loop;
}
}
assertNotNull("Cannot be null", methodBinding);
assertTrue("Canonical method binding", methodBinding3 == methodBinding); //$NON-NLS-1$
assertTrue("declaring class is canonical", typeBinding == methodBinding3.getDeclaringClass()); //$NON-NLS-1$
ITypeBinding[] exceptionTypes3 = methodBinding3.getExceptionTypes();
assertNotNull("No exception types", exceptionTypes3); //$NON-NLS-1$
assertEquals("No exception", 1, exceptionTypes3.length); //$NON-NLS-1$
assertEquals("wrong modifier", Modifier.PRIVATE, methodBinding3.getModifiers()); //$NON-NLS-1$
assertEquals("wrong name for method", "bar", methodBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding[] parameters3 = methodBinding3.getParameterTypes();
assertNotNull("No parameters", parameters3); //$NON-NLS-1$
assertEquals("wrong size", 1, parameters3.length); //$NON-NLS-1$
assertEquals("wrong type", "String", parameters3[0].getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong return type", "String", methodBinding3.getReturnType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("A constructor", !methodBinding3.isConstructor()); //$NON-NLS-1$
assertTrue("The binding is not canonical", parameters3[0] == methodBinding3.getReturnType()); //$NON-NLS-1$
}
/**
* i++; IVariableBinding
*/
public void test0173() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0173", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("Not an expressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression ex = expressionStatement.getExpression();
assertTrue("Not a postfixexpression", ex instanceof PostfixExpression); //$NON-NLS-1$
PostfixExpression postfixExpression = (PostfixExpression) ex;
Expression expr = postfixExpression.getOperand();
assertTrue("Not a simpleName", expr instanceof SimpleName); //$NON-NLS-1$
SimpleName name = (SimpleName) expr;
assertTrue("a declaration", !name.isDeclaration()); //$NON-NLS-1$
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
assertTrue(variableBinding == binding);
}
/**
* i++; IVariableBinding (field)
*/
public void test0174() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0174", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 1, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("Not an expressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression ex = expressionStatement.getExpression();
assertTrue("Not a postfixexpression", ex instanceof PostfixExpression); //$NON-NLS-1$
PostfixExpression postfixExpression = (PostfixExpression) ex;
Expression expr = postfixExpression.getOperand();
assertTrue("Not a simpleName", expr instanceof SimpleName); //$NON-NLS-1$
SimpleName name = (SimpleName) expr;
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("FieldDeclaration", node2 instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
List fragments = fieldDeclaration.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
assertTrue(variableBinding == binding);
}
/**
* int i = 0; Test IntBinding for the field declaration and the 0 literal
*/
public void test0175() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0175", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
List fragments = fieldDeclaration.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
ITypeBinding typeBinding = fragment.getInitializer().resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue("Not a primitive type", typeBinding.isPrimitive()); //$NON-NLS-1$
assertEquals("Not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue(variableBinding.getType() == typeBinding);
}
/**
* ThisReference
*/
public void test0176() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0176", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
assertTrue("Return statement", node2 instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node2;
assertTrue("Not a field access", returnStatement.getExpression() instanceof FieldAccess); //$NON-NLS-1$
FieldAccess fieldAccess = (FieldAccess) returnStatement.getExpression();
ITypeBinding typeBinding = fieldAccess.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue("Not a primitive type", typeBinding.isPrimitive()); //$NON-NLS-1$
assertEquals("Not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Expression expr = fieldAccess.getExpression();
assertTrue("Not a this expression", expr instanceof ThisExpression); //$NON-NLS-1$
ThisExpression thisExpression = (ThisExpression) expr;
ITypeBinding typeBinding2 = thisExpression.resolveTypeBinding();
assertNotNull("No type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("Not Test", "Test", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* i++; IVariableBinding
*/
public void test0177() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0177", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 1, 1);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("Not an expressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression ex = expressionStatement.getExpression();
assertTrue("Not a postfixexpression", ex instanceof PostfixExpression); //$NON-NLS-1$
PostfixExpression postfixExpression = (PostfixExpression) ex;
Expression expr = postfixExpression.getOperand();
assertTrue("Not a simpleName", expr instanceof SimpleName); //$NON-NLS-1$
SimpleName name = (SimpleName) expr;
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
assertEquals("return type is not int", "int", variableBinding.getType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue(variableBinding == binding);
}
/**
* SuperReference
*/
public void test0178() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0178", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 1, 0, 0);
assertTrue("Return statement", node2 instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node2;
Expression expr = returnStatement.getExpression();
assertTrue("Not a field access", expr instanceof SuperFieldAccess); //$NON-NLS-1$
SuperFieldAccess fieldAccess = (SuperFieldAccess) expr;
ITypeBinding typeBinding = fieldAccess.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue("Not a primitive type", typeBinding.isPrimitive()); //$NON-NLS-1$
assertEquals("Not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Allocation expression
*/
public void test0179() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0179", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
Expression initialization = fragment.getInitializer();
ITypeBinding typeBinding = initialization.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue(variableBinding.getType() == typeBinding);
}
/**
* Allocation expression
*/
public void test0180() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0180", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
Expression initialization = fragment.getInitializer();
assertTrue("No an array creation", initialization instanceof ArrayCreation); //$NON-NLS-1$
ITypeBinding typeBinding = initialization.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue("Not an array", typeBinding.isArray()); //$NON-NLS-1$
assertTrue(variableBinding.getType() == typeBinding);
}
/**
* Allocation expression
*/
public void test0181() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0181", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
Expression initialization = fragment.getInitializer();
ITypeBinding typeBinding = initialization.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue("Not an array", typeBinding.isArray()); //$NON-NLS-1$
assertTrue(variableBinding.getType() == typeBinding);
}
/**
* BinaryExpression
*/
public void test0182() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0182", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("IfStatement", node2 instanceof IfStatement); //$NON-NLS-1$
IfStatement ifStatement = (IfStatement) node2;
Expression expr = ifStatement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "i < 10", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0183() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0183", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("IfStatement", node2 instanceof IfStatement); //$NON-NLS-1$
IfStatement ifStatement = (IfStatement) node2;
Expression expr = ifStatement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "i < 10 && i < 20", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0184() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0184", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("IfStatement", node2 instanceof IfStatement); //$NON-NLS-1$
IfStatement ifStatement = (IfStatement) node2;
Expression expr = ifStatement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "i < 10 || i < 20", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0185() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0185", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("IfStatement", node2 instanceof IfStatement); //$NON-NLS-1$
IfStatement ifStatement = (IfStatement) node2;
Expression expr = ifStatement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "i == 10", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0186() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0186", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("IfStatement", node2 instanceof IfStatement); //$NON-NLS-1$
IfStatement ifStatement = (IfStatement) node2;
Expression expr = ifStatement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "o == o", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0187() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0187", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("IfStatement", node2 instanceof WhileStatement); //$NON-NLS-1$
WhileStatement whileStatement = (WhileStatement) node2;
Expression expr = whileStatement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "i <= 10", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0188() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0188", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 2);
assertTrue("DoStatement", node2 instanceof DoStatement); //$NON-NLS-1$
DoStatement statement = (DoStatement) node2;
Expression expr = statement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "i <= 10", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0189() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0189", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("ForStatement", node2 instanceof ForStatement); //$NON-NLS-1$
ForStatement statement = (ForStatement) node2;
Expression expr = statement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "i < 10", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0190() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0190", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 2, 1);
assertTrue("IfStatement", node2 instanceof IfStatement); //$NON-NLS-1$
IfStatement statement = (IfStatement) node2;
Expression expr = statement.getExpression();
assertNotNull("No condition", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "scanner.x < selection.start && selection.start < scanner.y", source); //$NON-NLS-1$
}
/**
* BinaryExpression
*/
public void test0191() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0191", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node2;
Expression ex = expressionStatement.getExpression();
assertTrue("Assignment", ex instanceof Assignment); //$NON-NLS-1$
Assignment statement = (Assignment) ex;
Expression rightExpr = statement.getRightHandSide();
assertTrue("Not an infix expression", rightExpr instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression = (InfixExpression) rightExpr;
Expression expr = infixExpression.getRightOperand();
assertNotNull("No right hand side expression", expr); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(expr, "2 < 20", source); //$NON-NLS-1$
}
/**
* Initializer
*/
public void test0192() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0192", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
Expression initialization = fragment.getInitializer();
ITypeBinding typeBinding = initialization.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue(variableBinding.getType() == typeBinding);
checkSourceRange(initialization, "0", source); //$NON-NLS-1$
}
/**
* Initializer
*/
public void test0193() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0193", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
Expression initialization = fragment.getInitializer();
ITypeBinding typeBinding = initialization.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue(variableBinding.getType() == typeBinding);
checkSourceRange(initialization, "new Inner()", source); //$NON-NLS-1$
assertEquals("Wrong type", "Inner", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Initializer
*/
public void test0194() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0194", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
Expression initialization = fragment.getInitializer();
ITypeBinding typeBinding = initialization.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue(variableBinding.getType() == typeBinding);
checkSourceRange(initialization, "new Inner[10]", source); //$NON-NLS-1$
assertTrue("Not an array", typeBinding.isArray()); //$NON-NLS-1$
assertEquals("Wrong type", "Inner[]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Initializer
*/
public void test0195() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0195", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 1, 0, 1);
assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node2;
Expression ex = expressionStatement.getExpression();
assertTrue("MethodInvocation", ex instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) ex;
checkSourceRange(methodInvocation, "a.useFile(/*]*/a.getFile()/*[*/)", source); //$NON-NLS-1$
List list = methodInvocation.arguments();
assertTrue("Parameter list not empty", list.size() == 1); //$NON-NLS-1$
Expression parameter = (Expression) list.get(0);
assertTrue("Not a method invocation", parameter instanceof MethodInvocation); //$NON-NLS-1$
ITypeBinding typeBinding = parameter.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not a boolean", "File", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(parameter, "a.getFile()", source); //$NON-NLS-1$
}
/**
* Initializer
*/
public void test0196() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0196", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 2);
assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node2;
Expression ex = expressionStatement.getExpression();
assertTrue("Assignment", ex instanceof Assignment); //$NON-NLS-1$
Assignment statement = (Assignment) ex;
Expression rightExpr = statement.getRightHandSide();
assertTrue("Not an instanceof expression", rightExpr instanceof InstanceofExpression); //$NON-NLS-1$
ITypeBinding typeBinding = rightExpr.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong type", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(rightExpr, "inner instanceof Inner", source); //$NON-NLS-1$
}
/**
* Initializer
*/
public void test0197() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0197", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, result.getNodeType());
CompilationUnit unit = (CompilationUnit) result;
assertProblemsSize(unit, 0);
ASTNode node2 = getASTNode(unit, 1, 0, 1);
assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node2;
Expression ex = expressionStatement.getExpression();
assertTrue("MethodInvocation", ex instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) ex;
checkSourceRange(methodInvocation, "a.getFile()/*[*/.getName()", source); //$NON-NLS-1$
Expression receiver = methodInvocation.getExpression();
assertTrue("Not a method invocation", receiver instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation2 = (MethodInvocation) receiver;
ITypeBinding typeBinding = methodInvocation2.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "File", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(methodInvocation2, "a.getFile()", source); //$NON-NLS-1$
}
/**
* Initializer
*/
public void test0198() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0198", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("ReturnStatement", node2 instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node2;
Expression expr = returnStatement.getExpression();
assertTrue("Not an infixExpression", expr instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression = (InfixExpression) expr;
Expression left = infixExpression.getLeftOperand();
assertTrue("Not an InfixExpression", left instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression2 = (InfixExpression) left;
Expression right = infixExpression2.getRightOperand();
assertTrue("Not an InfixExpression", right instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression3 = (InfixExpression) right;
assertEquals("A multiplication", InfixExpression.Operator.TIMES, infixExpression3.getOperator()); //$NON-NLS-1$
ITypeBinding typeBinding = infixExpression3.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(infixExpression3, "20 * 30", source); //$NON-NLS-1$
}
/**
* Initializer
*/
public void test0199() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0199", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
Expression initialization = fragment.getInitializer();
assertTrue("Not an infixExpression", initialization instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression = (InfixExpression) initialization;
Expression left = infixExpression.getLeftOperand();
assertTrue("Not an InfixExpression", left instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression2 = (InfixExpression) left;
Expression right = infixExpression2.getRightOperand();
assertTrue("Not an InfixExpression", right instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression3 = (InfixExpression) right;
assertEquals("A multiplication", InfixExpression.Operator.TIMES, infixExpression3.getOperator()); //$NON-NLS-1$
ITypeBinding typeBinding = infixExpression3.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(infixExpression3, "10 * 30", source); //$NON-NLS-1$
}
/**
* Initializer
*/
public void test0200() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0200", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 1, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertTrue("No fragment", fragments.size() == 1); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
Expression initialization = fragment.getInitializer();
assertTrue("Not an infixExpression", initialization instanceof FieldAccess); //$NON-NLS-1$
FieldAccess fieldAccess = (FieldAccess) initialization;
Expression receiver = fieldAccess.getExpression();
assertTrue("ArrayCreation", receiver instanceof ArrayCreation); //$NON-NLS-1$
ArrayCreation arrayCreation = (ArrayCreation) receiver;
List dimensions = arrayCreation.dimensions();
assertEquals("Wrong dimension", 1, dimensions.size()); //$NON-NLS-1$
Expression dim = (Expression) dimensions.get(0);
assertTrue("InfixExpression", dim instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression = (InfixExpression) dim;
ITypeBinding typeBinding = infixExpression.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(infixExpression, "1 + 2", source); //$NON-NLS-1$
}
/**
* Position inside for statement: PR 3300
*/
public void test0201() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0201", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("ForStatement", node2 instanceof ForStatement); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node2;
List initializers = forStatement.initializers();
assertTrue("wrong size", initializers.size() == 1); //$NON-NLS-1$
Expression init = (Expression) initializers.get(0);
checkSourceRange(init, "int i= 0", source); //$NON-NLS-1$
}
/**
* PR 7386
*/
public void test0202() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0202", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("FieldDeclaration", node2 instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
checkSourceRange(fieldDeclaration, "int f= (2);", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
Expression initialization = fragment.getInitializer();
assertTrue("Not a parenthesized expression", initialization instanceof ParenthesizedExpression); //$NON-NLS-1$
checkSourceRange(initialization, "(2)", source); //$NON-NLS-1$
ITypeBinding typeBinding = initialization.resolveTypeBinding();
assertNotNull("no binding", typeBinding); //$NON-NLS-1$
assertEquals("not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* PR 7386
*/
public void test0203() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0203", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("FieldDeclaration", node2 instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
checkSourceRange(fieldDeclaration, "int f= (2);", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
Expression initialization = fragment.getInitializer();
assertTrue("Not a parenthesized expression", initialization instanceof ParenthesizedExpression); //$NON-NLS-1$
ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) initialization;
checkSourceRange(parenthesizedExpression, "(2)", source); //$NON-NLS-1$
Expression expr = parenthesizedExpression.getExpression();
checkSourceRange(expr, "2", source); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("no binding", typeBinding); //$NON-NLS-1$
assertEquals("not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("type binding is canonical", typeBinding == parenthesizedExpression.resolveTypeBinding()); //$NON-NLS-1$
}
/**
* PR 7386
*/
public void test0204() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0204", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("FieldDeclaration", node2 instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node2;
checkSourceRange(fieldDeclaration, "int f= ((2));", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
Expression initialization = fragment.getInitializer();
assertTrue("Not a parenthesized expression", initialization instanceof ParenthesizedExpression); //$NON-NLS-1$
ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) initialization;
checkSourceRange(parenthesizedExpression, "((2))", source); //$NON-NLS-1$
Expression expr = parenthesizedExpression.getExpression();
assertTrue("Not a parenthesized expression", expr instanceof ParenthesizedExpression); //$NON-NLS-1$
ParenthesizedExpression parenthesizedExpression2 = (ParenthesizedExpression) expr;
checkSourceRange(parenthesizedExpression2, "(2)", source); //$NON-NLS-1$
expr = parenthesizedExpression2.getExpression();
checkSourceRange(expr, "2", source); //$NON-NLS-1$
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("no binding", typeBinding); //$NON-NLS-1$
assertEquals("not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = parenthesizedExpression.resolveTypeBinding();
assertNotNull("no binding", typeBinding); //$NON-NLS-1$
assertEquals("not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("type binding is canonical", typeBinding == parenthesizedExpression2.resolveTypeBinding()); //$NON-NLS-1$
}
/**
* Local class end position when trailing comment
* @deprecated using deprecated code
*/
public void test0205() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0205", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("TypeDeclarationStatement", node2 instanceof TypeDeclarationStatement); //$NON-NLS-1$
TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node2;
TypeDeclaration typeDeclaration = typeDeclarationStatement.getTypeDeclaration();
assertEquals("wrong name", "AA", typeDeclaration.getName().getIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(typeDeclaration, "class AA extends Test {}", source); //$NON-NLS-1$
}
/**
* QualifiedName
*/
public void test0206() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0206", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 5, 0);
assertTrue("ReturnStatement", node2 instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node2;
Expression expr = returnStatement.getExpression();
assertTrue("Not a qualifiedName", expr instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) expr;
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Not an int (typeBinding)", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(qualifiedName, "field1.field2.field3.field4.i", source); //$NON-NLS-1$
assertTrue("Not a simple name", qualifiedName.getName().isSimpleName()); //$NON-NLS-1$
SimpleName simpleName = qualifiedName.getName();
assertTrue("a declaration", !simpleName.isDeclaration()); //$NON-NLS-1$
checkSourceRange(simpleName, "i", source); //$NON-NLS-1$
ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
assertNotNull("No typebinding2", typeBinding2); //$NON-NLS-1$
assertEquals("Not an int (typeBinding2)", "int", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("VariableBinding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertEquals("Not Test", "Test", variableBinding.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not default", Modifier.PUBLIC, variableBinding.getModifiers()); //$NON-NLS-1$
Name qualifierName = qualifiedName.getQualifier();
assertTrue("Not a qualified name", qualifierName.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(qualifierName, "field1.field2.field3.field4", source); //$NON-NLS-1$
ITypeBinding typeBinding5 = qualifierName.resolveTypeBinding();
assertNotNull("No binding5", typeBinding5); //$NON-NLS-1$
assertEquals("Not Test", "Test", typeBinding5.getName()); //$NON-NLS-1$ //$NON-NLS-2$
qualifiedName = (QualifiedName) qualifierName;
simpleName = qualifiedName.getName();
checkSourceRange(simpleName, "field4", source); //$NON-NLS-1$
ITypeBinding typeBinding6 = simpleName.resolveTypeBinding();
assertNotNull("No binding6", typeBinding6); //$NON-NLS-1$
assertEquals("Not Test", "Test", typeBinding6.getName()); //$NON-NLS-1$ //$NON-NLS-2$
qualifierName = qualifiedName.getQualifier();
assertTrue("Not a qualified name", qualifierName.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(qualifierName, "field1.field2.field3", source); //$NON-NLS-1$
ITypeBinding typeBinding7 = qualifierName.resolveTypeBinding();
assertNotNull("No binding7", typeBinding7); //$NON-NLS-1$
assertEquals("Not Test", "Test", typeBinding7.getName()); //$NON-NLS-1$ //$NON-NLS-2$
qualifiedName = (QualifiedName) qualifierName;
simpleName = qualifiedName.getName();
checkSourceRange(simpleName, "field3", source); //$NON-NLS-1$
qualifierName = qualifiedName.getQualifier();
assertTrue("Not a qualified name", qualifierName.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(qualifierName, "field1.field2", source); //$NON-NLS-1$
ITypeBinding typeBinding3 = qualifierName.resolveTypeBinding();
assertNotNull("No binding3", typeBinding3); //$NON-NLS-1$
assertEquals("Not Test", "Test", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
qualifiedName = (QualifiedName) qualifierName;
simpleName = qualifiedName.getName();
checkSourceRange(simpleName, "field2", source); //$NON-NLS-1$
qualifierName = qualifiedName.getQualifier();
assertTrue("Not a simple name", qualifierName.isSimpleName()); //$NON-NLS-1$
assertTrue("a declaration", !((SimpleName)qualifierName).isDeclaration()); //$NON-NLS-1$
checkSourceRange(qualifierName, "field1", source); //$NON-NLS-1$
ITypeBinding typeBinding4 = qualifierName.resolveTypeBinding();
assertNotNull("No binding4", typeBinding4); //$NON-NLS-1$
assertEquals("Not Test", "Test", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check javadoc for MethodDeclaration
* @deprecated marking deprecated since using deprecated code
*/
public void test0207() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0207", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
checkSourceRange(node, "/** JavaDoc Comment*/\n void foo(final int i) {}", source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Check javadoc for MethodDeclaration
*/
public void test0208() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0208", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
}
/**
* Check javadoc for MethodDeclaration
*/
public void test0209() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0209", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((MethodDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "void foo(final int i) {}", source); //$NON-NLS-1$
}
/**
* Check javadoc for FieldDeclaration
* @deprecated marking deprecated since using deprecated code
*/
public void test0210() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0210", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
checkSourceRange(node, "/** JavaDoc Comment*/\n int i;", source); //$NON-NLS-1$
}
/**
* Check javadoc for FieldDeclaration
*/
public void test0211() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0211", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "int i;", source); //$NON-NLS-1$
}
/**
* Check javadoc for FieldDeclaration
*/
public void test0212() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0212", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((FieldDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "int i;", source); //$NON-NLS-1$
}
/**
* Check javadoc for TypeDeclaration
*/
public void test0213() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0213", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
String expectedContents = "public class Test {\n" +//$NON-NLS-1$
" int i;\n" +//$NON-NLS-1$
"}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
}
/**
* Check javadoc for TypeDeclaration
*/
public void test0214() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0214", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
String expectedContents = "public class Test {\n" +//$NON-NLS-1$
" int i;\n" +//$NON-NLS-1$
"}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
}
/**
* Check javadoc for TypeDeclaration
* @deprecated marking deprecated since using deprecated code
*/
public void test0215() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0215", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
String expectedContents =
"/** JavaDoc Comment*/\n" + //$NON-NLS-1$
"public class Test {\n" +//$NON-NLS-1$
" int i;\n" +//$NON-NLS-1$
"}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Check javadoc for MemberTypeDeclaration
* @deprecated marking deprecated since using deprecated code
*/
public void test0216() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0216", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
String expectedContents =
"/** JavaDoc Comment*/\n" + //$NON-NLS-1$
" class B {}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Check javadoc for MemberTypeDeclaration
*/
public void test0217() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0217", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "class B {}", source); //$NON-NLS-1$
}
/**
* Check javadoc for MemberTypeDeclaration
*/
public void test0218() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0218", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "public static class B {}", source); //$NON-NLS-1$
}
/**
* Check javadoc for MemberTypeDeclaration
*/
public void test0219() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0219", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
assertTrue("The node is not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
Javadoc actualJavadoc = ((TypeDeclaration) node).getJavadoc();
assertTrue("Javadoc must be null", actualJavadoc == null);//$NON-NLS-1$
checkSourceRange(node, "public static class B {}", source); //$NON-NLS-1$
}
/**
* Checking initializers
*/
public void test0220() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0220", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
checkSourceRange(node, "{}", source); //$NON-NLS-1$
}
/**
* Checking initializers
*/
public void test0221() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0221", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
checkSourceRange(node, "static {}", source); //$NON-NLS-1$
}
/**
* Checking initializers
* @deprecated marking deprecated since using deprecated code
*/
public void test0222() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0222", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
assertNotNull("Javadoc comment should no be null", actualJavadoc); //$NON-NLS-1$
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
String expectedContents =
"/** JavaDoc Comment*/\n" + //$NON-NLS-1$
" static {}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Checking initializers
* @deprecated marking deprecated since using deprecated code
*/
public void test0223() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0223", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
assertNotNull("Javadoc comment should not be null", actualJavadoc); //$NON-NLS-1$
Javadoc javadoc = this.ast.newJavadoc();
javadoc.setComment("/** JavaDoc Comment*/");//$NON-NLS-1$*/
assertTrue("Both AST trees should be identical", javadoc.subtreeMatch(new ASTMatcher(), actualJavadoc));//$NON-NLS-1$
String expectedContents =
"/** JavaDoc Comment*/\n" + //$NON-NLS-1$
" {}";//$NON-NLS-1$
checkSourceRange(node, expectedContents, source); //$NON-NLS-1$
checkSourceRange(actualJavadoc, "/** JavaDoc Comment*/", source); //$NON-NLS-1$
}
/**
* Checking initializers
*/
public void test0224() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0224", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
Javadoc actualJavadoc = ((Initializer) node).getJavadoc();
assertNull("Javadoc comment should be null", actualJavadoc); //$NON-NLS-1$
checkSourceRange(node, "{}", source); //$NON-NLS-1$
}
/**
* Continue ==> ContinueStatement
*/
public void test0225() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0225", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
LabeledStatement labeledStatement = (LabeledStatement) getASTNode((CompilationUnit) result, 0, 0, 0);
checkSourceRange(labeledStatement.getLabel(), "label", source); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) labeledStatement.getBody();
ContinueStatement statement = (ContinueStatement) ((Block) forStatement.getBody()).statements().get(0);
assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
ContinueStatement continueStatement = this.ast.newContinueStatement();
continueStatement.setLabel(this.ast.newSimpleName("label")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", continueStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
checkSourceRange(statement, "continue label;", source); //$NON-NLS-1$
checkSourceRange(statement.getLabel(), "label", source); //$NON-NLS-1$
}
/**
* Break + label ==> BreakStatement
*/
public void test0226() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0226", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
LabeledStatement labeledStatement = (LabeledStatement) getASTNode((CompilationUnit) result, 0, 0, 0);
checkSourceRange(labeledStatement.getLabel(), "label", source); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) labeledStatement.getBody();
BreakStatement statement = (BreakStatement) ((Block) forStatement.getBody()).statements().get(0);
assertNotNull("Expression should not be null", statement); //$NON-NLS-1$
BreakStatement breakStatement = this.ast.newBreakStatement();
breakStatement.setLabel(this.ast.newSimpleName("label")); //$NON-NLS-1$
assertTrue("Both AST trees should be identical", breakStatement.subtreeMatch(new ASTMatcher(), statement)); //$NON-NLS-1$
checkSourceRange(statement, "break label;", source); //$NON-NLS-1$
checkSourceRange(statement.getLabel(), "label", source); //$NON-NLS-1$
}
/**
* QualifiedName
*/
public void test0227() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0227", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 3, 2, 0);
assertTrue("ReturnStatement", node2 instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node2;
Expression expr = returnStatement.getExpression();
assertTrue("Not a qualifiedName", expr instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) expr;
ITypeBinding typeBinding = expr.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Not an long (typeBinding)", "long", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(qualifiedName, "field.fB.fA.j", source); //$NON-NLS-1$
SimpleName simpleName = qualifiedName.getName();
checkSourceRange(simpleName, "j", source); //$NON-NLS-1$
ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
assertEquals("Not an long (typeBinding2)", "long", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("VariableBinding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertEquals("Not A", "A", variableBinding.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not default", Modifier.NONE, variableBinding.getModifiers()); //$NON-NLS-1$
assertEquals("wrong name", "j", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Name qualifierName = qualifiedName.getQualifier();
assertTrue("Not a qualified name", qualifierName.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(qualifierName, "field.fB.fA", source); //$NON-NLS-1$
qualifiedName = (QualifiedName) qualifierName;
ITypeBinding typeBinding3 = qualifiedName.resolveTypeBinding();
assertNotNull("No type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("Not an A", "A", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
simpleName = qualifiedName.getName();
checkSourceRange(simpleName, "fA", source); //$NON-NLS-1$
ITypeBinding typeBinding4 = simpleName.resolveTypeBinding();
assertNotNull("No typeBinding4", typeBinding4); //$NON-NLS-1$
assertEquals("Not an A", "A", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding2 = qualifiedName.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
assertTrue("VariableBinding", binding2 instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding2 = (IVariableBinding) binding2;
assertEquals("Not B", "B", variableBinding2.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not default", Modifier.NONE, variableBinding2.getModifiers()); //$NON-NLS-1$
assertEquals("wrong name", "fA", variableBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
qualifierName = qualifiedName.getQualifier();
assertTrue("Not a qualified name", qualifierName.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(qualifierName, "field.fB", source); //$NON-NLS-1$
qualifiedName = (QualifiedName) qualifierName;
ITypeBinding typeBinding5 = qualifiedName.resolveTypeBinding();
assertNotNull("No typeBinding5", typeBinding5); //$NON-NLS-1$
assertEquals("Not a B", "B", typeBinding5.getName()); //$NON-NLS-1$ //$NON-NLS-2$
simpleName = qualifiedName.getName();
checkSourceRange(simpleName, "fB", source); //$NON-NLS-1$
ITypeBinding typeBinding6 = simpleName.resolveTypeBinding();
assertNotNull("No typebinding6", typeBinding6); //$NON-NLS-1$
assertEquals("not a B", "B", typeBinding6.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding3 = qualifiedName.resolveBinding();
assertNotNull("No binding2", binding3); //$NON-NLS-1$
assertTrue("VariableBinding", binding3 instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding3 = (IVariableBinding) binding3;
assertEquals("Not C", "C", variableBinding3.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not default", Modifier.NONE, variableBinding3.getModifiers()); //$NON-NLS-1$
assertEquals("wrong name", "fB", variableBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
qualifierName = qualifiedName.getQualifier();
assertTrue("Not a simple name", qualifierName.isSimpleName()); //$NON-NLS-1$
checkSourceRange(qualifierName, "field", source); //$NON-NLS-1$
simpleName = (SimpleName) qualifierName;
ITypeBinding typeBinding7 = simpleName.resolveTypeBinding();
assertNotNull("No typeBinding7", typeBinding7); //$NON-NLS-1$
assertEquals("Not a C", "C", typeBinding7.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding4 = simpleName.resolveBinding();
assertNotNull("No binding4", binding4); //$NON-NLS-1$
assertTrue("VariableBinding", binding4 instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding4 = (IVariableBinding) binding4;
assertEquals("Not Test", "Test", variableBinding4.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not public", Modifier.PUBLIC, variableBinding4.getModifiers()); //$NON-NLS-1$
assertEquals("wrong name", "field", variableBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong return type", "C", variableBinding4.getType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* QualifiedName as TypeReference
*/
public void test0228() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0228", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
assertTrue("ReturnStatement", node2 instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node2;
Expression expr = returnStatement.getExpression();
checkSourceRange(expr, "test0228.Test.foo()", source); //$NON-NLS-1$
assertTrue("MethodInvocation", expr instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expr;
Expression qualifier = methodInvocation.getExpression();
assertNotNull("no qualifier", qualifier); //$NON-NLS-1$
assertTrue("QualifiedName", qualifier instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) qualifier;
checkSourceRange(qualifiedName, "test0228.Test", source); //$NON-NLS-1$
ITypeBinding typeBinding = qualifiedName.resolveTypeBinding();
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong type", "Test", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding = qualifiedName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Not a type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
}
/**
* MethodInvocation
*/
public void test0229() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0229", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node2;
Expression expr = expressionStatement.getExpression();
assertTrue("MethodInvocation", expr instanceof MethodInvocation); //$NON-NLS-1$
checkSourceRange(expr, "System.err.println()", source); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expr;
Expression qualifier = methodInvocation.getExpression();
assertTrue("QualifiedName", qualifier instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) qualifier;
ITypeBinding typeBinding = qualifier.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "PrintStream", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding = qualifiedName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("VariableBinding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertEquals("wrong name", "err", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
SimpleName methodName = methodInvocation.getName();
IBinding binding2 = methodName.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
}
/**
* MethodInvocation
*/
public void test0230() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0230", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 1, 0);
assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node2;
Expression expr = expressionStatement.getExpression();
assertTrue("MethodInvocation", expr instanceof MethodInvocation); //$NON-NLS-1$
checkSourceRange(expr, "err.println()", source); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expr;
Expression qualifier = methodInvocation.getExpression();
assertTrue("SimpleName", qualifier instanceof SimpleName); //$NON-NLS-1$
SimpleName name = (SimpleName) qualifier;
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong name", "err", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding typeBinding = name.resolveTypeBinding();
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wron type name", "PrintStream", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* MethodInvocation
*/
public void test0231() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0231", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("ExpressionStatement", node2 instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node2;
Expression expr = expressionStatement.getExpression();
assertTrue("MethodInvocation", expr instanceof MethodInvocation); //$NON-NLS-1$
checkSourceRange(expr, "System.err.println()", source); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expr;
Expression qualifier = methodInvocation.getExpression();
assertTrue("QualifiedName", qualifier instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) qualifier;
ITypeBinding typeBinding = qualifier.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "PrintStream", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding = qualifiedName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("VariableBinding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertEquals("wrong name", "err", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
SimpleName methodName = methodInvocation.getName();
IBinding binding2 = methodName.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
Name name = qualifiedName.getQualifier();
assertTrue("SimpleName", name.isSimpleName()); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) name;
ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
assertNotNull("No typeBinding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong type name", "System", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* MethodInvocation
*/
public void test0232() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0232", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node2 = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("VariableDeclarationStatement", node2 instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node2;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression initialization = variableDeclarationFragment.getInitializer();
ITypeBinding typeBinding = initialization.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue("Not a primitive type", typeBinding.isPrimitive()); //$NON-NLS-1$
assertEquals("wrong name", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("QualifiedName", initialization instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) initialization;
SimpleName simpleName = qualifiedName.getName();
ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
assertNotNull("No type binding", typeBinding2); //$NON-NLS-1$
assertTrue("Not a primitive type", typeBinding2.isPrimitive()); //$NON-NLS-1$
assertEquals("wrong name", "int", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("IVariableBinding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertNull("No declaring class", variableBinding.getDeclaringClass()); //$NON-NLS-1$
}
/**
* Checking that only syntax errors are reported for the MALFORMED tag
*/
public void test0233() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0233", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("Expression should not be null", result); //$NON-NLS-1$
assertTrue("The compilation unit is malformed", !isMalformed(result)); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("The fiels is not malformed", !isMalformed(node)); //$NON-NLS-1$
assertEquals("No problem found", 1, unit.getMessages().length); //$NON-NLS-1$
assertEquals("No problem found", 1, unit.getProblems().length); //$NON-NLS-1$
}
/**
* Checking that null is returned for a resolveBinding if the type is unknown
*/
public void test0234() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0234", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("The fiels is not malformed", !isMalformed(node)); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("No problem found", 1, unit.getMessages().length); //$NON-NLS-1$
assertEquals("No problem found", 1, unit.getProblems().length); //$NON-NLS-1$
assertTrue("FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
assertNotNull("No binding", variableBinding); //$NON-NLS-1$
assertEquals("Ltest0234/Test;.field)LList;", variableBinding.getKey()); //$NON-NLS-1$
}
/**
* Checking that null is returned for a resolveBinding if the type is unknown
*/
public void test0235() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0235", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("The fiels is not malformed", !isMalformed(node)); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("problems found", 0, unit.getMessages().length); //$NON-NLS-1$
assertEquals("problems found", 0, unit.getProblems().length); //$NON-NLS-1$
assertTrue("FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = fragment.resolveBinding();
assertNotNull("No binding", variableBinding); //$NON-NLS-1$
}
/**
* Test the removal of a IField inside a CU that has an initializer
*/
public void test0236() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0236", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
IType type = sourceUnit.getType("Test"); //$NON-NLS-1$
assertNotNull("No type", type); //$NON-NLS-1$
IField field = type.getField("i"); //$NON-NLS-1$
assertNotNull("No field", field); //$NON-NLS-1$
field.delete(true, null);
}
/**
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=9452
*/
public void test0237() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "junit.framework", "TestCase.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
}
/**
* Check ThisExpression
* @deprecated using deprecated code
*/
public void test0238() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0238", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
char[] source = sourceUnit.getSource().toCharArray();
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not a type declaration statement", node instanceof TypeDeclarationStatement); //$NON-NLS-1$
TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
TypeDeclaration typeDecl = typeDeclarationStatement.getTypeDeclaration();
Object o = typeDecl.bodyDeclarations().get(0);
assertTrue("Not a method", o instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDecl = (MethodDeclaration) o;
Block block = methodDecl.getBody();
List statements = block.statements();
assertEquals("Not 1", 1, statements.size()); //$NON-NLS-1$
Statement stmt = (Statement) statements.get(0);
assertTrue("Not a return statement", stmt instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) stmt;
Expression expr = returnStatement.getExpression();
assertTrue("Not a method invocation", expr instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expr;
checkSourceRange(methodInvocation, "Test.this.bar()", source); //$NON-NLS-1$
Expression qualifier = methodInvocation.getExpression();
assertTrue("Not a ThisExpression", qualifier instanceof ThisExpression); //$NON-NLS-1$
ThisExpression thisExpression = (ThisExpression) qualifier;
Name name = thisExpression.getQualifier();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("wrong name", "Test", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check ThisExpression
* @deprecated using deprecated code
*/
public void test0239() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0239", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 1, 0, 0);
assertTrue("Not a type declaration statement", node instanceof TypeDeclarationStatement); //$NON-NLS-1$
TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
TypeDeclaration typeDecl = typeDeclarationStatement.getTypeDeclaration();
Object o = typeDecl.bodyDeclarations().get(0);
assertTrue("Not a method", o instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDecl = (MethodDeclaration) o;
Block block = methodDecl.getBody();
List statements = block.statements();
assertEquals("Not 1", 1, statements.size()); //$NON-NLS-1$
Statement stmt = (Statement) statements.get(0);
assertTrue("Not a return statement", stmt instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) stmt;
Expression expr = returnStatement.getExpression();
assertTrue("Not a SuperMethodInvocation", expr instanceof SuperMethodInvocation); //$NON-NLS-1$
SuperMethodInvocation superMethodInvocation = (SuperMethodInvocation) expr;
Name name = superMethodInvocation.getQualifier();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("A type binding", binding instanceof ITypeBinding); //$NON-NLS-1$
assertEquals("Not Test", "Test", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Name methodName = superMethodInvocation.getName();
IBinding binding2 = methodName.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
assertTrue("No an IMethodBinding", binding2 instanceof IMethodBinding); //$NON-NLS-1$
IMethodBinding methodBinding = (IMethodBinding) binding2;
assertEquals("Not bar", "bar", methodBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not T", "T", methodBinding.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check FieldAccess
* @deprecated using deprecated code
*/
public void test0240() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0240", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not a type declaration statement", node instanceof TypeDeclarationStatement); //$NON-NLS-1$
TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
TypeDeclaration typeDecl = typeDeclarationStatement.getTypeDeclaration();
Object o = typeDecl.bodyDeclarations().get(0);
assertTrue("Not a method", o instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDecl = (MethodDeclaration) o;
Block block = methodDecl.getBody();
List statements = block.statements();
assertEquals("Not 1", 1, statements.size()); //$NON-NLS-1$
Statement stmt = (Statement) statements.get(0);
assertTrue("Not a return statement", stmt instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) stmt;
Expression expr = returnStatement.getExpression();
assertTrue("Not a field access", expr instanceof FieldAccess); //$NON-NLS-1$
FieldAccess fieldAccess = (FieldAccess) expr;
Expression qualifier = fieldAccess.getExpression();
assertTrue("Not a ThisExpression", qualifier instanceof ThisExpression); //$NON-NLS-1$
ThisExpression thisExpression = (ThisExpression) qualifier;
Name name = thisExpression.getQualifier();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Not Test", "Test", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Name fieldName = fieldAccess.getName();
IBinding binding2 = fieldName.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
assertEquals("Wrong name", "f", binding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong modifier", Modifier.PUBLIC, binding2.getModifiers()); //$NON-NLS-1$
ITypeBinding typeBinding = fieldName.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Not int", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check order of body declarations
*/
public void test0241() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0241", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0);
assertTrue("Not a type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
assertTrue("Not a declaration", ((TypeDeclaration) node).getName().isDeclaration()); //$NON-NLS-1$
assertEquals("Wrong size", 11, ((TypeDeclaration)node).bodyDeclarations().size()); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("Not a field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 1);
assertTrue("Not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 2);
assertTrue("Not a Type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 3);
assertTrue("Not a Type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 4);
assertTrue("Not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 5);
assertTrue("Not a field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 6);
assertTrue("Not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 7);
assertTrue("Not a field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 8);
assertTrue("Not a field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 9);
assertTrue("Not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
node = getASTNode((CompilationUnit) result, 0, 10);
assertTrue("Not a Type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
}
/**
* Check ThisExpression
* @deprecated using deprecated code
*/
public void test0242() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0242", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 1, 0, 0);
assertTrue("Not a type declaration statement", node instanceof TypeDeclarationStatement); //$NON-NLS-1$
TypeDeclarationStatement typeDeclarationStatement = (TypeDeclarationStatement) node;
TypeDeclaration typeDecl = typeDeclarationStatement.getTypeDeclaration();
Object o = typeDecl.bodyDeclarations().get(0);
assertTrue("Not a method", o instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDecl = (MethodDeclaration) o;
Block block = methodDecl.getBody();
List statements = block.statements();
assertEquals("Not 1", 1, statements.size()); //$NON-NLS-1$
Statement stmt = (Statement) statements.get(0);
assertTrue("Not a return statement", stmt instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) stmt;
Expression expr = returnStatement.getExpression();
assertTrue("Not a SuperFieldAccess", expr instanceof SuperFieldAccess); //$NON-NLS-1$
SuperFieldAccess superFieldAccess = (SuperFieldAccess) expr;
Name name = superFieldAccess.getQualifier();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("A type binding", binding instanceof ITypeBinding); //$NON-NLS-1$
assertEquals("Not Test", "Test", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Name fieldName = superFieldAccess.getName();
IBinding binding2 = fieldName.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
assertTrue("No an IVariableBinding", binding2 instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding2;
assertEquals("Not f", "f", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not T", "T", variableBinding.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding typeBinding2 = fieldName.resolveTypeBinding();
assertNotNull("No type binding", typeBinding2); //$NON-NLS-1$
assertEquals("Not int", "int", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check catch clause positions:
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10570
*/
public void test0243() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0243", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not a try statement", node instanceof TryStatement); //$NON-NLS-1$
TryStatement tryStatement = (TryStatement) node;
List catchClauses = tryStatement.catchClauses();
assertEquals("wrong size", 1, catchClauses.size()); //$NON-NLS-1$
CatchClause catchClause = (CatchClause) catchClauses.get(0);
checkSourceRange(catchClause, "catch (Exception e){m();}", source); //$NON-NLS-1$
}
/**
* Check catch clause positions:
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10570
*/
public void test0244() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0244", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not a try statement", node instanceof TryStatement); //$NON-NLS-1$
TryStatement tryStatement = (TryStatement) node;
List catchClauses = tryStatement.catchClauses();
assertEquals("wrong size", 2, catchClauses.size()); //$NON-NLS-1$
CatchClause catchClause = (CatchClause) catchClauses.get(0);
checkSourceRange(catchClause, "catch (RuntimeException e){m();}", source); //$NON-NLS-1$
catchClause = (CatchClause) catchClauses.get(1);
checkSourceRange(catchClause, "catch(Exception e) {}", source); //$NON-NLS-1$
}
/**
* http://bugs.eclipse.org/bugs/show_bug.cgi?id=10587
*/
public void test0245() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0245", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("Not a return statement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expr = returnStatement.getExpression();
assertTrue("not a name", expr instanceof Name); //$NON-NLS-1$
Name name = (Name) expr;
IBinding binding = name.resolveBinding();
assertTrue("Not a variable binding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertEquals("Not i", "i", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not int", "int", variableBinding.getType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
ASTNode declaringNode = unit.findDeclaringNode(variableBinding);
assertNotNull("No declaring node", declaringNode); //$NON-NLS-1$
assertTrue("Not a VariableDeclarationFragment", declaringNode instanceof VariableDeclarationFragment); //$NON-NLS-1$
}
/**
* Test binding resolution for import declaration
*/
public void test0246() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0246", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
List imports = unit.imports();
assertEquals("wrong imports size", 2, imports.size()); //$NON-NLS-1$
ImportDeclaration importDeclaration = (ImportDeclaration) imports.get(0);
assertTrue("Not on demand", importDeclaration.isOnDemand()); //$NON-NLS-1$
checkSourceRange(importDeclaration, "import java.util.*;", source); //$NON-NLS-1$
IBinding binding = importDeclaration.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.PACKAGE, binding.getKind()); //$NON-NLS-1$
assertEquals("Wrong name", "java.util", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
importDeclaration = (ImportDeclaration) imports.get(1);
assertTrue("On demand", !importDeclaration.isOnDemand()); //$NON-NLS-1$
checkSourceRange(importDeclaration, "import java.io.IOException;", source); //$NON-NLS-1$
binding = importDeclaration.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertEquals("Wrong name", "IOException", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Test binding resolution for import declaration
*/
public void test0247() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0247", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
PackageDeclaration packageDeclaration = unit.getPackage();
checkSourceRange(packageDeclaration, "package test0247;", source); //$NON-NLS-1$
IPackageBinding binding = packageDeclaration.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.PACKAGE, binding.getKind()); //$NON-NLS-1$
assertEquals("Wrong name", "test0247", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong modifier", Modifier.NONE, binding.getModifiers());
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10592
*/
public void test0248() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0248", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
List parameters = methodDeclaration.parameters();
assertEquals("wrong size", 1, parameters.size()); //$NON-NLS-1$
SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
Name name = singleVariableDeclaration.getName();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("Not a variable binding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertEquals("Wrong name", "i", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong type", "int", variableBinding.getType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10592
*/
public void test0249() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0249", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 2, 1);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression = expressionStatement.getExpression();
assertTrue("Not an assignment", expression instanceof Assignment); //$NON-NLS-1$
Assignment assignment = (Assignment) expression;
Expression leftHandSide = assignment.getLeftHandSide();
assertTrue("Not a qualified name", leftHandSide instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) leftHandSide;
Name simpleName = qualifiedName.getName();
IBinding binding = simpleName.resolveBinding();
assertNotNull("no binding", binding); //$NON-NLS-1$
assertTrue("Not a IVariableBinding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertEquals("Wrong name", "k", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong modifier", Modifier.STATIC, variableBinding.getModifiers()); //$NON-NLS-1$
assertEquals("Wrong type", "int", variableBinding.getType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong declaring class name", "j", variableBinding.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10592
*/
public void test0250() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0250", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
List parameters = methodDeclaration.parameters();
assertEquals("wrong size", 2, parameters.size()); //$NON-NLS-1$
SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
Name name = singleVariableDeclaration.getName();
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("Not a variable binding", binding instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertEquals("Wrong name", "i", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong type", "int", variableBinding.getType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check qualified name resolution for static fields
*/
public void test0251() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0251", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not a ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression = expressionStatement.getExpression();
assertTrue("Not a method invocation", expression instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expression;
checkSourceRange(methodInvocation, "java.lang.System.out.println()", source); //$NON-NLS-1$
Expression qualifier = methodInvocation.getExpression();
assertTrue("Not a qualified name", qualifier instanceof QualifiedName); //$NON-NLS-1$
checkSourceRange(qualifier, "java.lang.System.out", source); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) qualifier;
Name typeName = qualifiedName.getQualifier();
assertTrue("Not a QualifiedName", typeName instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedTypeName = (QualifiedName) typeName;
IBinding binding = qualifiedTypeName.getName().resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong name", "System", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
binding = qualifiedTypeName.getQualifier().resolveBinding();
assertNotNull("No binding2", binding); //$NON-NLS-1$
assertEquals("Wrong type binding", IBinding.PACKAGE, binding.getKind()); //$NON-NLS-1$
}
/**
* Check binding for anonymous class
*/
public void test0252() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0252", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 1);
assertTrue("Not a return statement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
assertTrue("Not a classinstancecreation", expression instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
IMethodBinding methodBinding = classInstanceCreation.resolveConstructorBinding();
assertNotNull("No methodBinding", methodBinding); //$NON-NLS-1$
assertTrue("Not a constructor", methodBinding.isConstructor()); //$NON-NLS-1$
assertTrue("Not an anonymous class", methodBinding.getDeclaringClass().isAnonymous()); //$NON-NLS-1$
assertEquals("Not an anonymous class of java.lang.Object", "Object", methodBinding.getDeclaringClass().getSuperclass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Not an anonymous class of java.lang.Object", "java.lang", methodBinding.getDeclaringClass().getSuperclass().getPackage().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check binding for allocation expression
*/
public void test0253() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0253", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not a return statement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
assertTrue("Not a classinstancecreation", expression instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
IMethodBinding methodBinding = classInstanceCreation.resolveConstructorBinding();
assertNotNull("No methodBinding", methodBinding); //$NON-NLS-1$
assertTrue("Not a constructor", methodBinding.isConstructor()); //$NON-NLS-1$
assertEquals("Wrong size", 1, methodBinding.getParameterTypes().length); //$NON-NLS-1$
assertEquals("Wrong type", "String", methodBinding.getParameterTypes()[0].getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check binding for allocation expression
*/
public void test0254() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0254", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 1, 0);
assertTrue("Not a return statement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
assertTrue("Not a class instance creation", expression instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
IMethodBinding binding = classInstanceCreation.resolveConstructorBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("wrong type", "C", binding.getDeclaringClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check binding for allocation expression
*/
public void test0255() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0255", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression = expressionStatement.getExpression();
assertTrue("Not a MethodInvocation", expression instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expression;
List arguments = methodInvocation.arguments();
assertEquals("wrong size", 1, arguments.size()); //$NON-NLS-1$
Expression expression2 = (Expression) arguments.get(0);
assertTrue("Not a CastExpression", expression2 instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression2;
Type type = castExpression.getType();
ITypeBinding binding = type.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("Not an array type", binding.isArray()); //$NON-NLS-1$
}
/**
* Check binding for allocation expression
*/
public void test0256() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0256", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression = expressionStatement.getExpression();
assertTrue("Not a MethodInvocation", expression instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expression;
List arguments = methodInvocation.arguments();
assertEquals("wrong size", 1, arguments.size()); //$NON-NLS-1$
Expression expression2 = (Expression) arguments.get(0);
assertTrue("Not a CastExpression", expression2 instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression2;
Type type = castExpression.getType();
assertTrue("Not a simple type", type.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
ITypeBinding binding = type.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("Not a class", binding.isClass()); //$NON-NLS-1$
Name name = simpleType.getName();
IBinding binding2 = name.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
assertEquals("Wrong type", "Object", binding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Check binding for allocation expression
*/
public void test0257() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0257", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression = expressionStatement.getExpression();
assertTrue("Not a MethodInvocation", expression instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expression;
List arguments = methodInvocation.arguments();
assertEquals("wrong size", 1, arguments.size()); //$NON-NLS-1$
Expression expression2 = (Expression) arguments.get(0);
assertTrue("Not a CastExpression", expression2 instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression2;
Type type = castExpression.getType();
assertTrue("Not a primitive type", type.isPrimitiveType()); //$NON-NLS-1$
PrimitiveType primitiveType = (PrimitiveType) type;
assertEquals("Not int", PrimitiveType.INT, primitiveType.getPrimitiveTypeCode()); //$NON-NLS-1$
}
/**
* Check binding for allocation expression
*/
public void test0258() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0258", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression = expressionStatement.getExpression();
assertTrue("Not a MethodInvocation", expression instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expression;
List arguments = methodInvocation.arguments();
assertEquals("wrong size", 1, arguments.size()); //$NON-NLS-1$
Expression expression2 = (Expression) arguments.get(0);
assertTrue("Not a CastExpression", expression2 instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression2;
Type type = castExpression.getType();
assertTrue("Not a simple type", type.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
ITypeBinding binding = type.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertTrue("Not a class", binding.isClass()); //$NON-NLS-1$
Name name = simpleType.getName();
IBinding binding2 = name.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
assertEquals("Wrong type", "Object", binding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10663
*/
public void test0259() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0259", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10592
*/
public void test0260() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0260", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
List parameters = methodDeclaration.parameters();
assertEquals("wrong size", 2, parameters.size()); //$NON-NLS-1$
SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
IBinding binding = singleVariableDeclaration.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
Name name = singleVariableDeclaration.getName();
assertTrue("Not a simple name", name instanceof SimpleName); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) name;
assertEquals("Wrong name", "i", simpleName.getIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding2 = name.resolveBinding();
assertNotNull("No binding", binding2); //$NON-NLS-1$
assertTrue("binding == binding2", binding == binding2); //$NON-NLS-1$
assertTrue("Not a variable binding", binding2 instanceof IVariableBinding); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding2;
assertEquals("Wrong name", "i", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong type", "int", variableBinding.getType().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10679
*/
public void test0261() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0261", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("Wrong msg size", 1, compilationUnit.getMessages().length); //$NON-NLS-1$
assertEquals("Wrong pb size", 1, compilationUnit.getProblems().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a return statement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
ITypeBinding binding = expression.resolveTypeBinding();
assertNull("got a binding", binding); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10676
*/
public void test0262() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0262", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expr = expressionStatement.getExpression();
assertTrue("Not a MethodInvocation", expr instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expr;
List arguments = methodInvocation.arguments();
assertEquals("Wrong argument list size", 1, arguments.size()); //$NON-NLS-1$
Expression expr2 = (Expression) arguments.get(0);
assertTrue("Not a class instance creation", expr2 instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expr2;
arguments = classInstanceCreation.arguments();
assertEquals("Wrong size", 1, arguments.size()); //$NON-NLS-1$
Expression expression2 = (Expression) arguments.get(0);
assertTrue("Not a string literal", expression2 instanceof StringLiteral); //$NON-NLS-1$
StringLiteral stringLiteral = (StringLiteral) expression2;
ITypeBinding typeBinding = stringLiteral.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "String", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10700
*/
public void test0263() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0263", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expr = expressionStatement.getExpression();
assertTrue("Not a MethodInvocation", expr instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expr;
List arguments = methodInvocation.arguments();
assertEquals("Wrong argument list size", 1, arguments.size()); //$NON-NLS-1$
Expression expr2 = (Expression) arguments.get(0);
assertTrue("Not a simple name", expr2 instanceof SimpleName); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) expr2;
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10699
*/
public void test0264() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0264", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("Wrong fragment size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a classinstancecreation", expression instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
assertNotNull("No anonymousclassdeclaration", anonymousClassDeclaration); //$NON-NLS-1$
String expectedSourceRange =
"{\n"+ //$NON-NLS-1$
" void m(int k){\n"+ //$NON-NLS-1$
" k= i;\n"+ //$NON-NLS-1$
" }\n"+ //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(anonymousClassDeclaration, expectedSourceRange, source);
List bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
assertEquals("Wrong size", 1, bodyDeclarations.size()); //$NON-NLS-1$
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
assertTrue("Not a method declaration", bodyDeclaration instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
assertEquals("Wrong name", "m", methodDeclaration.getName().getIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10698
*/
public void test0265() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0265", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
*/
public void test0266() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0266", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "Inner\\u005b]", source); //$NON-NLS-1$
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
Type type2 = arrayType.getElementType();
assertTrue("Not a simple type", type2.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type2;
checkSourceRange(simpleType, "Inner", source); //$NON-NLS-1$
Name name = simpleType.getName();
assertTrue("not a simple name", name.isSimpleName()); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) name;
checkSourceRange(simpleName, "Inner", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
*/
public void test0267() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0267", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "Inner[]", source); //$NON-NLS-1$
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
Type type2 = arrayType.getElementType();
assertTrue("Not a simple type", type2.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type2;
checkSourceRange(simpleType, "Inner", source); //$NON-NLS-1$
Name name = simpleType.getName();
assertTrue("not a simple name", name.isSimpleName()); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) name;
checkSourceRange(simpleName, "Inner", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
*/
public void test0268() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0268", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "test0268.Test.Inner[]", source); //$NON-NLS-1$
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
Type type2 = arrayType.getElementType();
assertTrue("Not a simple type", type2.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type2;
checkSourceRange(simpleType, "test0268.Test.Inner", source); //$NON-NLS-1$
Name name = simpleType.getName();
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(name, "test0268.Test.Inner", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
*/
public void test0269() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0269", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "test0269.Test.Inner[/**/]", source); //$NON-NLS-1$
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
Type type2 = arrayType.getElementType();
assertTrue("Not a simple type", type2.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type2;
checkSourceRange(simpleType, "test0269.Test.Inner", source); //$NON-NLS-1$
Name name = simpleType.getName();
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(name, "test0269.Test.Inner", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
*/
public void test0270() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0270", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "test0270.Test.Inner", source); //$NON-NLS-1$
assertTrue("Not a simple type", type.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
Name name = simpleType.getName();
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(name, "test0270.Test.Inner", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
*/
public void test0271() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0271", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "test0271.Test.Inner[]", source); //$NON-NLS-1$
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
Type type2 = arrayType.getElementType();
assertTrue("Not a simple type", type2.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type2;
checkSourceRange(simpleType, "test0271.Test.Inner", source); //$NON-NLS-1$
Name name = simpleType.getName();
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
checkSourceRange(name, "test0271.Test.Inner", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10843
*/
public void test0272() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0272", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a For statement", node instanceof ForStatement); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node;
checkSourceRange(forStatement, "for (int i= 0; i < 10; i++) foo();", source); //$NON-NLS-1$
Statement action = forStatement.getBody();
checkSourceRange(action, "foo();", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10843
*/
public void test0273() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0273", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a For statement", node instanceof ForStatement); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node;
checkSourceRange(forStatement, "for (int i= 0; i < 10; i++) { foo(); }", source); //$NON-NLS-1$
Statement action = forStatement.getBody();
checkSourceRange(action, "{ foo(); }", source); //$NON-NLS-1$
assertTrue("Not a block", action instanceof Block); //$NON-NLS-1$
Block block = (Block) action;
List statements = block.statements();
assertEquals("Wrong size", 1, statements.size()); //$NON-NLS-1$
Statement stmt = (Statement) statements.get(0);
checkSourceRange(stmt, "foo();", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10843
*/
public void test0274() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0274", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertTrue("Not a While statement", node instanceof WhileStatement); //$NON-NLS-1$
WhileStatement whileStatement = (WhileStatement) node;
checkSourceRange(whileStatement, "while (i < 10) { foo(i++); }", source); //$NON-NLS-1$
Statement action = whileStatement.getBody();
checkSourceRange(action, "{ foo(i++); }", source); //$NON-NLS-1$
assertTrue("Not a block", action instanceof Block); //$NON-NLS-1$
Block block = (Block) action;
List statements = block.statements();
assertEquals("Wrong size", 1, statements.size()); //$NON-NLS-1$
Statement stmt = (Statement) statements.get(0);
checkSourceRange(stmt, "foo(i++);", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10843
*/
public void test0275() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0275", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertTrue("Not a While statement", node instanceof WhileStatement); //$NON-NLS-1$
WhileStatement whileStatement = (WhileStatement) node;
checkSourceRange(whileStatement, "while (i < 10) foo(i++);", source); //$NON-NLS-1$
Statement action = whileStatement.getBody();
checkSourceRange(action, "foo(i++);", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10798
*/
public void test0276() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0276", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
String expectedSource =
"public void foo() {\n" + //$NON-NLS-1$
" foo();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(methodDeclaration, expectedSource, source);
expectedSource =
"{\n" + //$NON-NLS-1$
" foo();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(methodDeclaration.getBody(), expectedSource, source);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10798
*/
public void test0277() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0277", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
String expectedSource =
"public void foo() {\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(methodDeclaration, expectedSource, source);
expectedSource =
"{\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(methodDeclaration.getBody(), expectedSource, source);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10861
*/
public void test0278() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0278", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "Class c = java.lang.String.class;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a type literal", expression instanceof TypeLiteral); //$NON-NLS-1$
ITypeBinding typeBinding = expression.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Class", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10861
*/
public void test0279() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0279", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0,0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
checkSourceRange(variableDeclarationStatement, "Class c = java.lang.String.class;", source); //$NON-NLS-1$
List fragments = variableDeclarationStatement.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a type literal", expression instanceof TypeLiteral); //$NON-NLS-1$
ITypeBinding typeBinding = expression.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Class", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10865
* Check well known types
*/
public void test0280() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0280", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
AST newAst = result.getAST();
ITypeBinding typeBinding = newAst.resolveWellKnownType("boolean"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "boolean", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("char"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "char", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("byte"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "byte", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("short"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "short", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("int"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("long"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "long", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("float"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "float", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("double"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "double", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("void"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "void", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Object", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.String"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "String", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.StringBuffer"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "StringBuffer", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.Throwable"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Throwable", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.Exception"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Exception", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.RuntimeException"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "RuntimeException", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.Error"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Error", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.Class"); //$NON-NLS-1$
assertNotNull("No typeBinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Class", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
typeBinding = newAst.resolveWellKnownType("java.lang.Runnable"); //$NON-NLS-1$
assertNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Cloneable"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.io.Serializable"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Boolean"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Byte"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Character"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Double"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Float"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Integer"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Long"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Short"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
typeBinding = newAst.resolveWellKnownType("java.lang.Void"); //$NON-NLS-1$
assertNotNull("typeBinding not null", typeBinding); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0281() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0281", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "Object o= /*]*/new Object()/*[*/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "new Object()", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0282() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0282", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "boolean b = /*]*/true/*[*/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "true", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0283() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0283", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "char c = /*]*/'c'/*[*/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "'c'", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0284() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0284", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "Object o = /*]*/null/*[*/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "null", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0285() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0285", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "Object o = /*]*/Object.class/*[*/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "Object.class", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0286() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0286", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "int i = /**/(2)/**/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "(2)", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0287() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0287", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "String[] tab = /**/new String[3]/**/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "new String[3]", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0288() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0288", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "String[] tab = /**/{ }/**/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "{ }", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0289() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0289", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "String s = /**/tab1[0]/**/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "tab1[0]", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
*/
public void test0290() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0290", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "Object o = /*]*/new java.lang.Object()/*[*/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "new java.lang.Object()", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10898
*/
public void test0291() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0291", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("no errors", 1, unit.getMessages().length); //$NON-NLS-1$
assertEquals("no errors", 1, unit.getProblems().length); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10913
*/
public void test0292() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0292", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a return statement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
assertTrue("Not a qualifiedName", expression instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) expression;
SimpleName simpleName = qualifiedName.getName();
assertEquals("Wrong name", "x", simpleName.getIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding = simpleName.resolveBinding();
assertNotNull("NO binding", binding); //$NON-NLS-1$
assertTrue("Not a variable binding", binding instanceof IVariableBinding); //$NON-NLS-1$
assertEquals("wrong name", "x", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Name name = qualifiedName.getQualifier();
assertTrue("Not a simpleName", name instanceof SimpleName); //$NON-NLS-1$
SimpleName simpleName2 = (SimpleName) name;
IBinding binding2 = simpleName2.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
assertTrue("Not a type binding", binding2 instanceof ITypeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Test", binding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10933
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10935
*/
public void test0293() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0293", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a class instance creation", expression instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
assertNotNull("No body", anonymousClassDeclaration); //$NON-NLS-1$
String expectedSource =
"{\n" + //$NON-NLS-1$
" public void run() {\n" + //$NON-NLS-1$
" /*]*/foo();/*[*/\n" + //$NON-NLS-1$
" }\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(anonymousClassDeclaration, expectedSource, source);
expectedSource =
"run= new Runnable() {\n" + //$NON-NLS-1$
" public void run() {\n" + //$NON-NLS-1$
" /*]*/foo();/*[*/\n" + //$NON-NLS-1$
" }\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(variableDeclarationFragment, expectedSource, source);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10984
*/
public void test0294() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0294", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
String expectedSource =
"public void fails() {\n" + //$NON-NLS-1$
" foo()\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(methodDeclaration, expectedSource, source);
Block block = methodDeclaration.getBody();
expectedSource =
"{\n" + //$NON-NLS-1$
" foo()\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(block, expectedSource, source);
node = getASTNode(compilationUnit, 0, 1);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
methodDeclaration = (MethodDeclaration) node;
block = methodDeclaration.getBody();
List statements = block.statements();
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10986
*/
public void test0295() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0295", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("Wrong size", 2, compilationUnit.getMessages().length); //$NON-NLS-1$
assertEquals("Wrong size", 2, compilationUnit.getProblems().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression = expressionStatement.getExpression();
assertTrue("not a method invocation", expression instanceof MethodInvocation); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expression;
ITypeBinding typeBinding = methodInvocation.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("LList;", typeBinding.getKey());
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10984
*/
public void test0296() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0296", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
String expectedSource =
"public void fails() {\n" + //$NON-NLS-1$
" foo()\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(methodDeclaration, expectedSource, source);
Block block = methodDeclaration.getBody();
expectedSource =
"{\n" + //$NON-NLS-1$
" foo()\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(block, expectedSource, source);
node = getASTNode(compilationUnit, 0, 1);
assertTrue("Not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
methodDeclaration = (MethodDeclaration) node;
block = methodDeclaration.getBody();
List statements = block.statements();
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11037
*/
public void test0297() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0297", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
runConversion(sourceUnit, false);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10984
*/
public void test0298() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0298", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a ReturnStatement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
checkSourceRange(expression, "a().length != 3", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11104
*/
public void test0299() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0299", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "int i = (/**/2/**/);", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a parenthesized expression", expression instanceof ParenthesizedExpression); //$NON-NLS-1$
ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) expression;
Expression expression2 = parenthesizedExpression.getExpression();
checkSourceRange(expression2, "2", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11104
*/
public void test0300() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0300", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "boolean b = /**/true/**/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "true", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=10874
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11104
*/
public void test0301() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0301", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a Field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
checkSourceRange(fieldDeclaration, "Object o = /**/null/**/;", source); //$NON-NLS-1$
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
checkSourceRange(expression, "null", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11106
*/
public void test0302() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0302", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a DoStatement", node instanceof DoStatement); //$NON-NLS-1$
DoStatement doStatement = (DoStatement) node;
String expectedSource =
"do\n" + //$NON-NLS-1$
" foo();\n" + //$NON-NLS-1$
" while(1 < 10);"; //$NON-NLS-1$
checkSourceRange(doStatement, expectedSource, source);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11129
*/
public void test0303() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0303", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression2 = expressionStatement.getExpression();
assertTrue("Not an Assignement", expression2 instanceof Assignment); //$NON-NLS-1$
Assignment assignment = (Assignment) expression2;
Expression expression = assignment.getRightHandSide();
assertTrue("Not a CastExpression", expression instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression;
ITypeBinding typeBinding = castExpression.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "char", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type type = castExpression.getType();
ITypeBinding typeBinding2 = type.resolveBinding();
assertNotNull("No binding2", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong name", "char", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11151
*/
public void test0304() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0304", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
checkSourceRange(node, "public void foo(int arg);", source); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Block block = methodDeclaration.getBody();
assertNull("Has a body", block); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11125
*/
public void test0305() {
char[] source =
("package test0305;\n" + //$NON-NLS-1$
"\n" + //$NON-NLS-1$
"class Test {\n" + //$NON-NLS-1$
" public void foo(int arg) {}\n" + //$NON-NLS-1$
"}").toCharArray(); //$NON-NLS-1$
IJavaProject project = getJavaProject("Converter"); //$NON-NLS-1$
ASTNode result = runConversion(source, "Test.java", project, true); //$NON-NLS-1$
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0);
assertTrue("not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Test", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong package", "test0305", typeBinding.getPackage().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Not an interface", typeBinding.isClass()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11125
*/
public void test0306() {
char[] source =
("package java.lang;\n" + //$NON-NLS-1$
"\n" + //$NON-NLS-1$
"class Object {\n" + //$NON-NLS-1$
" public void foo(int arg) {}\n" + //$NON-NLS-1$
"}").toCharArray(); //$NON-NLS-1$
IJavaProject project = getJavaProject("Converter"); //$NON-NLS-1$
ASTNode result = runConversion(source, "Object.java", project, true); //$NON-NLS-1$
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0);
assertTrue("not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Object", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong package", "java.lang", typeBinding.getPackage().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Not an interface", typeBinding.isClass()); //$NON-NLS-1$
assertEquals("Wrong size", 2, typeBinding.getDeclaredMethods().length); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11371
*/
public void test0307() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0307", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Block block = methodDeclaration.getBody();
assertNotNull("No body", block); //$NON-NLS-1$
List statements = block.statements();
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$
Statement statement = (Statement) statements.get(0);
assertTrue("Not a super constructor invocation", statement instanceof SuperConstructorInvocation); //$NON-NLS-1$
checkSourceRange(statement, "super(10);", source);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11371
*/
public void test0308() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0308", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("not a method declaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Block block = methodDeclaration.getBody();
assertNotNull("No body", block); //$NON-NLS-1$
List statements = block.statements();
assertEquals("wrong size", 1, statements.size()); //$NON-NLS-1$
Statement statement = (Statement) statements.get(0);
assertTrue("Not a super constructor invocation", statement instanceof SuperConstructorInvocation); //$NON-NLS-1$
SuperConstructorInvocation superConstructorInvocation = (SuperConstructorInvocation) statement;
IMethodBinding methodBinding = superConstructorInvocation.resolveConstructorBinding();
assertNotNull("No methodBinding", methodBinding); //$NON-NLS-1$
IMethodBinding methodBinding2 = methodDeclaration.resolveBinding();
assertNotNull("No methodBinding2", methodBinding2); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11380
*/
public void test0309() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0309", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a conditional expression", expression instanceof ConditionalExpression); //$NON-NLS-1$
ConditionalExpression conditionalExpression = (ConditionalExpression) expression;
ITypeBinding typeBinding = conditionalExpression.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong name", "int", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11380
*/
public void test0310() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0310", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a qualified name", expression instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) expression;
Name qualifier = qualifiedName.getQualifier();
IBinding binding = qualifier.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("wrong name", "I", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11638
*/
public void test0311() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0311", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("not a class instance creation", expression instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
assertNotNull("No body", anonymousClassDeclaration); //$NON-NLS-1$
List bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
assertEquals("wrong size for body declarations", 1, bodyDeclarations.size()); //$NON-NLS-1$
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
assertTrue("Not a method declaration", bodyDeclaration instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
Block block = methodDeclaration.getBody();
assertNotNull("no body", block); //$NON-NLS-1$
List statements = block.statements();
assertEquals("Wrong size for statements", 1, statements.size()); //$NON-NLS-1$
Statement statement = (Statement) statements.get(0);
assertTrue("not a variable declaration statement", statement instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement2 = (VariableDeclarationStatement) statement;
List fragments2 = variableDeclarationStatement2.fragments();
assertEquals("wrong size for fragments2", 1, fragments2.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment2 = (VariableDeclarationFragment) fragments2.get(0);
Expression expression2 = variableDeclarationFragment2.getInitializer();
assertTrue("Not a name", expression2 instanceof Name); //$NON-NLS-1$
Name name = (Name) expression2;
checkSourceRange(name, "j", source); //$NON-NLS-1$
IBinding binding = name.resolveBinding();
ASTNode declaringNode = compilationUnit.findDeclaringNode(binding);
assertNotNull("No declaring node", declaringNode); //$NON-NLS-1$
checkSourceRange(declaringNode, "int j", source); //$NON-NLS-1$
assertTrue("Not a single variable declaration", declaringNode instanceof SingleVariableDeclaration); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11638
* There is a error in this source. A is unresolved. Then there is no
* declaring node.
*/
public void test0312() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0312", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("not a class instance creation", expression instanceof ClassInstanceCreation); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation = (ClassInstanceCreation) expression;
AnonymousClassDeclaration anonymousClassDeclaration = classInstanceCreation.getAnonymousClassDeclaration();
assertNotNull("No body", anonymousClassDeclaration); //$NON-NLS-1$
List bodyDeclarations = anonymousClassDeclaration.bodyDeclarations();
assertEquals("wrong size for body declarations", 1, bodyDeclarations.size()); //$NON-NLS-1$
BodyDeclaration bodyDeclaration = (BodyDeclaration) bodyDeclarations.get(0);
assertTrue("Not a method declaration", bodyDeclaration instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
Block block = methodDeclaration.getBody();
assertNotNull("no body", block); //$NON-NLS-1$
List statements = block.statements();
assertEquals("Wrong size for statements", 1, statements.size()); //$NON-NLS-1$
Statement statement = (Statement) statements.get(0);
assertTrue("not a variable declaration statement", statement instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement2 = (VariableDeclarationStatement) statement;
List fragments2 = variableDeclarationStatement2.fragments();
assertEquals("wrong size for fragments2", 1, fragments2.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment2 = (VariableDeclarationFragment) fragments2.get(0);
Expression expression2 = variableDeclarationFragment2.getInitializer();
assertTrue("Not a name", expression2 instanceof Name); //$NON-NLS-1$
Name name = (Name) expression2;
checkSourceRange(name, "j", source); //$NON-NLS-1$
IBinding binding = name.resolveBinding();
ASTNode declaringNode = compilationUnit.findDeclaringNode(binding);
assertNull("No declaring node is available", declaringNode); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11659
*/
public void test0313() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0313", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not an InfixExpression", expression instanceof InfixExpression); //$NON-NLS-1$
InfixExpression infixExpression = (InfixExpression) expression;
checkSourceRange(infixExpression, "i+j", source); //$NON-NLS-1$
Expression expression2 = infixExpression.getLeftOperand();
checkSourceRange(expression2, "i", source); //$NON-NLS-1$
assertTrue("Not a name", expression2 instanceof Name); //$NON-NLS-1$
Name name = (Name) expression2;
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
ASTNode astNode = compilationUnit.findDeclaringNode(binding);
assertNotNull("No declaring node", astNode); //$NON-NLS-1$
checkSourceRange(astNode, "int i", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=12326
*/
public void test0314() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0314", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
assertNotNull("No result", result); //$NON-NLS-1$
assertTrue("Not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("Wrong line number", 1, compilationUnit.getLineNumber(0)); //$NON-NLS-1$
// ensure that last character is on the last line
assertEquals("Wrong line number", 3, compilationUnit.getLineNumber(source.length - 1)); //$NON-NLS-1$
// source.length is beyond the size of the compilation unit source
assertEquals("Wrong line number", -1, compilationUnit.getLineNumber(source.length)); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=12326
*/
public void test0315() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0315", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a Return statement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
assertTrue("Not an instanceof expression", expression instanceof InstanceofExpression); //$NON-NLS-1$
InstanceofExpression instanceOfExpression = (InstanceofExpression) expression;
Type rightOperand = instanceOfExpression.getRightOperand();
assertTrue("Not a simpleType", rightOperand instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) rightOperand;
Name n = simpleType.getName();
assertTrue("Not a qualified name", n instanceof QualifiedName); //$NON-NLS-1$
QualifiedName name = (QualifiedName) n;
checkSourceRange(name, "java.io.Serializable", source); //$NON-NLS-1$
ITypeBinding typeBinding = name.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Serializable", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Name qualifier = name.getQualifier();
assertTrue("Not a qualified name", qualifier instanceof QualifiedName); //$NON-NLS-1$
ITypeBinding typeBinding2 = qualifier.resolveTypeBinding();
assertNull("typebinding2 is not null", typeBinding2); //$NON-NLS-1$
IBinding binding = qualifier.resolveBinding();
assertNotNull("no binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.PACKAGE, binding.getKind()); //$NON-NLS-1$
IPackageBinding pBinding = (IPackageBinding) binding;
assertEquals("Wrong name", "java.io", pBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=12454
*/
public void test0316() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "", "Hello.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No result", result); //$NON-NLS-1$
assertTrue("Not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("Wrong size", 1, compilationUnit.getMessages().length); //$NON-NLS-1$
assertEquals("Wrong size", 1, compilationUnit.getProblems().length); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=12781
*/
public void test0317() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0317", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a return statement", node instanceof ReturnStatement); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
assertTrue("not an instanceof expression", expression instanceof InstanceofExpression); //$NON-NLS-1$
InstanceofExpression instanceOfExpression = (InstanceofExpression) expression;
Expression left = instanceOfExpression.getLeftOperand();
assertTrue("Not a Name", left instanceof Name); //$NON-NLS-1$
Name name = (Name) left;
IBinding binding = name.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("wrong name", "x", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding typeBinding = name.resolveTypeBinding();
assertNotNull("No typebinding", typeBinding); //$NON-NLS-1$
assertEquals("wrong type", "Object", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type right = instanceOfExpression.getRightOperand();
assertTrue("Not a simpleType", right instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) right;
name = simpleType.getName();
assertTrue("Not a simpleName", name instanceof SimpleName); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) name;
IBinding binding2 = simpleName.resolveBinding();
assertNotNull("No binding2", binding2); //$NON-NLS-1$
assertEquals("Wrong name", "Vector", binding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding typeBinding2 = simpleName.resolveTypeBinding();
assertNotNull("No typeBinding2", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong name", "Vector", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13233
*/
public void test0318() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0318", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit unit = (CompilationUnit) result;
assertEquals("No error", 1, unit.getMessages().length); //$NON-NLS-1$
assertEquals("No error", 1, unit.getProblems().length); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
*/
public void test0319() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0319", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not an array creation", expression instanceof ArrayCreation); //$NON-NLS-1$
ArrayCreation arrayCreation = (ArrayCreation) expression;
ITypeBinding typeBinding = arrayCreation.resolveTypeBinding();
assertNotNull("no type binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ArrayType arrayType = arrayCreation.getType();
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
ITypeBinding typeBinding3 = simpleType.resolveBinding();
assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
*/
public void test0320() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0320", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "int[]", source); //$NON-NLS-1$
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
ITypeBinding typeBinding = arrayType.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
Type elementType = arrayType.getElementType();
assertTrue("Not a simple type", elementType.isPrimitiveType()); //$NON-NLS-1$
ITypeBinding typeBinding2 = elementType.resolveBinding();
assertNotNull("No type binding2", typeBinding2); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
*/
public void test0321() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0321", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
ITypeBinding typeBinding = arrayType.resolveBinding();
checkSourceRange(type, "java.lang.Object[][]", source); //$NON-NLS-1$
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
Type elementType = arrayType.getComponentType();
ITypeBinding typeBinding2 = elementType.resolveBinding();
assertNotNull("No type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong dimension", 1, typeBinding2.getDimensions()); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Not an array type", elementType.isArrayType()); //$NON-NLS-1$
Type elementType2 = ((ArrayType) elementType).getComponentType();
assertTrue("Not a simple type", elementType2.isSimpleType()); //$NON-NLS-1$
ITypeBinding typeBinding3 = elementType2.resolveBinding();
assertNotNull("No type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong dimension", 0, typeBinding3.getDimensions()); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13231
*/
public void test0322() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0322", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a FieldDeclaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a null literal", expression instanceof NullLiteral); //$NON-NLS-1$
NullLiteral nullLiteral = (NullLiteral) expression;
ITypeBinding typeBinding = nullLiteral.resolveTypeBinding();
assertNotNull("no type binding", typeBinding); //$NON-NLS-1$
assertTrue("Not the null type", typeBinding.isNullType()); //$NON-NLS-1$
assertEquals("Wrong qualified name", typeBinding.getQualifiedName(), "null"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14198
*/
public void test0323() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0323", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression2 = expressionStatement.getExpression();
assertTrue("Not an Assignement", expression2 instanceof Assignment); //$NON-NLS-1$
Assignment assignment = (Assignment) expression2;
Expression expression = assignment.getRightHandSide();
assertTrue("Not a CastExpression", expression instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression;
ITypeBinding typeBinding = castExpression.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Object", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type type = castExpression.getType();
ITypeBinding typeBinding2 = type.resolveBinding();
assertNotNull("No binding2", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong name", "Object", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14198
*/
public void test0324() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0324", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression2 = expressionStatement.getExpression();
assertTrue("Not an Assignement", expression2 instanceof Assignment); //$NON-NLS-1$
Assignment assignment = (Assignment) expression2;
Expression expression = assignment.getRightHandSide();
assertTrue("Not a CastExpression", expression instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression;
ITypeBinding typeBinding = castExpression.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "Object[]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type type = castExpression.getType();
ITypeBinding typeBinding2 = type.resolveBinding();
assertNotNull("No binding2", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong name", "Object[]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14198
*/
public void test0325() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0325", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression2 = expressionStatement.getExpression();
assertTrue("Not an Assignement", expression2 instanceof Assignment); //$NON-NLS-1$
Assignment assignment = (Assignment) expression2;
Expression expression = assignment.getRightHandSide();
assertTrue("Not a CastExpression", expression instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression;
ITypeBinding typeBinding = castExpression.resolveTypeBinding();
assertNotNull("No binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "int[]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type type = castExpression.getType();
ITypeBinding typeBinding2 = type.resolveBinding();
assertNotNull("No binding2", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong name", "int[]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14217
*/
public void test0326() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0326", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
char[] source = sourceUnit.getSource().toCharArray();
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertTrue("Not an ExpressionStatement", node instanceof ExpressionStatement); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
checkSourceRange(expressionStatement.getExpression(), "a().f= a()", source); //$NON-NLS-1$
checkSourceRange(expressionStatement, "a().f= a();", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14198
*/
public void test0327() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0327", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("Wrong number of errors", 2, compilationUnit.getProblems().length); //$NON-NLS-1$<
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not an VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a CastExpression", expression instanceof CastExpression); //$NON-NLS-1$
CastExpression castExpression = (CastExpression) expression;
ITypeBinding typeBinding = castExpression.resolveTypeBinding();
assertNotNull("No typebinding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong name", "String", typeBinding.getName());
Type type = castExpression.getType();
ITypeBinding typeBinding2 = type.resolveBinding();
assertNotNull("No binding2", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong name", "String", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
*/
public void test0328() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0328", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "java.lang.Object[]", source); //$NON-NLS-1$
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
ITypeBinding typeBinding = arrayType.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type elementType = arrayType.getElementType();
assertTrue("Not a simple type", elementType.isSimpleType()); //$NON-NLS-1$
ITypeBinding typeBinding2 = elementType.resolveBinding();
assertNotNull("No type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a array creation", expression instanceof ArrayCreation); //$NON-NLS-1$
ITypeBinding typeBinding3 = expression.resolveTypeBinding();
assertNotNull("No typeBinding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ArrayCreation arrayCreation = (ArrayCreation) expression;
ArrayInitializer arrayInitializer = arrayCreation.getInitializer();
assertNotNull("not array initializer", arrayInitializer); //$NON-NLS-1$
ITypeBinding typeBinding4 = arrayInitializer.resolveTypeBinding();
assertNotNull("No typeBinding4", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
*/
public void test0329() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0329", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "java.lang.Object[]", source); //$NON-NLS-1$
assertTrue("Not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
ITypeBinding typeBinding = arrayType.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type elementType = arrayType.getElementType();
assertTrue("Not a simple type", elementType.isSimpleType()); //$NON-NLS-1$
ITypeBinding typeBinding2 = elementType.resolveBinding();
assertNotNull("No type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a array creation", expression instanceof ArrayCreation); //$NON-NLS-1$
ITypeBinding typeBinding3 = expression.resolveTypeBinding();
assertNotNull("No typeBinding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ArrayCreation arrayCreation = (ArrayCreation) expression;
ArrayInitializer arrayInitializer = arrayCreation.getInitializer();
assertNotNull("not array initializer", arrayInitializer); //$NON-NLS-1$
ITypeBinding typeBinding4 = arrayInitializer.resolveTypeBinding();
assertNotNull("No typeBinding4", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14313
*/
public void test0330() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0330", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("wrong size", 2, compilationUnit.getMessages().length); //$NON-NLS-1$
assertEquals("wrong size", 2, compilationUnit.getProblems().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0);
assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("no type binding", typeBinding); //$NON-NLS-1$
IMethodBinding[] methods = typeBinding.getDeclaredMethods();
assertEquals("wrong size", 1, methods.length); //$NON-NLS-1$
assertTrue("not a constructor", methods[0].isConstructor()); //$NON-NLS-1$
assertTrue("wrong name", !methods[0].getName().equals("foo")); //$NON-NLS-1$ //$NON-NLS-2$
node = getASTNode(compilationUnit, 0, 0);
assertTrue("Not a methodDeclaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
IMethodBinding methodBinding = methodDeclaration.resolveBinding();
assertNull("method binding not null", methodBinding); //$NON-NLS-1$
node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a return statement", node.getNodeType() == ASTNode.RETURN_STATEMENT); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
ITypeBinding typeBinding2 = expression.resolveTypeBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14322
*/
public void test0331() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0331", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not an VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a QualifiedName", expression instanceof QualifiedName); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) expression;
IBinding binding = qualifiedName.getName().resolveBinding();
assertNotNull("no binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.VARIABLE, binding.getKind()); //$NON-NLS-1$
IVariableBinding variableBinding = (IVariableBinding) binding;
assertTrue("Not a field", variableBinding.isField()); //$NON-NLS-1$
assertNull("Got a declaring class", variableBinding.getDeclaringClass()); //$NON-NLS-1$
assertEquals("wrong name", "length", variableBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14403
*/
public void test0332() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0332", "LocalSelectionTransfer.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
*/
public void test0333() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0333", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not an array creation", expression instanceof ArrayCreation); //$NON-NLS-1$
ArrayCreation arrayCreation = (ArrayCreation) expression;
ITypeBinding typeBinding = arrayCreation.resolveTypeBinding();
assertNotNull("no type binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong name", "Object[][]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ArrayType arrayType = arrayCreation.getType();
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[][]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
ITypeBinding typeBinding3 = simpleType.resolveBinding();
assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
type = arrayType.getComponentType();
assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
ArrayType arrayType2 = (ArrayType) type;
ITypeBinding typeBinding4 = arrayType2.resolveBinding();
assertNotNull("no type binding4", typeBinding4); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=13807
*/
public void test0334() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0334", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertTrue("Not a VariableDeclarationStatement", node instanceof VariableDeclarationStatement); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not an array creation", expression instanceof ArrayCreation); //$NON-NLS-1$
ArrayCreation arrayCreation = (ArrayCreation) expression;
ITypeBinding typeBinding = arrayCreation.resolveTypeBinding();
assertNotNull("no type binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong name", "Object[][][]", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ArrayType arrayType = arrayCreation.getType();
checkSourceRange(arrayType, "Object[10][][]", source); //$NON-NLS-1$
ITypeBinding typeBinding2 = arrayType.resolveBinding();
assertNotNull("no type binding2", typeBinding2); //$NON-NLS-1$
assertEquals("wrong name", "Object[][][]", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type instanceof SimpleType); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
checkSourceRange(simpleType, "Object", source); //$NON-NLS-1$
ITypeBinding typeBinding3 = simpleType.resolveBinding();
assertNotNull("no type binding3", typeBinding3); //$NON-NLS-1$
assertEquals("wrong name", "Object", typeBinding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
type = arrayType.getComponentType();
assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
ArrayType arrayType2 = (ArrayType) type;
checkSourceRange(arrayType2, "Object[10][]", source); //$NON-NLS-1$
ITypeBinding typeBinding4 = arrayType2.resolveBinding();
assertNotNull("no type binding4", typeBinding4); //$NON-NLS-1$
assertEquals("wrong name", "Object[][]", typeBinding4.getName()); //$NON-NLS-1$ //$NON-NLS-2$
type = arrayType2.getComponentType();
assertTrue("Not an array type", type instanceof ArrayType); //$NON-NLS-1$
ArrayType arrayType3 = (ArrayType) type;
ITypeBinding typeBinding5 = arrayType3.resolveBinding();
assertNotNull("no type binding5", typeBinding5); //$NON-NLS-1$
assertEquals("wrong name", "Object[]", typeBinding5.getName()); //$NON-NLS-1$ //$NON-NLS-2$
checkSourceRange(arrayType3, "Object[10]", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14526
* @deprecated using deprecated code
*/
public void test0335() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0335", "ExceptionTestCaseTest.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0);
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
assertEquals("errors found", 0, compilationUnit.getProblems().length); //$NON-NLS-1$
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
Name name = typeDeclaration.getSuperclass();
assertNotNull("no super class", name); //$NON-NLS-1$
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) name;
name = qualifiedName.getQualifier();
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
qualifiedName = (QualifiedName) name;
name = qualifiedName.getQualifier();
assertTrue("not a simple name", name.isSimpleName()); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) name;
IBinding binding = simpleName.resolveBinding();
assertNotNull("no binding", binding); //$NON-NLS-1$
assertEquals("wrong type", IBinding.PACKAGE, binding.getKind()); //$NON-NLS-1$
assertEquals("wrong name", "junit", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14526
* @deprecated using deprecated code
*/
public void test0336() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0336", "SorterTest.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
assertEquals("errors found", 0, compilationUnit.getProblems().length); //$NON-NLS-1$
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
List superInterfaces = typeDeclaration.superInterfaces();
assertEquals("wrong size", 1, superInterfaces.size()); //$NON-NLS-1$
Name name = (Name) superInterfaces.get(0);
assertTrue("not a qualified name", name.isQualifiedName()); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) name;
name = qualifiedName.getQualifier();
assertTrue("not a simple name", name.isSimpleName()); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) name;
IBinding binding = simpleName.resolveBinding();
assertNotNull("no binding", binding); //$NON-NLS-1$
assertEquals("wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertEquals("wrong name", "Sorter", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14602
*/
public void test0337() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0337", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a field declaration", node instanceof FieldDeclaration); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
List fragments = fieldDeclaration.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
checkSourceRange(variableDeclarationFragment, "message= Test.m(\"s\", new String[]{\"g\"})", source); //$NON-NLS-1$
checkSourceRange(fieldDeclaration, "String message= Test.m(\"s\", new String[]{\"g\"});", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14852
*/
public void test0338() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0338", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
List thrownExceptions = methodDeclaration.thrownExceptions();
assertEquals("Wrong size", 1, thrownExceptions.size()); //$NON-NLS-1$
Name name = (Name) thrownExceptions.get(0);
IBinding binding = name.resolveBinding();
assertEquals("wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertEquals("wrong name", "IOException", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=15061
*/
public void test0339() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0339", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("No errors found", 3, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a Type declaration", node instanceof TypeDeclaration); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
List bodyDeclarations = typeDeclaration.bodyDeclarations();
assertEquals("wrong size", 1, bodyDeclarations.size()); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclarations.get(0);
checkSourceRange(methodDeclaration, "int doQuery(boolean x);", source); //$NON-NLS-1$
node = getASTNode(compilationUnit, 0, 1);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a MethodDeclaration", node instanceof MethodDeclaration); //$NON-NLS-1$
String expectedSource =
"public void setX(boolean x) {\n" + //$NON-NLS-1$
" {\n" + //$NON-NLS-1$
" z\n" + //$NON-NLS-1$
" }\n" + //$NON-NLS-1$
"}"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
int methodEndPosition = node.getStartPosition() + node.getLength();
node = getASTNode(compilationUnit, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("not a TypeDeclaration", node instanceof TypeDeclaration); //$NON-NLS-1$
int typeEndPosition = node.getStartPosition() + node.getLength();
assertEquals("different positions", methodEndPosition, typeEndPosition); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=14852
*/
public void test0340() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "p3", "B.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an expression statement", node.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$
ExpressionStatement expressionStatement = (ExpressionStatement) node;
Expression expression = expressionStatement.getExpression();
assertTrue("Not an method invocation", expression.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expression;
Expression expression2 = methodInvocation.getExpression();
assertNotNull("No receiver", expression2); //$NON-NLS-1$
ITypeBinding binding = expression2.resolveTypeBinding();
assertNotNull("No type binding", binding); //$NON-NLS-1$
assertEquals("wrong name", "A", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong name", "p2", binding.getPackage().getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue("Not a qualified name", expression2.getNodeType() == ASTNode.QUALIFIED_NAME); //$NON-NLS-1$
QualifiedName qualifiedName = (QualifiedName) expression2;
SimpleName simpleName = qualifiedName.getName();
assertEquals("wrong name", "A", simpleName.getIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding typeBinding = simpleName.resolveTypeBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong name", "A", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong name", "p2", typeBinding.getPackage().getName()); //$NON-NLS-1$ //$NON-NLS-2$
Name name = qualifiedName.getQualifier();
assertTrue("Not a simple name", name.getNodeType() == ASTNode.SIMPLE_NAME); //$NON-NLS-1$
SimpleName simpleName2 = (SimpleName) name;
assertEquals("wrong name", "p2", simpleName2.getIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$
IBinding binding2 = simpleName2.resolveBinding();
assertNotNull("No binding", binding2); //$NON-NLS-1$
assertEquals("wrong type", IBinding.PACKAGE, binding2.getKind()); //$NON-NLS-1$
assertEquals("wrong name", "p2", binding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
node = getASTNode(compilationUnit, 0, 1, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an expression statement", node.getNodeType() == ASTNode.EXPRESSION_STATEMENT); //$NON-NLS-1$
ExpressionStatement expressionStatement2 = (ExpressionStatement) node;
Expression expression3 = expressionStatement2.getExpression();
assertTrue("Not an method invocation", expression3.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$
MethodInvocation methodInvocation2 = (MethodInvocation) expression3;
Expression expression4 = methodInvocation2.getExpression();
assertNotNull("No receiver", expression4); //$NON-NLS-1$
ITypeBinding binding3 = expression4.resolveTypeBinding();
assertNotNull("No type binding", binding3); //$NON-NLS-1$
assertEquals("wrong name", "A", binding3.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("wrong name", "p1", binding3.getPackage().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=15804
*/
public void test0341() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0341", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 1, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an if statement", node.getNodeType() == ASTNode.IF_STATEMENT); //$NON-NLS-1$
String expectedSource =
"if (field != null) {\n" + //$NON-NLS-1$
" throw new IOException();\n" + //$NON-NLS-1$
" } else if (field == null) {\n" + //$NON-NLS-1$
" throw new MalformedURLException();\n" + //$NON-NLS-1$
" } else if (field == null) {\n" + //$NON-NLS-1$
" throw new InterruptedIOException();\n" + //$NON-NLS-1$
" } else {\n" + //$NON-NLS-1$
" throw new UnsupportedEncodingException();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
IfStatement ifStatement = (IfStatement) node;
Statement thenStatement = ifStatement.getThenStatement();
expectedSource =
"{\n" + //$NON-NLS-1$
" throw new IOException();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(thenStatement, expectedSource, source);
Statement elseStatement = ifStatement.getElseStatement();
expectedSource =
"if (field == null) {\n" + //$NON-NLS-1$
" throw new MalformedURLException();\n" + //$NON-NLS-1$
" } else if (field == null) {\n" + //$NON-NLS-1$
" throw new InterruptedIOException();\n" + //$NON-NLS-1$
" } else {\n" + //$NON-NLS-1$
" throw new UnsupportedEncodingException();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(elseStatement, expectedSource, source);
assertTrue("Not a if statement", elseStatement.getNodeType() == ASTNode.IF_STATEMENT); //$NON-NLS-1$
ifStatement = (IfStatement) elseStatement;
thenStatement = ifStatement.getThenStatement();
expectedSource =
"{\n" + //$NON-NLS-1$
" throw new MalformedURLException();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(thenStatement, expectedSource, source);
elseStatement = ifStatement.getElseStatement();
expectedSource =
"if (field == null) {\n" + //$NON-NLS-1$
" throw new InterruptedIOException();\n" + //$NON-NLS-1$
" } else {\n" + //$NON-NLS-1$
" throw new UnsupportedEncodingException();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(elseStatement, expectedSource, source);
assertTrue("Not a if statement", elseStatement.getNodeType() == ASTNode.IF_STATEMENT); //$NON-NLS-1$
ifStatement = (IfStatement) elseStatement;
thenStatement = ifStatement.getThenStatement();
expectedSource =
"{\n" + //$NON-NLS-1$
" throw new InterruptedIOException();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(thenStatement, expectedSource, source);
elseStatement = ifStatement.getElseStatement();
expectedSource =
"{\n" + //$NON-NLS-1$
" throw new UnsupportedEncodingException();\n" + //$NON-NLS-1$
" }"; //$NON-NLS-1$
checkSourceRange(elseStatement, expectedSource, source);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=15657
* @deprecated marked deprecated to suppress JDOM-related deprecation warnings
*/
public void test0342() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0342", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
IDOMCompilationUnit dcompUnit = new DOMFactory().createCompilationUnit(sourceUnit.getSource(), sourceUnit.getElementName());
assertNotNull("dcompUnit is null", dcompUnit); //$NON-NLS-1$
// searching class
IDOMType classNode = null;
Enumeration children = dcompUnit.getChildren();
assertNotNull("dcompUnit has no children", children); //$NON-NLS-1$
while (children.hasMoreElements()) {
IDOMNode child = (IDOMNode) children.nextElement();
if (child.getNodeType() == IDOMNode.TYPE) {
classNode = (IDOMType) child;
break;
}
}
assertNotNull("classNode is null", classNode); //$NON-NLS-1$
// searching for methods
children = classNode.getChildren();
assertNotNull("classNode has no children", children); //$NON-NLS-1$
while (children.hasMoreElements()) {
IDOMNode child = (IDOMNode) children.nextElement();
if (child.getNodeType() == IDOMNode.METHOD) {
IDOMMethod childMethod = (IDOMMethod) child;
// returnType is always null;
String returnType = childMethod.getReturnType();
if (childMethod.isConstructor()) {
assertNull(returnType);
} else {
assertNotNull("no return type", returnType); //$NON-NLS-1$
}
}
}
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=16051
*/
public void test0343() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0343", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 1, 1);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an if statement", node.getNodeType() == ASTNode.IF_STATEMENT); //$NON-NLS-1$
String expectedSource =
"if (flag)\n" + //$NON-NLS-1$
" i= 10;"; //$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=16132
*/
public void test0344() throws JavaModelException {
Preferences preferences = null;
String pb_assert = null;
String compiler_source = null;
String compiler_compliance = null;
try {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0344", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
preferences = JavaCore.getPlugin().getPluginPreferences();
pb_assert = preferences.getString(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER);
compiler_source = preferences.getString(JavaCore.COMPILER_SOURCE);
compiler_compliance = preferences.getString(JavaCore.COMPILER_COMPLIANCE);
preferences.setValue(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR);
preferences.setValue(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
preferences.setValue(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
} finally {
if (preferences != null) {
preferences.setValue(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, pb_assert);
preferences.setValue(JavaCore.COMPILER_SOURCE, compiler_source);
preferences.setValue(JavaCore.COMPILER_COMPLIANCE, compiler_compliance);
}
}
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=17922
*/
public void test0345() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0345", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an field declaration", node.getNodeType() == ASTNode.FIELD_DECLARATION); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
List fragments = fieldDeclaration.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not an ArrayCreation", expression.getNodeType() == ASTNode.ARRAY_CREATION); //$NON-NLS-1$
ArrayCreation arrayCreation = (ArrayCreation) expression;
ArrayType arrayType = arrayCreation.getType();
IBinding binding2 = arrayType.resolveBinding();
assertNotNull("no binding2", binding2); //$NON-NLS-1$
assertEquals("not a type", binding2.getKind(), IBinding.TYPE); //$NON-NLS-1$
ITypeBinding typeBinding2 = (ITypeBinding) binding2;
assertTrue("Not an array type binding2", typeBinding2.isArray()); //$NON-NLS-1$
Type type = arrayType.getElementType();
assertTrue("Not a simple type", type.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
Name name = simpleType.getName();
assertTrue("QualifiedName", name.getNodeType() == ASTNode.QUALIFIED_NAME); //$NON-NLS-1$
SimpleName simpleName = ((QualifiedName) name).getName();
IBinding binding = simpleName.resolveBinding();
assertNotNull("no binding", binding); //$NON-NLS-1$
assertEquals("not a type", binding.getKind(), IBinding.TYPE); //$NON-NLS-1$
ITypeBinding typeBinding = (ITypeBinding) binding;
assertTrue("An array type binding", !typeBinding.isArray()); //$NON-NLS-1$
Type type2 = fieldDeclaration.getType();
assertTrue("Not a array type", type2.isArrayType()); //$NON-NLS-1$
ArrayType arrayType2 = (ArrayType) type2;
Type type3 = arrayType2.getElementType();
assertTrue("Not a simple type", type3.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType2 = (SimpleType) type3;
Name name2 = simpleType2.getName();
assertTrue("Not a qualified name", name2.getNodeType() == ASTNode.QUALIFIED_NAME); //$NON-NLS-1$
SimpleName simpleName2 = ((QualifiedName) name2).getName();
IBinding binding3 = simpleName2.resolveBinding();
assertNotNull("no binding", binding3); //$NON-NLS-1$
assertEquals("not a type", binding3.getKind(), IBinding.TYPE); //$NON-NLS-1$
ITypeBinding typeBinding3 = (ITypeBinding) binding3;
assertTrue("An array type binding", !typeBinding3.isArray()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
*/
public void test0346() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0346", "Test2.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an variable declaration", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "Vector", source); //$NON-NLS-1$
assertTrue("not an array type", !type.isArrayType()); //$NON-NLS-1$
assertTrue("Not a simple type", type.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
Name name = simpleType.getName();
assertTrue("Not a simpleName", name.isSimpleName()); //$NON-NLS-1$
SimpleName simpleName = (SimpleName) name;
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
ITypeBinding typeBinding = (ITypeBinding) binding;
assertTrue("An array", !typeBinding.isArray()); //$NON-NLS-1$
assertEquals("Wrong name", "Vector", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
ITypeBinding typeBinding2 = simpleType.resolveBinding();
assertNotNull("No binding", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, typeBinding2.getKind()); //$NON-NLS-1$
assertTrue("An array", !typeBinding2.isArray()); //$NON-NLS-1$
assertEquals("Wrong name", "Vector", typeBinding2.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
*/
public void test0347() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0347", "Test2.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an variable declaration", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "Vector[]", source); //$NON-NLS-1$
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
ITypeBinding binding = arrayType.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertTrue("Not an array type", binding.isArray()); //$NON-NLS-1$
assertEquals("Wrong name", "Vector[]", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
*/
public void test0348() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0348", "Test2.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an variable declaration", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "Vector[][]", source); //$NON-NLS-1$
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
ITypeBinding binding = arrayType.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertTrue("Not an array type", binding.isArray()); //$NON-NLS-1$
assertEquals("Wrong name", "Vector[][]", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
*/
public void test0349() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0349", "Test2.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an field declaration", node.getNodeType() == ASTNode.FIELD_DECLARATION); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
Type type = fieldDeclaration.getType();
checkSourceRange(type, "Vector[][]", source); //$NON-NLS-1$
assertTrue("not an array type", type.isArrayType()); //$NON-NLS-1$
ArrayType arrayType = (ArrayType) type;
ITypeBinding binding = arrayType.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertTrue("Not an array type", binding.isArray()); //$NON-NLS-1$
assertEquals("Wrong name", "Vector[][]", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=18138
*/
public void test0350() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0350", "Test2.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an field declaration", node.getNodeType() == ASTNode.FIELD_DECLARATION); //$NON-NLS-1$
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
Type type = fieldDeclaration.getType();
checkSourceRange(type, "Vector", source); //$NON-NLS-1$
assertTrue("not a simple type", type.isSimpleType()); //$NON-NLS-1$
SimpleType simpleType = (SimpleType) type;
ITypeBinding binding = simpleType.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertTrue("An array type", binding.isClass()); //$NON-NLS-1$
assertEquals("Wrong name", "Vector", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=18169
*/
public void test0351() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0351", "Test2.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
List parameters = methodDeclaration.parameters();
assertEquals("wrong size", 2, parameters.size()); //$NON-NLS-1$
SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
checkSourceRange(singleVariableDeclaration, "int a", source); //$NON-NLS-1$
singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(1);
checkSourceRange(singleVariableDeclaration, "int[] b", source); //$NON-NLS-1$
node = getASTNode(compilationUnit, 0, 1);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
methodDeclaration = (MethodDeclaration) node;
parameters = methodDeclaration.parameters();
assertEquals("wrong size", 2, parameters.size()); //$NON-NLS-1$
singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
checkSourceRange(singleVariableDeclaration, "int a", source); //$NON-NLS-1$
singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(1);
checkSourceRange(singleVariableDeclaration, "int b[]", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=18169
*/
public void test0352() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0352", "Test2.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
List parameters = methodDeclaration.parameters();
assertEquals("wrong size", 2, parameters.size()); //$NON-NLS-1$
SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
checkSourceRange(singleVariableDeclaration, "final int a", source); //$NON-NLS-1$
singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(1);
checkSourceRange(singleVariableDeclaration, "final int[] b", source); //$NON-NLS-1$
node = getASTNode(compilationUnit, 0, 1);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
methodDeclaration = (MethodDeclaration) node;
parameters = methodDeclaration.parameters();
assertEquals("wrong size", 2, parameters.size()); //$NON-NLS-1$
singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(0);
checkSourceRange(singleVariableDeclaration, "final int a", source); //$NON-NLS-1$
singleVariableDeclaration = (SingleVariableDeclaration) parameters.get(1);
checkSourceRange(singleVariableDeclaration, "final int b[]", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=18042
*/
public void test0353() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0353", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull("not null", node); //$NON-NLS-1$
assertTrue("Not an variable declaration", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
checkSourceRange(type, "InputStream", source); //$NON-NLS-1$
assertTrue("not a simple type", type.isSimpleType()); //$NON-NLS-1$
ITypeBinding binding = type.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
assertTrue("Not a class", binding.isClass()); //$NON-NLS-1$
assertEquals("Wrong name", "InputStream", binding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong package", "java.io", binding.getPackage().getName()); //$NON-NLS-1$ //$NON-NLS-2$
SimpleType simpleType = (SimpleType) type;
Name name = simpleType.getName();
IBinding binding2 = name.resolveBinding();
assertNotNull("No binding", binding2); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.TYPE, binding2.getKind()); //$NON-NLS-1$
ITypeBinding typeBinding = (ITypeBinding) binding2;
assertTrue("Not a class", typeBinding.isClass()); //$NON-NLS-1$
assertEquals("Wrong name", "InputStream", typeBinding.getName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong package", "java.io", typeBinding.getPackage().getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=19851
*/
public void test0354() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0354", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 2, compilationUnit.getMessages().length); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=20520
*/
public void test0355() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0355", "Foo.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not an if statement", node.getNodeType() == ASTNode.IF_STATEMENT); //$NON-NLS-1$
IfStatement ifStatement = (IfStatement) node;
Expression condition = ifStatement.getExpression();
assertTrue("Not an infixExpression", condition.getNodeType() == ASTNode.INFIX_EXPRESSION); //$NON-NLS-1$
InfixExpression infixExpression = (InfixExpression) condition;
Expression expression = infixExpression.getLeftOperand();
assertTrue("Not a method invocation expression", expression.getNodeType() == ASTNode.METHOD_INVOCATION); //$NON-NLS-1$
MethodInvocation methodInvocation = (MethodInvocation) expression;
Expression expression2 = methodInvocation.getExpression();
assertTrue("Not a parenthesis expression", expression2.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=20865
*/
public void test0356() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0356", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 1, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
Type type = variableDeclarationStatement.getType();
ITypeBinding binding = type.resolveBinding();
assertNotNull("Binding should NOT be null for type: "+type, binding);
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=21757
*/
public void test0357() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0357", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0);
assertNotNull(node);
assertTrue("Not a type declaration statement", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
SimpleName name = typeDeclaration.getName();
checkSourceRange(name, "A", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=21768
*/
public void test0358() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0358", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0,0);
assertNotNull(node);
assertTrue("Not a method declaration statement", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
SimpleName name = methodDeclaration.getName();
checkSourceRange(name, "mdd", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=21768
*/
public void test0359() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0359", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0,0);
assertNotNull(node);
assertTrue("Not a method declaration statement", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
SimpleName name = methodDeclaration.getName();
checkSourceRange(name, "mdd", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=21916
*/
public void test0360() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0360", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0,0, 0);
assertNotNull(node);
assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node;
List initializers = forStatement.initializers();
assertEquals("Wrong size", 1, initializers.size()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=21916
*/
public void test0361() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0361", "X.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0,0, 0);
assertNotNull(node);
assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node;
List initializers = forStatement.initializers();
assertEquals("Wrong size", 1, initializers.size()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=21916
* @deprecated using deprecated code
*/
public void test0362() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0362", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, false);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
ForStatement forStatement = this.ast.newForStatement();
VariableDeclarationFragment iFragment = this.ast.newVariableDeclarationFragment();
iFragment.setName(this.ast.newSimpleName("i")); //$NON-NLS-1$
iFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
VariableDeclarationFragment jFragment = this.ast.newVariableDeclarationFragment();
jFragment.setName(this.ast.newSimpleName("j")); //$NON-NLS-1$
jFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
VariableDeclarationFragment kFragment = this.ast.newVariableDeclarationFragment();
kFragment.setName(this.ast.newSimpleName("k")); //$NON-NLS-1$
kFragment.setInitializer(this.ast.newNumberLiteral("0"));//$NON-NLS-1$
VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(iFragment);
variableDeclarationExpression.setModifiers(Modifier.NONE);
variableDeclarationExpression.setType(this.ast.newPrimitiveType(PrimitiveType.INT));
variableDeclarationExpression.fragments().add(jFragment);
variableDeclarationExpression.fragments().add(kFragment);
forStatement.initializers().add(variableDeclarationExpression);
PostfixExpression iPostfixExpression = this.ast.newPostfixExpression();
iPostfixExpression.setOperand(this.ast.newSimpleName("i"));//$NON-NLS-1$
iPostfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(iPostfixExpression);
PostfixExpression jPostfixExpression = this.ast.newPostfixExpression();
jPostfixExpression.setOperand(this.ast.newSimpleName("j"));//$NON-NLS-1$
jPostfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(jPostfixExpression);
PostfixExpression kPostfixExpression = this.ast.newPostfixExpression();
kPostfixExpression.setOperand(this.ast.newSimpleName("k"));//$NON-NLS-1$
kPostfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
forStatement.updaters().add(kPostfixExpression);
forStatement.setBody(this.ast.newBlock());
InfixExpression infixExpression = this.ast.newInfixExpression();
infixExpression.setLeftOperand(this.ast.newSimpleName("i")); //$NON-NLS-1$
infixExpression.setOperator(InfixExpression.Operator.LESS);
infixExpression.setRightOperand(this.ast.newNumberLiteral("10")); //$NON-NLS-1$
forStatement.setExpression(infixExpression);
assertTrue("Both AST trees should be identical", forStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
checkSourceRange(node, "for (int i=0, j=0, k=0; i<10 ; i++, j++, k++) {}", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22939
*/
public void test0363() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0363", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 1);
assertNotNull(node);
assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a parenthesized expression", expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION); //$NON-NLS-1$
Expression expression2 = ((ParenthesizedExpression) expression).getExpression();
checkSourceRange(expression2, "xxxx", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11529
*/
public void test0364() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0364", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
checkSourceRange(variableDeclarationStatement, "int local;", source); //$NON-NLS-1$
SimpleName simpleName = variableDeclarationFragment.getName();
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=11529
*/
public void test0365() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0365", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node;
List initializers = forStatement.initializers();
assertEquals("Wrong size", 1, initializers.size()); //$NON-NLS-1$
VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpression) initializers.get(0);
List fragments = variableDeclarationExpression.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
SimpleName simpleName = variableDeclarationFragment.getName();
IBinding binding = simpleName.resolveBinding();
assertNotNull("No binding", binding); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
*/
public void test0366() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0366", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node;
checkSourceRange(forStatement, "for (int i = 0; i < 5; ++i);", source); //$NON-NLS-1$
Statement statement = forStatement.getBody();
assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$
checkSourceRange(statement, ";", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
*/
public void test0367() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0367", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a while statement", node.getNodeType() == ASTNode.WHILE_STATEMENT); //$NON-NLS-1$
WhileStatement whileStatement = (WhileStatement) node;
checkSourceRange(whileStatement, "while(i == 2);", source); //$NON-NLS-1$
Statement statement = whileStatement.getBody();
assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$
checkSourceRange(statement, ";", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
*/
public void test0368() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0368", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertProblemsSize(compilationUnit, 1, "The label test is never explicitly referenced"); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a labeled statement", node.getNodeType() == ASTNode.LABELED_STATEMENT); //$NON-NLS-1$
LabeledStatement labeledStatement = (LabeledStatement) node;
checkSourceRange(labeledStatement, "test:;", source); //$NON-NLS-1$
Statement statement = labeledStatement.getBody();
assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$
checkSourceRange(statement, ";", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
*/
public void test0369() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0369", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertProblemsSize(compilationUnit, 1, "The label test is never explicitly referenced"); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a labeled statement", node.getNodeType() == ASTNode.LABELED_STATEMENT); //$NON-NLS-1$
LabeledStatement labeledStatement = (LabeledStatement) node;
checkSourceRange(labeledStatement, "test:\\u003B", source); //$NON-NLS-1$
Statement statement = labeledStatement.getBody();
assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$
checkSourceRange(statement, "\\u003B", source); //$NON-NLS-1$
}
/**
* DoStatement ==> DoStatement
*/
public void test0370() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0370", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull("Expression should not be null", node); //$NON-NLS-1$
DoStatement doStatement = this.ast.newDoStatement();
doStatement.setBody(this.ast.newEmptyStatement());
doStatement.setExpression(this.ast.newBooleanLiteral(true));
assertTrue("Both AST trees should be identical", doStatement.subtreeMatch(new ASTMatcher(), node)); //$NON-NLS-1$
String expectedSource = "do ; while(true);";//$NON-NLS-1$
checkSourceRange(node, expectedSource, source);
DoStatement doStatement2 = (DoStatement) node;
Statement statement = doStatement2.getBody();
assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$
checkSourceRange(statement, ";", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
*/
public void test0371() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0371", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a labeled statement", node.getNodeType() == ASTNode.IF_STATEMENT); //$NON-NLS-1$
IfStatement ifStatement = (IfStatement) node;
checkSourceRange(ifStatement, "if (i == 6);", source); //$NON-NLS-1$
Statement statement = ifStatement.getThenStatement();
assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$
checkSourceRange(statement, ";", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23048
*/
public void test0372() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0372", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a labeled statement", node.getNodeType() == ASTNode.IF_STATEMENT); //$NON-NLS-1$
IfStatement ifStatement = (IfStatement) node;
checkSourceRange(ifStatement, "if (i == 6) {} else ;", source); //$NON-NLS-1$
Statement statement = ifStatement.getElseStatement();
assertTrue("Not an empty statement", statement.getNodeType() == ASTNode.EMPTY_STATEMENT); //$NON-NLS-1$
checkSourceRange(statement, ";", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23118
*/
public void test0373() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0373", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node;
Statement statement = forStatement.getBody();
assertTrue("Not a block statement", statement.getNodeType() == ASTNode.BLOCK); //$NON-NLS-1$
Block block = (Block) statement;
List statements = block.statements();
assertEquals("Wrong size", 1, statements.size()); //$NON-NLS-1$
Statement statement2 = (Statement) statements.get(0);
assertTrue("Not a break statement", statement2.getNodeType() == ASTNode.BREAK_STATEMENT); //$NON-NLS-1$
BreakStatement breakStatement = (BreakStatement) statement2;
checkSourceRange(breakStatement, "break;", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23118
*/
public void test0374() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0374", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a for statement", node.getNodeType() == ASTNode.FOR_STATEMENT); //$NON-NLS-1$
ForStatement forStatement = (ForStatement) node;
Statement statement = forStatement.getBody();
assertTrue("Not a block statement", statement.getNodeType() == ASTNode.BLOCK); //$NON-NLS-1$
Block block = (Block) statement;
List statements = block.statements();
assertEquals("Wrong size", 1, statements.size()); //$NON-NLS-1$
Statement statement2 = (Statement) statements.get(0);
assertTrue("Not a break statement", statement2.getNodeType() == ASTNode.CONTINUE_STATEMENT); //$NON-NLS-1$
ContinueStatement continueStatement = (ContinueStatement) statement2;
checkSourceRange(continueStatement, "continue;", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23052
*/
public void test0375() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0375", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("problems found", 1, compilationUnit.getMessages().length); //$NON-NLS-1$
List imports = compilationUnit.imports();
assertEquals("wrong size", 1, imports.size()); //$NON-NLS-1$
ImportDeclaration importDeclaration = (ImportDeclaration) imports.get(0);
IBinding binding = importDeclaration.resolveBinding();
assertNotNull("no binding", binding); //$NON-NLS-1$
assertEquals("Not a type binding", IBinding.TYPE, binding.getKind()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22939
*/
public void test0376() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0376", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a cast expression", expression.getNodeType() == ASTNode.CAST_EXPRESSION); //$NON-NLS-1$
Type type = ((CastExpression) expression).getType();
checkSourceRange(type, "A", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23050
*/
public void test0377() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0377", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
IVariableBinding variableBinding = variableDeclarationFragment.resolveBinding();
assertNotNull("No variable binding", variableBinding); //$NON-NLS-1$
assertEquals("Wrong modifier", IModifierConstants.ACC_FINAL, variableBinding.getModifiers()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22161
*/
public void test0378() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0378", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
SimpleName name = typeDeclaration.getName();
checkSourceRange(name, "B", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22161
* @deprecated using deprecated code
*/
public void test0379() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0379", "Test.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode expression = getASTNodeToCompare((CompilationUnit) result);
assertNotNull("Expression should not be null", expression); //$NON-NLS-1$
assertTrue("Not a class instance creation", expression.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION); //$NON-NLS-1$
ClassInstanceCreation classInstanceCreation2 = (ClassInstanceCreation) expression;
Name name2 = classInstanceCreation2.getName();
checkSourceRange(name2, "Object", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22054
*/
public void test0380() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0380", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a return statement", node.getNodeType() == ASTNode.RETURN_STATEMENT); //$NON-NLS-1$
ReturnStatement returnStatement = (ReturnStatement) node;
Expression expression = returnStatement.getExpression();
assertTrue("Not a super method invocation", expression.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION); //$NON-NLS-1$
SuperMethodInvocation superMethodInvocation = (SuperMethodInvocation) expression;
ITypeBinding typeBinding = superMethodInvocation.resolveTypeBinding();
assertNotNull("no type binding", typeBinding); //$NON-NLS-1$
assertEquals("wrong declaring class", typeBinding.getSuperclass().getName(), "Object"); //$NON-NLS-1$ //$NON-NLS-2$
SimpleName simpleName = superMethodInvocation.getName();
IBinding binding = simpleName.resolveBinding();
assertNotNull("no binding", binding); //$NON-NLS-1$
assertEquals("Wrong type", IBinding.METHOD, binding.getKind()); //$NON-NLS-1$
IMethodBinding methodBinding = (IMethodBinding) binding;
assertEquals("Wrong declaring class", methodBinding.getDeclaringClass().getName(), "Object"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23054
*/
public void test0381() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0381", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0);
assertNotNull(node);
assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
Javadoc javadoc = typeDeclaration.getJavadoc();
assertNull("Javadoc not null", javadoc); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
*/
public void test0382() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0382", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0);
assertNotNull(node);
assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertEquals("Wrong fully qualified name", typeBinding.getQualifiedName(), "test0382.A"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
*/
public void test0383() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0383", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertEquals("Wrong fully qualified name", typeBinding.getQualifiedName(), "test0383.A.B"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
*/
public void test0384() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0384", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertEquals("Wrong fully qualified name", typeBinding.getQualifiedName(), "test0384.A.B.D"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23117
*/
public void test0385() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0385", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 1, compilationUnit.getMessages().length); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23259
*/
public void test0386() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0386", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a switch statement", node.getNodeType() == ASTNode.SWITCH_STATEMENT); //$NON-NLS-1$
SwitchStatement switchStatement = (SwitchStatement) node;
List statements = switchStatement.statements();
assertEquals("Wrong size", 5, statements.size()); //$NON-NLS-1$
Statement statement = (Statement) statements.get(0);
assertTrue("Not a case statement", statement.getNodeType() == ASTNode.SWITCH_CASE); //$NON-NLS-1$
checkSourceRange(statement, "case 1:", source); //$NON-NLS-1$
statement = (Statement) statements.get(3);
assertTrue("Not a default case statement", statement.getNodeType() == ASTNode.SWITCH_CASE); //$NON-NLS-1$
checkSourceRange(statement, "default :", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22939
*/
public void test0387() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0387", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("Wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not a cast expression", expression.getNodeType() == ASTNode.CAST_EXPRESSION); //$NON-NLS-1$
Type type = ((CastExpression) expression).getType();
checkSourceRange(type, "A", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
*/
public void test0388() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0388", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0);
assertNotNull(node);
assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "test0388.A", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
*/
public void test0389() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0389", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a type declaration", node.getNodeType() == ASTNode.TYPE_DECLARATION); //$NON-NLS-1$
TypeDeclaration typeDeclaration = (TypeDeclaration) node;
ITypeBinding typeBinding = typeDeclaration.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "test0389.A.B", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
* @deprecated using deprecated code
*/
public void test0390() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0390", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Type type = methodDeclaration.getReturnType();
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "int", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
* @deprecated using deprecated code
*/
public void test0391() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0391", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Type type = methodDeclaration.getReturnType();
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "int[]", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22154
* @deprecated using deprecated code
*/
public void test0392() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0392", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Type type = methodDeclaration.getReturnType();
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "java.lang.String[]", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
* @deprecated using deprecated code
*/
public void test0393() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0393", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Type type = methodDeclaration.getReturnType();
checkSourceRange(type, "String", source); //$NON-NLS-1$
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong dimension", 0, typeBinding.getDimensions()); //$NON-NLS-1$
assertEquals("Wrong qualified name", "java.lang.String", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong dimension", 1, methodDeclaration.getExtraDimensions()); //$NON-NLS-1$
IMethodBinding methodBinding = methodDeclaration.resolveBinding();
assertNotNull("No method binding", methodBinding); //$NON-NLS-1$
ITypeBinding typeBinding2 = methodBinding.getReturnType();
assertNotNull("No type binding", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong qualified name", "java.lang.String[]", typeBinding2.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong dimension", 1, typeBinding2.getDimensions()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
* @deprecated using deprecated code
*/
public void test0394() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0394", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Type type = methodDeclaration.getReturnType();
checkSourceRange(type, "String", source); //$NON-NLS-1$
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong qualified name", "java.lang.String", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong dimension", 0, methodDeclaration.getExtraDimensions()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
* @deprecated using deprecated code
*/
public void test0395() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0395", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
assertNotNull("No compilation unit", result); //$NON-NLS-1$
assertTrue("result is not a compilation unit", result instanceof CompilationUnit); //$NON-NLS-1$
CompilationUnit compilationUnit = (CompilationUnit) result;
assertEquals("errors found", 0, compilationUnit.getMessages().length); //$NON-NLS-1$
ASTNode node = getASTNode(compilationUnit, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
Type type = methodDeclaration.getReturnType();
checkSourceRange(type, "String[]", source); //$NON-NLS-1$
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertEquals("Wrong dimension", 1, typeBinding.getDimensions()); //$NON-NLS-1$
assertEquals("Wrong qualified name", "java.lang.String[]", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong dimension", 1, methodDeclaration.getExtraDimensions()); //$NON-NLS-1$
IMethodBinding methodBinding = methodDeclaration.resolveBinding();
assertNotNull("No method binding", methodBinding); //$NON-NLS-1$
ITypeBinding typeBinding2 = methodBinding.getReturnType();
assertNotNull("No type binding", typeBinding2); //$NON-NLS-1$
assertEquals("Wrong qualified name", "java.lang.String[][]", typeBinding2.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong dimension", 2, typeBinding2.getDimensions()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
*/
public void test0396() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0396", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration method = (MethodDeclaration) node;
SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) method.parameters().get(0);
assertNotNull("Expression should not be null", singleVariableDeclaration); //$NON-NLS-1$
checkSourceRange(singleVariableDeclaration, "final String s[]", source); //$NON-NLS-1$
Type type = singleVariableDeclaration.getType();
checkSourceRange(type, "String", source); //$NON-NLS-1$
assertEquals("Wrong dimension", 1, singleVariableDeclaration.getExtraDimensions()); //$NON-NLS-1$
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue("An array binding", !typeBinding.isArray()); //$NON-NLS-1$
assertEquals("Wrong dimension", 0, typeBinding.getDimensions()); //$NON-NLS-1$
assertEquals("wrong fully qualified name", "java.lang.String", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
IVariableBinding variableBinding = singleVariableDeclaration.resolveBinding();
assertNotNull("No variable binding", variableBinding); //$NON-NLS-1$
ITypeBinding typeBinding2 = variableBinding.getType();
assertNotNull("No type binding", typeBinding2); //$NON-NLS-1$
assertTrue("Not an array binding", typeBinding2.isArray()); //$NON-NLS-1$
assertEquals("Wrong dimension", 1, typeBinding2.getDimensions()); //$NON-NLS-1$
assertEquals("wrong fully qualified name", "java.lang.String[]", typeBinding2.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23284
*/
public void test0397() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0397", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration method = (MethodDeclaration) node;
SingleVariableDeclaration singleVariableDeclaration = (SingleVariableDeclaration) method.parameters().get(0);
assertNotNull("Expression should not be null", singleVariableDeclaration); //$NON-NLS-1$
checkSourceRange(singleVariableDeclaration, "final String[] \\u0073\\u005B][]", source); //$NON-NLS-1$
Type type = singleVariableDeclaration.getType();
checkSourceRange(type, "String[]", source); //$NON-NLS-1$
assertEquals("Wrong dimension", 2, singleVariableDeclaration.getExtraDimensions()); //$NON-NLS-1$
ITypeBinding typeBinding = type.resolveBinding();
assertNotNull("No type binding", typeBinding); //$NON-NLS-1$
assertTrue("Not an array binding", typeBinding.isArray()); //$NON-NLS-1$
assertEquals("Wrong dimension", 1, typeBinding.getDimensions()); //$NON-NLS-1$
assertEquals("wrong fully qualified name", "java.lang.String[]", typeBinding.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
IVariableBinding variableBinding = singleVariableDeclaration.resolveBinding();
assertNotNull("No variable binding", variableBinding); //$NON-NLS-1$
ITypeBinding typeBinding2 = variableBinding.getType();
assertNotNull("No type binding", typeBinding2); //$NON-NLS-1$
assertTrue("Not an array binding", typeBinding2.isArray()); //$NON-NLS-1$
assertEquals("Wrong dimension", 3, typeBinding2.getDimensions()); //$NON-NLS-1$
assertEquals("wrong fully qualified name", "java.lang.String[][][]", typeBinding2.getQualifiedName()); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=23362
*/
public void test0398() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0398", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0, 0);
assertNotNull(node);
assertTrue("Not a variable declaration statement", node.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT); //$NON-NLS-1$
VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = variableDeclarationStatement.fragments();
assertEquals("wrong size", 1, fragments.size()); //$NON-NLS-1$
VariableDeclarationFragment variableDeclarationFragment = (VariableDeclarationFragment) fragments.get(0);
Expression expression = variableDeclarationFragment.getInitializer();
assertTrue("Not an infix expression", expression.getNodeType() == ASTNode.INFIX_EXPRESSION); //$NON-NLS-1$
InfixExpression infixExpression = (InfixExpression) expression;
checkSourceRange(infixExpression, "(1 + 2) * 3", source); //$NON-NLS-1$
Expression expression2 = infixExpression.getLeftOperand();
assertTrue("Not an parenthesis expression", expression2.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION); //$NON-NLS-1$
ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpression) expression2;
Expression expression3 = parenthesizedExpression.getExpression();
assertTrue("Not an infix expression", expression3.getNodeType() == ASTNode.INFIX_EXPRESSION); //$NON-NLS-1$
checkSourceRange(expression3, "1 + 2", source); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22306
*/
public void test0399() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0399", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
assertTrue("Not a constructor", methodDeclaration.isConstructor()); //$NON-NLS-1$
Block block = methodDeclaration.getBody();
List statements = block.statements();
assertEquals("wrong size", 2, statements.size()); //$NON-NLS-1$
}
/**
* http://dev.eclipse.org/bugs/show_bug.cgi?id=22306
*/
public void test0400() throws JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "src", "test0400", "A.java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
char[] source = sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, true);
ASTNode node = getASTNode((CompilationUnit) result, 0, 0);
assertNotNull(node);
assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
MethodDeclaration methodDeclaration = (MethodDeclaration) node;
assertTrue("Not a constructor", methodDeclaration.isConstructor()); //$NON-NLS-1$
Block block = methodDeclaration.getBody();
List statements = block.statements();
assertEquals("wrong size", 3, statements.size()); //$NON-NLS-1$
Statement statement = (Statement) statements.get(0);
assertTrue("Not an superconstructorinvocation", statement.getNodeType() == ASTNode.SUPER_CONSTRUCTOR_INVOCATION); //$NON-NLS-1$
checkSourceRange(statement, "super();", source); //$NON-NLS-1$
}
}
| [
"[email protected]"
] | |
ba1fbf261fb8d83c3b6edfa534e4ecd2bd5caa7c | 5c64004c54c4a64035cce2224bdcfe450e6f9bab | /si-modules/OIC_IPE_Client/app/src/main/java/com/canonical/democlient/PageButton.java | 9bccfc8f44c69a29795aee08012afe217a4311fd | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | uguraba/SI | 3fd091b602c843e3b7acc12aa40ed5365964663b | 9e0f89a7413c351b2f739b1ee8ae2687c04d5ec1 | refs/heads/master | 2021-01-08T02:37:39.152700 | 2018-03-08T01:28:24 | 2018-03-08T01:28:24 | 241,887,209 | 0 | 0 | BSD-2-Clause | 2020-02-20T13:13:19 | 2020-02-20T13:12:20 | null | UTF-8 | Java | false | false | 2,878 | java | package com.canonical.democlient;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
/**
* Created by 문선호 on 2016-10-07.
*/
public class PageButton extends PageHandler implements android.view.View.OnClickListener {
private final static String TAG = MainActivity.class.getSimpleName();
private HttpOneM2MOperation op = new HttpOneM2MOperation();
private Button button_cancel;
private Thread observe_result;
private boolean isObserving = false;
/* OIC Module */
private FoundItem foundItem;
private void initData(){
Intent intent = getIntent();
foundItem = (FoundItem)intent.getSerializableExtra("foundItem");
}
private void receiveData(){
isObserving = true;
int i=0;
while( !Thread.interrupted() || isObserving ) {
try {
Log.i("WHILE >>> >>>> >>", " [" + ++i + "]");
initData();
op.init(Util.makeUrl(foundItem.getHost(), Constants.POLLING_CHANNEL_S, "pcu"), foundItem);
setObsList(foundItem.getDeviceId());
String xml = op.retrievePollingChannelPCU();
final String value = super.getValue(xml,"con");
if( super.getValue(xml,"cr").equals("button") ){
Log.e(TAG, value);
runOnUiThread(new Runnable(){
@Override
public void run() {
appendRow( value );
}
});
}
} catch (Exception je) {
Log.e(TAG, je.toString());
}
}
Log.e(TAG, " BREAK !! ");
}
public void start_observe(){
observe_result = new Thread(new Runnable() {
@Override
public void run() {
receiveData();
}
});
observe_result.start();
}
public void stop_observe(){
isObserving = false;
observe_result.interrupt();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.control_button);
button_cancel = (Button) findViewById(R.id.button_button_a_cancel);
button_cancel.setOnClickListener(this);
start_observe();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button_button_a_cancel:
stop_observe();
finish();
break;
default:
break;
}
}
@Override
public void onBackPressed(){
Log.e(TAG, " Back !! ");
stop_observe();
finish();
}
}
| [
"[email protected]"
] | |
ace650aeb1703b45ee546c02ba6048895a4dfd6e | bb6d06f8c15dff6e2f09a8f039618b2d5b8a432b | /src/by/bsuir/kaziukovich/task12/book/Book.java | 3cd335453390bcf21287a73aeb5ddbf94d5b39df | [
"MIT"
] | permissive | AlexX333BY/wt-java-introduction | e761eeab9088274a079a273b9fc617c25a0c2c70 | 04108d7f0160d70d512b8a404b6890669980ec5a | refs/heads/master | 2020-03-28T23:53:27.323396 | 2018-10-11T17:40:18 | 2018-10-11T17:40:18 | 149,314,073 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,381 | java | package by.bsuir.kaziukovich.task12.book;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* Class for Book representation
*/
public class Book implements Comparable<Book>, Cloneable {
/**
* Book title
*/
private String title;
/**
* Book author
*/
private String author;
/**
* Book price
*/
private int price;
/**
* Book edition
*/
private static int edition;
/**
* Book ISBN
*/
private String isbn;
/**
* Parts of ISBN
*/
private final static int ISBN_PARTS = 5;
/**
* Checks if books equals
* @param object Object to compare
* @return True if objects are same, otherwise false
*/
@Override
public boolean equals(Object object) {
Book book;
if (object == this) {
return true;
}
if ((object == null) || (getClass() != object.getClass())) {
return false;
}
book = (Book) object;
return Objects.equals(book.title, title) && Objects.equals(book.author, author) && (price == book.price)
&& Objects.equals(book.isbn, isbn);
}
/**
* Generates hash code of this book
* @return Hash code of this book
*/
@Override
public int hashCode() {
return Objects.hash(title, author, price, edition, isbn);
}
/**
* Generates string representation of this book
* @return String representation of this book
*/
@Override
public String toString() {
return getClass().getName() + "@title: " + title + ", author: " + author + ", price: " + price + ", edition: "
+ edition + ", ISBN: " + isbn;
}
/**
* Creates and returns a copy of this object
* @return Copy of this object
*/
@Override
protected Object clone() throws CloneNotSupportedException {
Book clone = (Book) super.clone();
clone.title = new String(title);
clone.author = new String(author);
clone.price = price;
clone.isbn = new String(isbn);
return clone;
}
/**
* Sets edition of all books
* @param edition Edition to set
*/
public static void setEdition(int edition) {
if (edition <= 0) {
throw new IllegalArgumentException("Edition should be positive number");
}
Book.edition = edition;
}
/**
* Gets book title
* @return Book title
*/
public String getTitle() {
return title;
}
/**
* Gets book author
* @return Book author
*/
public String getAuthor() {
return author;
}
/**
* Gets book price
* @return Book price
*/
public int getPrice() {
return price;
}
/**
* Gets book edition
* @return Book edition
*/
public static int getEdition() {
return edition;
}
/**
* Gets book ISBN
* @return Book ISBN
*/
public String getIsbn() {
return isbn;
}
/**
* Checks if ISBN is correct
* @param isbn ISBN to check
* @return True if ISBN is correct, otherwise false
*/
private static boolean isIsbnCorrect(String isbn) {
String[] splittedIsbn = isbn.split(Pattern.quote("-"));
byte indent = 0;
int isbnLength = 0;
if ((splittedIsbn.length != 5) && (splittedIsbn.length != 4)) {
return false;
}
if (splittedIsbn.length == 5) {
if (!splittedIsbn[0].matches("^97[89]$")) {
return false;
}
indent = 1;
}
for (String s : splittedIsbn) {
isbnLength += s.length();
}
return (isbnLength == 13)
&& splittedIsbn[indent].matches("^\\d{1,5}$")
&& splittedIsbn[1 + indent].matches("^\\d{2,7}$")
&& splittedIsbn[2 + indent].matches("^\\d{1,6}$")
&& splittedIsbn[3 + indent].matches("^[0-9X]$");
}
/**
* Splits ISBN string to int array
* @param isbn ISBN string
* @return Splitted ISBN
*/
private static int[] splitIsbnToInt(String isbn) {
final int DEFAULT_ISBN_FIRST_PART = 978;
int[] result = new int[ISBN_PARTS];
String[] splittedIsbn = isbn.replace("X", "10").split("-");
int indent = 0;
/* handling old 4-part ISBN */
if (splittedIsbn.length == ISBN_PARTS - 1) {
result[0] = DEFAULT_ISBN_FIRST_PART;
indent = 1;
}
for (int i = indent; i < ISBN_PARTS; i++) {
result[i] = Integer.parseInt(splittedIsbn[i - indent]);
}
return result;
}
/**
* Compares two books by ISBN
* @param book Book to compare to this book
* @return A negative integer, zero, or a positive integer as this book is less than, equal to, or greater than the specified book
*/
@Override
public int compareTo(Book book) {
int[] thisIsbn = splitIsbnToInt(isbn), otherIsbn;
int compareResult = 0;
if (book == null) {
throw new IllegalArgumentException("Book shouldn't be null");
}
otherIsbn = splitIsbnToInt(book.isbn);
for (int i = 0; (i < ISBN_PARTS) && (compareResult == 0); i++) {
compareResult = Integer.compare(thisIsbn[i], otherIsbn[i]);
}
return compareResult;
}
/**
* Constructor of book
* @param title Title of book
* @param author Author of book
* @param price Price of book
*/
public Book(String title, String author, int price, String isbn) {
if (title == null) {
throw new IllegalArgumentException("Title shouldn't be null");
}
if (author == null) {
throw new IllegalArgumentException("Author shouldn't be null");
}
if (price < 0) {
throw new IllegalArgumentException("Price cannot be negative");
}
if (isbn == null) {
throw new IllegalArgumentException("ISBN shouldn't be null");
}
if (!isIsbnCorrect(isbn)) {
throw new IllegalArgumentException(("ISBN is not correct"));
}
this.title = title;
this.author = author;
this.price = price;
this.isbn = isbn;
}
} | [
"[email protected]"
] | |
bee85004c0461b0fb3945471fa707ee9b1f2ee3e | 72ccad0f396356a15961a7c57a1af28678e8bba5 | /spring-cloud-gateway/src/main/java/com/xw/cloud/gs/AuthorizeFilter.java | 6936ce6ed7cfd0786362ed2d782c5108c5735087 | [] | no_license | shrimp32/springcloud-demo | 7366c7339a54855c19bf9adecf7ed8f2e9e3dcd6 | d08bd60530c7a9a2279113dba5d65926d76a7aba | refs/heads/master | 2021-06-13T15:48:38.353117 | 2020-06-02T04:38:07 | 2020-06-02T04:38:07 | 123,388,910 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,275 | java | //package com.xw.cloud.gs;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
//import org.springframework.cloud.gateway.filter.GlobalFilter;
//import org.springframework.core.annotation.Order;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.http.server.reactive.ServerHttpResponse;
//import org.springframework.stereotype.Component;
//import org.springframework.util.StringUtils;
//import org.springframework.web.server.ServerWebExchange;
//import reactor.core.publisher.Mono;
//
///**
// * @author : 夏玮
// * Created on 2018-12-27 14:51
// * 全局路由器
// */
//@Component
//@Order(0)
//public class AuthorizeFilter implements GlobalFilter{
// private static final String AUTHORIZE_TOKEN = "token";
// private static final String AUTHORIZE_UID = "uid";
//
// @Autowired
// private StringRedisTemplate stringRedisTemplate;
//
// @Override
// public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
// ServerHttpRequest request = exchange.getRequest();
// HttpHeaders headers = request.getHeaders();
// String token = headers.getFirst(AUTHORIZE_TOKEN);
// String uid = headers.getFirst(AUTHORIZE_UID);
// if (token == null) {
// token = request.getQueryParams().getFirst(AUTHORIZE_TOKEN);
// }
// if (uid == null) {
// uid = request.getQueryParams().getFirst(AUTHORIZE_UID);
// }
//
// ServerHttpResponse response = exchange.getResponse();
// if (StringUtils.isEmpty(token) || StringUtils.isEmpty(uid)) {
// response.setStatusCode(HttpStatus.UNAUTHORIZED);
// return response.setComplete();
// }
// String authToken = stringRedisTemplate.opsForValue().get(uid);
// if (authToken == null || !authToken.equals(token)) {
// response.setStatusCode(HttpStatus.UNAUTHORIZED);
// return response.setComplete();
// }
//
// return chain.filter(exchange);
// }
//}
| [
"[email protected]"
] | |
ebd12cdafcb17d86e59dd175687f8da2a39d0811 | b7f4f80c08495d31ef56d6cbb82bda2052b14e38 | /app/src/main/java/com/app/fran/copanamo/fragments/VideosFragment.java | 598e1a6afe153dba61a52c73aaac1ebc1c3f0913 | [] | no_license | mraasf/copa-na-mao | e0296f82891e2f9cb464d9fdc9f8af069e69764a | 5a90ffd3dfa9ea26d29a5afbf1a025b53e7f6cbc | refs/heads/master | 2020-03-24T21:27:07.039743 | 2018-07-31T15:28:42 | 2018-07-31T15:28:42 | 143,033,143 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,372 | java | package com.app.fran.copanamo.fragments;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import com.app.fran.copanamo.R;
import com.app.fran.copanamo.adapters.RecyclerVideoAdapter;
import com.app.fran.copanamo.entidades.Video;
import com.app.fran.copanamo.service.RetrofitService;
import com.app.fran.copanamo.service.RetrofitServiceGenerator;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class VideosFragment extends Fragment {
RecyclerView rvVideos;
List<Video> videos;
ProgressBar progressBar;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.videos_fragment, container, false);
videos = new ArrayList<>();
rvVideos = view.findViewById(R.id.myRv_videos);
rvVideos.setLayoutManager(new LinearLayoutManager(getContext()));
progressBar = view.findViewById(R.id.progressBarVideos);
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(true);
getVideos();
return view;
}
private void getVideos(){
RetrofitService service = RetrofitServiceGenerator.createService(RetrofitService.class);
Call<List<Video>> call = service.getVideosIds();
call.enqueue(new Callback<List<Video>>() {
@Override
public void onResponse(Call<List<Video>> call, Response<List<Video>> response) {
if(response.isSuccessful()){
videos = response.body();
RecyclerVideoAdapter adapter = new RecyclerVideoAdapter(getContext(),videos);
rvVideos.setAdapter(adapter);
progressBar.setVisibility(View.GONE);
}
}
@Override
public void onFailure(Call<List<Video>> call, Throwable t) {
}
});
}
}
| [
"[email protected]"
] | |
de695dca224562823da5bcc05750598f2faaf06a | a5acc408b124e13bb7a2fcf0afa15552d67bcbe7 | /src/main/java/com/example/Application.java | 6bb1d97845959596be7e884791c3feced8b98b76 | [] | no_license | woj1993/SpringBootTraining | cee31e15ee1b5173664713362f15e86af382c887 | 47351980372af334aefd4095d5e500a8abb9b452 | refs/heads/master | 2021-01-10T01:54:48.293773 | 2015-10-22T20:28:22 | 2015-10-22T20:28:22 | 44,771,533 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 444 | java | package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
@EnableJpaRepositories(basePackages = "com.example.repository")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
| [
"w"
] | w |
c4967210d2357e3cc42feafea1097e76b8cb60f6 | 8083f89bc6fc4b218b2301ab1ac87a868e91780c | /src/java/service/NoteFacadeREST.java | 7e142abe94924e5fc79b99d894ba173fc4e5944a | [
"Apache-2.0"
] | permissive | Kalalihapulla/BitsPlease | a2f94a680f28e57845d4da51c73eba16942dda0f | d79ff91b8a794da73d26ac003fd717212596f018 | refs/heads/main | 2021-04-27T21:06:03.116157 | 2017-03-13T16:16:29 | 2017-03-13T16:16:29 | 122,392,702 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,894 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package service;
import Util.HibernateStuff;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import model.Note;
import model.Status;
import model.UserAccount;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
/**
*
* @author Izymi
*/
@Stateless
@Path("model.note")
public class NoteFacadeREST extends AbstractFacade<Note> {
private SessionFactory sessionFactory;
@PersistenceContext(unitName = "ProjectTestUDPU")
private EntityManager em;
public NoteFacadeREST() {
super(Note.class);
}
@POST
@Override
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public void create(Note entity) {
this.sessionFactory = HibernateStuff.getInstance().getSessionFactory();
Session session
= sessionFactory.openSession();
session.beginTransaction();
session.saveOrUpdate(entity);
session.getTransaction().commit();
}
@PUT
@Path("{id}")
@Consumes({MediaType.TEXT_PLAIN})
public void editStatus(@PathParam("id") Long id, String status) {
this.sessionFactory = HibernateStuff.getInstance().getSessionFactory();
Session session
= sessionFactory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
Note note
= (Note) session.get(Note.class, id);
note.setStatus(strtost(status));
session.update(note);
tx.commit();
} catch (HibernateException e) {
if (tx != null) {
tx.rollback();
}
e.printStackTrace();
} finally {
}
}
@DELETE
@Path("{id}")
public void remove(@PathParam("id") Long id) {
this.sessionFactory = HibernateStuff.getInstance().getSessionFactory();
Session session
= sessionFactory.openSession();
Transaction tx = null;
tx = session.beginTransaction();
session.delete(find(id));
}
@GET
@Path("{id}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Note find(@PathParam("id") Long id) {
this.sessionFactory = HibernateStuff.getInstance().getSessionFactory();
Session session
= sessionFactory.openSession();
Transaction tx = null;
tx = session.beginTransaction();
Note note
= (Note) session.get(Note.class, id);
return note;
}
@GET
@Override
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Note> findAll() {
this.sessionFactory = HibernateStuff.getInstance().getSessionFactory();
Session session
= sessionFactory.openSession();
Criteria criteria = session.createCriteria(Note.class);
List notes = criteria.list();
List<Note> allnotes = new ArrayList();
notes.forEach((note) -> {
Note note1 = (Note) note;
allnotes.add(note1);
});
Collections.sort(allnotes);
return allnotes;
}
@GET
@Path("{from}/{to}")
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Note> findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
return super.findRange(new int[]{from, to});
}
@GET
@Path("count")
@Produces(MediaType.TEXT_PLAIN)
public String countREST() {
return String.valueOf(super.count());
}
@Override
protected EntityManager getEntityManager() {
return em;
}
public static Status strtost(String status) {
if (status.equals("STATUS_APPROVED")) {
return Status.STATUS_APPROVED;
}
if (status.equals("STATUS_PROCESSING")) {
return Status.STATUS_PROCESSING;
}
if (status.equals("STATUS_DONE")) {
return Status.STATUS_DONE;
}
return null;
}
}
| [
"[email protected]"
] | |
2eac07ca0dd672b22103506ba2bda1f0e3c02cde | a6f416835ce3b01139ec5b5415982de5db77e234 | /src/main/java/com/ruthtech/sorting/BubbleSorting.java | 8efff1c7c0b38b09b1178bd666fd593c6c8d485f | [] | no_license | ishmayelv/java-ds-algo | c233db1cab6bf0bf986bd2ccccc8ea457a26fcc2 | ff6c43f027b6839d94690332af2a03582133c66c | refs/heads/main | 2023-08-05T18:58:39.126894 | 2021-10-09T18:20:38 | 2021-10-09T18:20:38 | 302,204,805 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 720 | java | package com.ruthtech.sorting;
public class BubbleSorting {
public static void main(String[] args) {
// TODO Auto-generated method stub
int input[]= {5,6,3,1,8,7,2,4};
print(input);
print(fnBubbleSort(input));
}
private static void print(int input[]) {
for(int i:input)
System.out.print(" "+i);
System.out.println();
}
private static int[] fnBubbleSort(int input[]) {
int temp=0;
if (input==null || input.length<2)
return input;
else{
for(int i=0; i<input.length;i++) {
for(int j=0; j<input.length-1;j++){
if(input[j]> input[j+1]) {
temp = input[j];
input[j] =input[j+1];
input[j+1]=temp;
}
}
}
return input;
}
}
}
| [
"[email protected]"
] | |
f1daf97cae136c711b1d8bf2a15d29dfde3a3f30 | 5b6149d3120d83bf0750c21a87d1c8cad3d5973e | /Spring-boot-web-data-security-sba3/src/main/java/com/wellsfargo/batch5/pms/entity/CommisionEntity.java | 914f33ec694f7ba0ef3d60dd635bf12ff656a518 | [] | no_license | SumaTestGit/sba3 | ae412c701220952961d40b10524d07c52aa9c678 | af2bb0bfe7ccfc28e2cd1c5c1aa06e20584acd4e | refs/heads/main | 2023-02-10T13:05:09.531198 | 2021-01-03T06:52:45 | 2021-01-03T06:52:45 | 326,345,350 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,370 | java | package com.wellsfargo.batch5.pms.entity;
import java.time.LocalDate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="commission")
public class CommisionEntity {
@GeneratedValue
@Id
@Column(name="com_id")
private Integer commisionId;
@Column(name="commision_rate")
private final Double commissonRate = 0.02;
@Column(name="commision_value")
private Double commisionValue;
@Column(name="date")
private LocalDate date;
public CommisionEntity() {
}
public CommisionEntity(Integer commisionId, Double commisionValue, LocalDate date) {
super();
this.commisionId = commisionId;
this.commisionValue = commisionValue;
this.date = date;
}
public Integer getCommisionId() {
return commisionId;
}
public void setCommisionId(Integer commisionId) {
this.commisionId = commisionId;
}
public Double getCommisionValue() {
return commisionValue;
}
public void setCommisionValue(Double commisionValue) {
this.commisionValue = commisionValue;
}
public LocalDate getDate() {
return date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public Double getCommissonRate() {
return commissonRate;
}
}
| [
"[email protected]"
] | |
bdbf009241dee89f766db96205e4435fb806446d | 3cb74e5b6a8ea2297ed7dd7b225c2ff711ea7d57 | /queue/Test.java | a9fe364daa611230cb54edacbf74bf258c5254dc | [] | no_license | ys588281/ImmutableQueue | 2ed05b7e9740ca3a385f6aa58a545db711bff795 | db426d937315623ad9fb521bc38ccab1c48e3361 | refs/heads/master | 2020-05-27T10:07:09.292879 | 2019-05-25T17:01:30 | 2019-05-25T17:01:30 | 188,578,249 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 990 | java | package company.paypay.queue;
public class Test {
public static void main(String[] args) {
Queue<Integer> q = ImmutableQueue.getInstance();
try {
q = q.enQueue(1);
System.out.println(q.toString());
System.out.println("------");
q = q.enQueue(2);
System.out.println(q.toString());
System.out.println("------");
q = q.enQueue(3);
System.out.println(q.toString());
System.out.println("------");
q = q.deQueue();
System.out.println(q.toString());
System.out.println("------");
q = q.deQueue();
System.out.println(q.toString());
System.out.println("------");
q = q.enQueue(4);
System.out.println(q.toString());
System.out.println("------");
} catch (Exception e) {
System.out.println("Exception: " + e.getStackTrace());
}
}
}
| [
"[email protected]"
] | |
b97c0dd25821fce4fee595205486fcff47326d11 | 2bc2eadc9b0f70d6d1286ef474902466988a880f | /tags/mule-2.1.1/tests/functional/src/main/java/org/mule/tck/functional/FunctionalTestNotificationListener.java | 955fe6f519007f84fb4dace523d4021a8b5ea987 | [] | no_license | OrgSmells/codehaus-mule-git | 085434a4b7781a5def2b9b4e37396081eaeba394 | f8584627c7acb13efdf3276396015439ea6a0721 | refs/heads/master | 2022-12-24T07:33:30.190368 | 2020-02-27T19:10:29 | 2020-02-27T19:10:29 | 243,593,543 | 0 | 0 | null | 2022-12-15T23:30:00 | 2020-02-27T18:56:48 | null | UTF-8 | Java | false | false | 1,788 | java | /*
* $Id$
* --------------------------------------------------------------------------------------
* Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
*
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.tck.functional;
import org.mule.api.context.notification.CustomNotificationListener;
/**
* By implementing this listener interface and registering the object with the
* {@link org.mule.api.MuleContext#registerListener(org.mule.api.context.ServerNotificationListener)}
* You can receive {@link org.mule.tck.functional.FunctionalTestNotification}s from the
* {@link org.mule.tck.functional.FunctionalTestComponent}.
*
* This Notification contains the current MuleEventContext and reply message. The resource Identifier for this event
* is the service name that received the message. This means you can register to listen to Notifications from a
* selected {@link org.mule.tck.functional.FunctionalTestComponent}. i.e.
* <code>
* muleContext.registerListener(this, "*JmsTestCompoennt");
* </code>
*
* This registration would only receive {@link org.mule.tck.functional.FunctionalTestNotification} objects
* from components called 'MyJmsTestComponent' and 'YourJmsTestComponent' but not 'HerFileTestComponent'.
*
* To receive all notifications simply do -
* <code>
* muleContext.registerListener(this");
* </code>
*
* @see org.mule.tck.functional.FunctionalTestComponent
* @see org.mule.tck.functional.FunctionalTestNotificationListener
* @see org.mule.api.MuleContext
*/
public interface FunctionalTestNotificationListener extends CustomNotificationListener
{
// no methods
}
| [
"dfeist@bf997673-6b11-0410-b953-e057580c5b09"
] | dfeist@bf997673-6b11-0410-b953-e057580c5b09 |
6ff1bdbd59e3e9801182c9a48b0e621c152687f7 | 0c98aa5e4cb77230628d333d85a7078141522d09 | /OnlineMarket-ejb/src/main/java/com/onlinemarket/imp/AnnonceServiceImp.java | 5e89aea11d617574825cc47425b2f8e9e028592a | [] | no_license | usf077/OnlineMarket | 5f4d0863712048c65b09df63780d8753aca095fc | e9ff2438eed2f45931030e52a1e4f638581c7fb9 | refs/heads/master | 2021-01-10T02:09:17.035646 | 2017-01-04T15:00:32 | 2017-01-04T15:00:32 | 48,052,514 | 0 | 1 | null | 2015-12-18T19:40:07 | 2015-12-15T15:43:41 | Java | UTF-8 | Java | false | false | 12,894 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.onlinemarket.imp;
import com.onlinemarket.domain.dtos.AnnonceDTO;
import com.onlinemarket.domain.dtos.CategorieDTO;
import com.onlinemarket.domain.dtos.ProduitDTO;
import com.onlinemarket.domain.interfaces.AnnonceServiceInt;
import com.onlinemarket.entities.Annonce;
import com.onlinemarket.entities.Annonce_;
import com.onlinemarket.entities.Categorie;
import com.onlinemarket.entities.Categorie_;
import com.onlinemarket.entities.Produit;
import com.onlinemarket.entities.Produit_;
import com.onlinemarket.entities.User;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.Root;
/**
*
* @author ADMINIBM
*/
@Stateless
public class AnnonceServiceImp implements AnnonceServiceInt {
@PersistenceContext
private EntityManager em;
@Override
public List<CategorieDTO> getCategories() {
List<Categorie> lstc = em.createNamedQuery("Categorie.findAll").getResultList();
List<CategorieDTO> lstcr = new ArrayList<>();
for (Categorie c : lstc) {
lstcr.add(new CategorieDTO(c.getIdCat(), c.getNomC()));
}
return lstcr;
}
@Override
public List<AnnonceDTO> getAnnonces() {
List<Annonce> lsta = em.createNamedQuery("Annonce.findByEtatA").setParameter("etatA", "disponible").getResultList();
List<AnnonceDTO> lstar = new ArrayList<>();
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
for (Annonce a : lsta) {
AnnonceDTO adto = new AnnonceDTO(a.getIdAnnonce(), a.getNomA(), a.getDescriptionA(),
a.getDateCreation() != null ? df.format(a.getDateCreation()) : "",
a.getDateValidation() != null ? df.format(a.getDateValidation()) : "",
a.getDateMiseVente() != null ? df.format(a.getDateValidation()) : "",
a.getProduitCollection().size(), a.getEtatA());
for (Produit p : a.getProduitCollection()) {
if (adto.getLstProduit() == null) {
adto.setLstProduit(new ArrayList<ProduitDTO>());
}
adto.getLstProduit().add(new ProduitDTO(p.getIdProduit(), p.getIdCat() != null ? p.getIdCat().getIdCat() : 0, p.getCategorie(), p.getImage(), p.getDescriptionP(),
p.getDateMiseVente() != null ? df.format(p.getDateMiseVente()) : "", p.getPrix(), p.getImage()));
}
lstar.add(adto);
}
return lstar;
}
@Override
public int count(String txt, int idCategorie, String etat) {
// javax.persistence.criteria.CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
//javax.persistence.criteria.Root<Annonce> rt = cq.from(Annonce.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
javax.persistence.criteria.CriteriaQuery cq = cb.createQuery();
Root<Annonce> annonce = cq.from(Annonce.class);
Expression e = null;
Join<Annonce, Produit> produit = annonce.join(Annonce_.produitCollection);
Join<Produit, Categorie> categorie = produit.join(Produit_.idCat);
if (idCategorie != 0 && idCategorie != 2) {
e = cb.equal(categorie.get(Categorie_.idCat), idCategorie);
}
if (txt != null && !txt.isEmpty()) {
if (e == null) {
e = cb.or(cb.like(cb.lower(annonce.get(Annonce_.nomA)), "%" + txt.toLowerCase() + "%"), cb.like(cb.lower(annonce.get(Annonce_.descriptionA)), "%" + txt.toLowerCase() + "%"), cb.like(cb.lower(produit.get(Produit_.nomP)), "%" + txt.toLowerCase() + "%"),
cb.like(cb.lower(produit.get(Produit_.descriptionP)), "%" + txt.toLowerCase() + "%"));
} else {
e = cb.and(e, cb.or(cb.like(cb.lower(annonce.get(Annonce_.nomA)), "%" + txt.toLowerCase() + "%"), cb.like(cb.lower(annonce.get(Annonce_.descriptionA)), "%" + txt.toLowerCase() + "%"), cb.like(cb.lower(produit.get(Produit_.nomP)), "%" + txt.toLowerCase() + "%"),
cb.like(cb.lower(produit.get(Produit_.descriptionP)), "%" + txt.toLowerCase() + "%")));
}
}
if (etat != null && !etat.isEmpty()) {
if (e == null) {
e = cb.equal(annonce.get(Annonce_.etatA), etat);
} else {
e = cb.and(e, cb.equal(annonce.get(Annonce_.etatA), etat));
}
}
if (e!=null){
cq.where(e);
}
cq.select(annonce).distinct(true);
cq.select(em.getCriteriaBuilder().countDistinct(annonce));
javax.persistence.Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
}
@Override
public List<AnnonceDTO> findRange(String txt, int idCategorie, String etat, int[] range) {
CriteriaBuilder cb = em.getCriteriaBuilder();
Expression e=null;
javax.persistence.criteria.CriteriaQuery cq = cb.createQuery();
Root<Annonce> annonce = cq.from(Annonce.class);
// cq.select(cq.from(Annonce.class));
Join<Annonce, Produit> produit = annonce.join(Annonce_.produitCollection);
Join<Produit, Categorie> categorie = produit.join(Produit_.idCat);
if (idCategorie != 0 && idCategorie != 2) {
e = cb.equal(categorie.get(Categorie_.idCat), idCategorie);
}
if (txt != null && !txt.isEmpty()) {
if (e == null) {
e = cb.or(cb.like(cb.lower(annonce.get(Annonce_.nomA)), "%" + txt.toLowerCase() + "%"), cb.like(cb.lower(annonce.get(Annonce_.descriptionA)), "%" + txt.toLowerCase() + "%"), cb.like(cb.lower(produit.get(Produit_.nomP)), "%" + txt.toLowerCase() + "%"),
cb.like(cb.lower(produit.get(Produit_.descriptionP)), "%" + txt.toLowerCase() + "%"));
} else {
e = cb.and(e, cb.or(cb.like(cb.lower(annonce.get(Annonce_.nomA)), "%" + txt.toLowerCase() + "%"), cb.like(cb.lower(annonce.get(Annonce_.descriptionA)), "%" + txt.toLowerCase() + "%"), cb.like(cb.lower(produit.get(Produit_.nomP)), "%" + txt.toLowerCase() + "%"),
cb.like(cb.lower(produit.get(Produit_.descriptionP)), "%" + txt.toLowerCase() + "%")));
}
}
if (etat != null && !etat.isEmpty()) {
if (e == null) {
e = cb.equal(annonce.get(Annonce_.etatA), etat);
} else {
e = cb.and(e, cb.equal(annonce.get(Annonce_.etatA), etat));
}
}
if (e!=null){
cq.where(e);
}
cq.orderBy(cb.desc(annonce.get(Annonce_.dateValidation)));
cq.select(annonce).distinct(true);
javax.persistence.Query q = em.createQuery(cq);
q.setMaxResults(range[1] - range[0]);
q.setFirstResult(range[0]);
List<Annonce> lsta = q.getResultList();
List<AnnonceDTO> lstar = new ArrayList<>();
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
for (Annonce a : lsta) {
AnnonceDTO adto = new AnnonceDTO(a.getIdAnnonce(), a.getNomA(), a.getDescriptionA(),
a.getDateCreation() != null ? df.format(a.getDateCreation()) : "",
a.getDateValidation() != null ? df.format(a.getDateValidation()) : "",
a.getDateMiseVente() != null ? df.format(a.getDateValidation()) : "",
a.getProduitCollection().size(), a.getEtatA());
for (Produit p : a.getProduitCollection()) {
if (adto.getLstProduit() == null) {
adto.setLstProduit(new ArrayList<ProduitDTO>());
}
adto.setPrix(adto.getPrix() + p.getPrix());
adto.getLstProduit().add(new ProduitDTO(p.getIdProduit(), p.getIdCat() != null ? p.getIdCat().getIdCat() : 0, p.getCategorie(), p.getImage(), p.getDescriptionP(),
p.getDateMiseVente() != null ? df.format(p.getDateMiseVente()) : "", p.getPrix(), p.getImage()));
}
lstar.add(adto);
}
return lstar;
}
@Override
public int CreateAnnonce(AnnonceDTO a) {
Annonce ae = new Annonce();
// List<Produit> lstPe = new ArrayList<Produit>();
ae.setNomA(a.getLibelle());
ae.setDescriptionA(a.getDescription());
ae.setDateCreation(new Date());
User u = em.find(User.class, a.getIdUtilisateur());
if (u != null) {
ae.setIdUser(u);
}
ae.setEtatA("Draft");
// for (ProduitDTO p : a.getLstProduit()) {
// Produit pe = new Produit();
// pe.setNomP(p.getNom());
// pe.setDescriptionP(p.getDescription());
// Categorie c = em.find(Categorie.class, p.getIdCategorie());
// if (c != null) {
// pe.setIdCat(c);
// }
// pe.setIdAnnonce(ae);
// pe.setImage(p.getImgesUrl());
// pe.setDateMiseVente(new Date(p.getDateMiseEnVente()));
// lstPe.add(pe);
// }
// ae.setProduitCollection(lstPe);
em.persist(ae);
em.flush();
a.setIdentifiant(ae.getIdAnnonce());
return ae.getIdAnnonce();
}
@Override
public AnnonceDTO UpdateAnnonce(AnnonceDTO a) {
Annonce ae = em.find(Annonce.class, a.getIdentifiant());
ae.setNomA(a.getLibelle());
ae.setDescriptionA(a.getDescription());
ae.setEtatA(a.getEtat());
ae.setDateValidation(new Date(a.getDateValidation()));
ae.setDateMiseVente(new Date(a.getDateMiseEnVente()));
List<ProduitDTO> lstP = a.getLstProduit();
List<Produit> lstPe = new ArrayList<Produit>();
Produit pe;
if (ae.getProduitCollection() != null || ae.getProduitCollection().size() == 0) {
for (ProduitDTO p : a.getLstProduit()) {
pe = new Produit();
pe.setNomP(p.getNom());
pe.setDescriptionP(p.getDescription());
Categorie c = em.find(Categorie.class, p.getIdCategorie());
if (c != null) {
pe.setIdCat(c);
}
pe.setIdAnnonce(ae);
pe.setImage(p.getImgesUrl());
pe.setDateMiseVente(new Date(p.getDateMiseEnVente()));
lstPe.add(pe);
}
ae.setProduitCollection(lstPe);
}
em.merge(ae);
return a;
}
@Override
public AnnonceDTO getAnnonceById(int id) {
Annonce a = em.find(Annonce.class, id);
AnnonceDTO adto = null;
if (a != null) {
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
adto = new AnnonceDTO(a.getIdAnnonce(), a.getNomA(), a.getDescriptionA(),
a.getDateCreation() != null ? df.format(a.getDateCreation()) : "",
a.getDateValidation() != null ? df.format(a.getDateValidation()) : "",
a.getDateMiseVente() != null ? df.format(a.getDateValidation()) : "",
a.getProduitCollection().size(), a.getEtatA());
for (Produit p : a.getProduitCollection()) {
if (adto.getLstProduit() == null) {
adto.setLstProduit(new ArrayList<ProduitDTO>());
}
adto.setPrix(adto.getPrix() + p.getPrix());
adto.getLstProduit().add(new ProduitDTO(p.getIdProduit(), p.getIdCat() != null ? p.getIdCat().getIdCat() : 0, p.getCategorie(), p.getNomP(), p.getDescriptionP(),
p.getDateMiseVente() != null ? df.format(p.getDateMiseVente()) : "", p.getPrix(), p.getImage()));
}
}
return adto;
}
@Override
public int ValiderAnnonce(int identifiant, Date dateValidation) {
Annonce a = em.find(Annonce.class, identifiant);
if (a!=null){
a.setEtatA("Disponible");
a.setDateValidation(dateValidation);
a.setDateMiseVente(dateValidation);
em.merge(a);
return a.getIdAnnonce();
}
return -1;
}
}
| [
"ADMINIBM@ADMINIB-FJVISA5"
] | ADMINIBM@ADMINIB-FJVISA5 |
f51ee39aa385bcb5c11bb1e3236db7fb1845cf6d | d94e3ee11ff34d114b2ee67c5281cce71be748fd | /Circumference of a circle/Main.java | 4d92a7cb448331203ff1457c180a66421b221b72 | [] | no_license | sourabhnarake/Playground | b67ec58e9b46d80129c86ad1e4c2463768b61f92 | 2bf125ba3c177cb7e31498e44d7f081cc83ab747 | refs/heads/master | 2022-12-27T11:12:24.253859 | 2020-10-13T10:42:39 | 2020-10-13T10:42:39 | 270,556,303 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 59 | java | # TCS NQT
r = float(input())
ci = 2*3.14*r
print('%.2f'%ci) | [
"[email protected]"
] | |
db47480b787d7a3d3650774ab037e7dc92bc2035 | 3a5d2a5cc69c68498a3866bef9691fa825bcde1e | /library/src/main/java/com/github/sundeepk/compactcalendarview/WeekUtils.java | e10512a7a4800653bb30e9e0d16d7f3efb8ba402 | [] | no_license | aniketkumar2808/TripToEasy_Latest | 3ec086563efb6010d77735178c72b91ce68c4006 | f66481b31fe51f2dcb7307905f2ae35001b6fbdf | refs/heads/main | 2023-06-10T21:10:38.581956 | 2021-07-01T12:20:51 | 2021-07-01T12:20:51 | 381,992,301 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,559 | java | package com.github.sundeepk.compactcalendarview;
import java.text.DateFormatSymbols;
import java.util.Arrays;
import java.util.Locale;
public class WeekUtils {
static String[] getWeekdayNames(Locale locale, int day, boolean useThreeLetterAbbreviation){
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
String[] dayNames = dateFormatSymbols.getShortWeekdays();
// String[] dayNames = dateFormatSymbols.getWeekdays();
if (dayNames == null) {
throw new IllegalStateException("Unable to determine weekday names from default locale");
}
if (dayNames.length != 8) {
throw new IllegalStateException("Expected weekday names from default locale to be of size 7 but: "
+ Arrays.toString(dayNames) + " with size " + dayNames.length + " was returned.");
}
String[] weekDayNames = new String[7];
String[] weekDaysFromSunday = {dayNames[1], dayNames[2], dayNames[3], dayNames[4], dayNames[5], dayNames[6], dayNames[7]};
for (int currentDay = day - 1, i = 0; i <= 6; i++, currentDay++) {
currentDay = currentDay >= 7 ? 0 : currentDay;
weekDayNames[i] = weekDaysFromSunday[currentDay];
}
if (!useThreeLetterAbbreviation) {
for (int i = 0; i < weekDayNames.length; i++) {
// weekDayNames[i] = weekDayNames[i].substring(0, 1);
weekDayNames[i] = weekDayNames[i];// changed by me
}
}
return weekDayNames;
}
}
| [
"[email protected]"
] | |
b9e5804d840290261333b2af56a60d2ed1967134 | 96eac7ac412ced564292d8c52c81cd26aaa1b2db | /src/main/java/problem/KeyboardRow.java | b077f8fdf19afd0f11442539a2c5b01f437c9d11 | [] | no_license | viktar-charnarutski/algorithms | 5789b14743578dcdacd4a2277b14a78b088da5ac | 935e33f00cf8d01b1fc911f971b15e5e50bfe92f | refs/heads/master | 2021-04-15T10:23:51.905475 | 2018-10-31T15:25:46 | 2018-10-31T15:25:46 | 82,727,594 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,599 | java | package problem;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
/**
* 500. Keyboard Row
* <p>
* Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard.
* <p>
* Example 1:
* Input: ["Hello", "Alaska", "Dad", "Peace"]
* Output: ["Alaska", "Dad"]
* Note:
* You may use one character in the keyboard more than once.
* You may assume the input string will only contain letters of alphabet.
*/
public class KeyboardRow {
public String[] findWords(String[] words) {
if (words == null || words.length < 1) return new String[0];
List<String> res = new ArrayList<>();
for (String w : words) {
if (composedByFirstRow(w)) {
res.add(w);
continue;
}
if (composedBySecondRow(w)) {
res.add(w);
continue;
}
if (composedByThirdRow(w)) {
res.add(w);
}
}
return res.toArray(new String[res.size()]);
}
public String[] findWordsSlow(String[] words) {
return Stream.of(words).filter(s -> composedByFirstRow(s) || composedBySecondRow(s) || composedByThirdRow(s)).toArray(String[]::new);
}
private static boolean composedByFirstRow(String w) {
return composedByRow(w, FIRST_ROW);
}
private static boolean composedBySecondRow(String w) {
return composedByRow(w, SECOND_ROW);
}
private static boolean composedByThirdRow(String w) {
return composedByRow(w, THIRD_ROW);
}
private static boolean composedByRow(String w, Set<Character> row) {
for (char c : w.toCharArray()) {
if (!row.contains(c))
return false;
}
return true;
}
private final static Set<Character> FIRST_ROW = new HashSet<>();
private final static Set<Character> SECOND_ROW = new HashSet<>();
private final static Set<Character> THIRD_ROW = new HashSet<>();
static {
FIRST_ROW.add('q');
FIRST_ROW.add('w');
FIRST_ROW.add('e');
FIRST_ROW.add('r');
FIRST_ROW.add('t');
FIRST_ROW.add('y');
FIRST_ROW.add('u');
FIRST_ROW.add('i');
FIRST_ROW.add('o');
FIRST_ROW.add('p');
FIRST_ROW.add('Q');
FIRST_ROW.add('W');
FIRST_ROW.add('E');
FIRST_ROW.add('R');
FIRST_ROW.add('T');
FIRST_ROW.add('Y');
FIRST_ROW.add('U');
FIRST_ROW.add('I');
FIRST_ROW.add('O');
FIRST_ROW.add('P');
SECOND_ROW.add('a');
SECOND_ROW.add('s');
SECOND_ROW.add('d');
SECOND_ROW.add('f');
SECOND_ROW.add('g');
SECOND_ROW.add('h');
SECOND_ROW.add('j');
SECOND_ROW.add('k');
SECOND_ROW.add('l');
SECOND_ROW.add('A');
SECOND_ROW.add('S');
SECOND_ROW.add('D');
SECOND_ROW.add('F');
SECOND_ROW.add('G');
SECOND_ROW.add('H');
SECOND_ROW.add('J');
SECOND_ROW.add('K');
SECOND_ROW.add('L');
THIRD_ROW.add('z');
THIRD_ROW.add('x');
THIRD_ROW.add('c');
THIRD_ROW.add('v');
THIRD_ROW.add('b');
THIRD_ROW.add('n');
THIRD_ROW.add('m');
THIRD_ROW.add('Z');
THIRD_ROW.add('X');
THIRD_ROW.add('C');
THIRD_ROW.add('V');
THIRD_ROW.add('B');
THIRD_ROW.add('N');
THIRD_ROW.add('M');
}
}
| [
"[email protected]"
] | |
c8087986f56bd60c6403a9ef4bdc362d323ab245 | c80600738fa56120417971e3fcbc06b3b6ca3d19 | /src/main/java/meta/working/InfoMainLayoutDTO.java | d18b43fbdf926ed4fedec2720873fde5d541afc0 | [
"Apache-2.0"
] | permissive | luHub/learningTool | b32ab9c49158e8cdab496b255f311b0c798b6287 | 4988b169967e5f995d80a8cb99c02224d041e16d | refs/heads/master | 2022-11-20T20:40:25.963501 | 2019-12-15T20:42:55 | 2019-12-15T20:42:55 | 67,649,494 | 0 | 0 | null | 2022-11-15T23:52:42 | 2016-09-07T22:54:52 | Java | UTF-8 | Java | false | false | 267 | java | package meta.working;
public class InfoMainLayoutDTO implements ConvertableToJSON
{
private float splitPanePos;
public float getSplitPanePos() {
return splitPanePos;
}
public void setSplitPanePos(float splitPanePos) {
this.splitPanePos = splitPanePos;
}
} | [
"[email protected]"
] | |
ab8b4614c17fabe21184fdcc986c65b471339db3 | cc0369609bd82f11d4a4a807b3678ceeab94cce8 | /app/src/main/java/com/example/recipe/sort/SortViewModel.java | 190770d2eddf52423ea90c60cc58cd667a44c503 | [] | no_license | Yanlan-Li/Recipe | 5cb4b49186728aca4512803faebfca4451892c69 | abcf8ceb7f07dee377320721074a9195145e037f | refs/heads/master | 2023-04-14T17:04:57.755506 | 2021-04-29T09:49:06 | 2021-04-29T09:49:06 | 362,307,645 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 765 | java | package com.example.recipe.sort;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import com.example.recipe.adapter.SearchResultAdapter;
import com.example.recipe.adapter.SortAdapter;
import com.example.recipe.databinding.FragmentSearchResultBinding;
import com.example.recipe.databinding.FragmentSortBinding;
public class SortViewModel extends AndroidViewModel {
SortModel sortModel=new SortModel();
public SortViewModel(@NonNull Application application, @NonNull FragmentSortBinding binding){
super(application);
SortAdapter adapter=(SortAdapter)binding.classifyRv.getAdapter();
assert adapter != null;
adapter.setList(sortModel.getSortList());
}
}
| [
"[email protected]"
] | |
27b01d0d2e24cd6ff8623cffd17ec7cdc53e4273 | 08bdd164c174d24e69be25bf952322b84573f216 | /opencores/client/foundation classes/j2sdk-1_4_2-src-scsl/j2se/src/windows/classes/sun/print/Win32PrintJob.java | 5efe2510b888ed4d4467446a2393430027b222da | [] | no_license | hagyhang/myforthprocessor | 1861dcabcf2aeccf0ab49791f510863d97d89a77 | 210083fe71c39fa5d92f1f1acb62392a7f77aa9e | refs/heads/master | 2021-05-28T01:42:50.538428 | 2014-07-17T14:14:33 | 2014-07-17T14:14:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,845 | java | /*
* @(#)Win32PrintJob.java 1.19 03/01/23
*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package sun.print;
import java.net.URI;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.Reader;
import java.net.URL;
import java.util.Vector;
import javax.print.CancelablePrintJob;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import javax.print.PrintException;
import javax.print.event.PrintJobEvent;
import javax.print.event.PrintJobListener;
import javax.print.event.PrintJobAttributeListener;
import javax.print.attribute.Attribute;
import javax.print.attribute.AttributeSet;
import javax.print.attribute.AttributeSetUtilities;
import javax.print.attribute.DocAttributeSet;
import javax.print.attribute.HashPrintJobAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintJobAttribute;
import javax.print.attribute.PrintJobAttributeSet;
import javax.print.attribute.PrintRequestAttribute;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.DocumentName;
import javax.print.attribute.standard.Fidelity;
import javax.print.attribute.standard.JobName;
import javax.print.attribute.standard.JobOriginatingUserName;
import javax.print.attribute.standard.Media;
import javax.print.attribute.standard.MediaSize;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.RequestingUserName;
import javax.print.attribute.standard.Destination;
import java.awt.print.*;
public class Win32PrintJob implements CancelablePrintJob {
transient private Vector jobListeners;
transient private Vector attrListeners;
transient private Vector listenedAttributeSets;
private Win32PrintService service;
private boolean fidelity;
private boolean printing = false;
private boolean printReturned = false;
private PrintRequestAttributeSet reqAttrSet = null;
private PrintJobAttributeSet jobAttrSet = null;
private PrinterJob job;
private Doc doc;
/* these variables used globally to store reference to the print
* data retrieved as a stream. On completion these are always closed
* if non-null.
*/
private InputStream instream = null;
private Reader reader = null;
/* default values overridden by those extracted from the attributes */
private String jobName = "Java Printing";
private int copies = 0;
private MediaSizeName mediaName = null;
private MediaSize mediaSize = null;
private OrientationRequested orient = null;
/* print job handle used by native code */
private long hPrintJob;
/* buffer length for printing raw data */
private static final int PRINTBUFFERLEN = 8192;
Win32PrintJob(Win32PrintService service) {
this.service = service;
}
public PrintService getPrintService() {
return service;
}
public PrintJobAttributeSet getAttributes() {
synchronized (this) {
if (jobAttrSet == null) {
/* just return an empty set until the job is submitted */
PrintJobAttributeSet jobSet = new HashPrintJobAttributeSet();
return AttributeSetUtilities.unmodifiableView(jobSet);
} else {
return jobAttrSet;
}
}
}
public void addPrintJobListener(PrintJobListener listener) {
synchronized (this) {
if (listener == null) {
return;
}
if (jobListeners == null) {
jobListeners = new Vector();
}
jobListeners.add(listener);
}
}
public void removePrintJobListener(PrintJobListener listener) {
synchronized (this) {
if (listener == null || jobListeners == null ) {
return;
}
jobListeners.remove(listener);
if (jobListeners.isEmpty()) {
jobListeners = null;
}
}
}
/* Closes any stream already retrieved for the data.
* We want to avoid unnecessarily asking the Doc to create a stream only
* to get a reference in order to close it because the job failed.
* If the representation class is itself a "stream", this
* closes that stream too.
*/
private void closeDataStreams() {
if (doc == null) {
return;
}
Object data = null;
try {
data = doc.getPrintData();
} catch (IOException e) {
return;
}
if (instream != null) {
try {
instream.close();
} catch (IOException e) {
} finally {
instream = null;
}
}
else if (reader != null) {
try {
reader.close();
} catch (IOException e) {
} finally {
reader = null;
}
}
else if (data instanceof InputStream) {
try {
((InputStream)data).close();
} catch (IOException e) {
}
}
else if (data instanceof Reader) {
try {
((Reader)data).close();
} catch (IOException e) {
}
}
}
private void notifyEvent(int reason) {
/* since this method should always get called, here's where
* we will perform the clean up of any data stream supplied.
*/
switch (reason) {
case PrintJobEvent.DATA_TRANSFER_COMPLETE:
case PrintJobEvent.JOB_CANCELED :
case PrintJobEvent.JOB_FAILED :
case PrintJobEvent.NO_MORE_EVENTS :
case PrintJobEvent.JOB_COMPLETE :
closeDataStreams();
}
synchronized (this) {
if (jobListeners != null) {
PrintJobListener listener;
PrintJobEvent event = new PrintJobEvent(this, reason);
for (int i = 0; i < jobListeners.size(); i++) {
listener = (PrintJobListener)(jobListeners.elementAt(i));
switch (reason) {
case PrintJobEvent.JOB_CANCELED :
listener.printJobCanceled(event);
break;
case PrintJobEvent.JOB_FAILED :
listener.printJobFailed(event);
break;
case PrintJobEvent.DATA_TRANSFER_COMPLETE :
listener.printDataTransferCompleted(event);
break;
case PrintJobEvent.NO_MORE_EVENTS :
listener.printJobNoMoreEvents(event);
break;
default:
break;
}
}
}
}
}
public void addPrintJobAttributeListener(
PrintJobAttributeListener listener,
PrintJobAttributeSet attributes) {
synchronized (this) {
if (listener == null) {
return;
}
if (attrListeners == null) {
attrListeners = new Vector();
listenedAttributeSets = new Vector();
}
attrListeners.add(listener);
if (attributes == null) {
attributes = new HashPrintJobAttributeSet();
}
listenedAttributeSets.add(attributes);
}
}
public void removePrintJobAttributeListener(
PrintJobAttributeListener listener) {
synchronized (this) {
if (listener == null || attrListeners == null ) {
return;
}
int index = attrListeners.indexOf(listener);
if (index == -1) {
return;
} else {
attrListeners.remove(index);
listenedAttributeSets.remove(index);
if (attrListeners.isEmpty()) {
attrListeners = null;
listenedAttributeSets = null;
}
}
}
}
public void print(Doc doc, PrintRequestAttributeSet attributes)
throws PrintException {
synchronized (this) {
if (printing) {
throw new PrintException("already printing");
} else {
printing = true;
}
}
this.doc = doc;
/* check if the parameters are valid before doing much processing */
DocFlavor flavor = doc.getDocFlavor();
Object data;
try {
data = doc.getPrintData();
} catch (IOException e) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("can't get print data: " + e.toString());
}
if (flavor == null || (!service.isDocFlavorSupported(flavor))) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobFlavorException("invalid flavor", flavor);
}
initializeAttributeSets(doc, attributes);
getAttributeValues(flavor);
String repClassName = flavor.getRepresentationClassName();
if (flavor.equals(DocFlavor.INPUT_STREAM.GIF) ||
flavor.equals(DocFlavor.INPUT_STREAM.JPEG) ||
flavor.equals(DocFlavor.INPUT_STREAM.PNG) ||
flavor.equals(DocFlavor.BYTE_ARRAY.GIF) ||
flavor.equals(DocFlavor.BYTE_ARRAY.JPEG) ||
flavor.equals(DocFlavor.BYTE_ARRAY.PNG)) {
try {
instream = doc.getStreamForBytes();
printableJob(new ImagePrinter(instream));
service.wakeNotifier();
return;
} catch (ClassCastException cce) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(cce);
} catch (IOException ioe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(ioe);
}
} else if (flavor == DocFlavor.URL.GIF ||
flavor == DocFlavor.URL.JPEG ||
flavor == DocFlavor.URL.PNG) {
try {
printableJob(new ImagePrinter((URL)data));
service.wakeNotifier();
return;
} catch (ClassCastException cce) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(cce);
}
} else if (repClassName.equals("java.awt.print.Pageable")) {
try {
pageableJob((Pageable)doc.getPrintData());
service.wakeNotifier();
return;
} catch (ClassCastException cce) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(cce);
} catch (IOException ioe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(ioe);
}
} else if (repClassName.equals("java.awt.print.Printable")) {
try {
printableJob((Printable)doc.getPrintData());
service.wakeNotifier();
return;
} catch (ClassCastException cce) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(cce);
} catch (IOException ioe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(ioe);
}
} else if (repClassName.equals("[B") ||
repClassName.equals("java.io.InputStream") ||
repClassName.equals("java.net.URL")) {
if (repClassName.equals("java.net.URL")) {
URL url = (URL)data;
try {
instream = url.openStream();
} catch (IOException e) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(e.toString());
}
} else {
try {
instream = doc.getStreamForBytes();
} catch (IOException ioe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(ioe.toString());
}
}
if (!startPrintRawData(service.getName())) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("Print job failed to start.");
}
BufferedInputStream bin = new BufferedInputStream(instream);
int bread = 0;
try {
byte[] buffer = new byte[PRINTBUFFERLEN];
while ((bread = bin.read(buffer, 0, PRINTBUFFERLEN)) >=0) {
if (!printRawData(buffer, bread)) {
bin.close();
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException ("Problem while spooling data");
}
}
bin.close();
if (!endPrintRawData()) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("Print job failed to close properly.");
}
notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
} catch (IOException e) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException (e.toString());
} finally {
notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
}
} else {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("unrecognized class: "+repClassName);
}
service.wakeNotifier();
}
public void printableJob(Printable printable) throws PrintException {
try {
synchronized(this) {
if (job != null) { // shouldn't happen
throw new PrintException("already printing");
} else {
job = new sun.awt.windows.WPrinterJob();
}
}
PrintService svc = getPrintService();
job.setPrintService(svc);
if (copies == 0) {
Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class);
copies = c.getValue();
}
if (mediaName == null) {
Object media = svc.getDefaultAttributeValue(Media.class);
if (media instanceof MediaSizeName) {
mediaName = (MediaSizeName) media;
mediaSize = MediaSize.getMediaSizeForName(mediaName);
}
}
if (orient == null) {
orient =
(OrientationRequested)svc.getDefaultAttributeValue(OrientationRequested.class);
}
job.setCopies(copies);
job.setJobName(jobName);
PageFormat pf = new PageFormat();
if (mediaSize != null) {
Paper p = new Paper();
p.setSize(mediaSize.getX(MediaSize.INCH)*72.0,
mediaSize.getY(MediaSize.INCH)*72.0);
p.setImageableArea(72.0, 72.0, p.getWidth()-144.0,
p.getHeight()-144.0);
pf.setPaper(p);
}
if (orient == OrientationRequested.REVERSE_LANDSCAPE) {
pf.setOrientation(PageFormat.REVERSE_LANDSCAPE);
} else if (orient == OrientationRequested.LANDSCAPE) {
pf.setOrientation(PageFormat.LANDSCAPE);
}
job.setPrintable(printable, pf);
job.print(reqAttrSet);
notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
return;
} catch (PrinterException pe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(pe);
} finally {
printReturned = true;
notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
}
}
public void pageableJob(Pageable pageable) throws PrintException {
try {
synchronized(this) {
if (job != null) { // shouldn't happen
throw new PrintException("already printing");
} else {
job = new sun.awt.windows.WPrinterJob();
}
}
PrintService svc = getPrintService();
job.setPrintService(svc);
if (copies == 0) {
Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class);
copies = c.getValue();
}
job.setCopies(copies);
job.setJobName(jobName);
job.setPageable(pageable);
job.print(reqAttrSet);
notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
return;
} catch (PrinterException pe) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(pe);
} finally {
printReturned = true;
notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
}
}
/* There's some inefficiency here as the job set is created even though
* it may never be requested.
*/
private synchronized void
initializeAttributeSets(Doc doc, PrintRequestAttributeSet reqSet) {
reqAttrSet = new HashPrintRequestAttributeSet();
jobAttrSet = new HashPrintJobAttributeSet();
Attribute[] attrs;
if (reqSet != null) {
reqAttrSet.addAll(reqSet);
attrs = reqSet.toArray();
for (int i=0; i<attrs.length; i++) {
if (attrs[i] instanceof PrintJobAttribute) {
jobAttrSet.add(attrs[i]);
}
}
}
DocAttributeSet docSet = doc.getAttributes();
if (docSet != null) {
attrs = docSet.toArray();
for (int i=0; i<attrs.length; i++) {
if (attrs[i] instanceof PrintRequestAttribute) {
reqAttrSet.add(attrs[i]);
}
if (attrs[i] instanceof PrintJobAttribute) {
jobAttrSet.add(attrs[i]);
}
}
}
/* add the user name to the job */
String userName = "";
try {
userName = System.getProperty("user.name");
} catch (SecurityException se) {
}
if (userName == null || userName.equals("")) {
RequestingUserName ruName =
(RequestingUserName)reqSet.get(RequestingUserName.class);
if (ruName != null) {
jobAttrSet.add(
new JobOriginatingUserName(ruName.getValue(),
ruName.getLocale()));
} else {
jobAttrSet.add(new JobOriginatingUserName("", null));
}
} else {
jobAttrSet.add(new JobOriginatingUserName(userName, null));
}
/* if no job name supplied use doc name (if supplied), if none and
* its a URL use that, else finally anything .. */
if (jobAttrSet.get(JobName.class) == null) {
JobName jobName;
if (docSet != null && docSet.get(DocumentName.class) != null) {
DocumentName docName =
(DocumentName)docSet.get(DocumentName.class);
jobName = new JobName(docName.getValue(), docName.getLocale());
jobAttrSet.add(jobName);
} else {
String str = "JPS Job:" + doc;
try {
Object printData = doc.getPrintData();
if (printData instanceof URL) {
str = ((URL)(doc.getPrintData())).toString();
}
} catch (IOException e) {
}
jobName = new JobName(str, null);
jobAttrSet.add(jobName);
}
}
jobAttrSet = AttributeSetUtilities.unmodifiableView(jobAttrSet);
}
private void getAttributeValues(DocFlavor flavor) throws PrintException {
if (reqAttrSet.get(Fidelity.class) == Fidelity.FIDELITY_TRUE) {
fidelity = true;
} else {
fidelity = false;
}
Class category;
Attribute [] attrs = reqAttrSet.toArray();
for (int i=0; i<attrs.length; i++) {
Attribute attr = attrs[i];
category = attr.getCategory();
if (fidelity == true) {
if (!service.isAttributeCategorySupported(category)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported category: " + category, category, null);
} else if
(!service.isAttributeValueSupported(attr, flavor, null)) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintJobAttributeException(
"unsupported attribute: " + attr, null, attr);
}
}
if (category == Destination.class) {
URI uri = ((Destination)attr).getURI();
if (!"file".equals(uri.getScheme())) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException("Not a file: URI");
} else {
String mDestination;
try {
mDestination = (new File(uri)).getPath();
} catch (Exception e) {
throw new PrintException(e);
}
// check write access
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
security.checkWrite(mDestination);
} catch (SecurityException se) {
notifyEvent(PrintJobEvent.JOB_FAILED);
throw new PrintException(se);
}
}
}
} else if (category == JobName.class) {
jobName = ((JobName)attr).getValue();
} else if (category == Copies.class) {
copies = ((Copies)attr).getValue();
} else if (category == Media.class) {
if (attr instanceof MediaSizeName) {
mediaName = (MediaSizeName)attr;
// If requested MediaSizeName is not supported,
// get the corresponding media size - this will
// be used to create a new PageFormat.
if (!service.isAttributeValueSupported(attr, null, null)) {
mediaSize = MediaSize.getMediaSizeForName(mediaName);
}
}
} else if (category == OrientationRequested.class) {
orient = (OrientationRequested)attr;
}
}
}
private native boolean startPrintRawData(String printerName);
private native boolean printRawData(byte[] data, int count);
private native boolean endPrintRawData();
/* Cancel PrinterJob jobs that haven't yet completed. */
public void cancel() throws PrintException {
synchronized (this) {
if (!printing) {
throw new PrintException("Job is not yet submitted.");
} else if (job != null && !printReturned) {
job.cancel();
notifyEvent(PrintJobEvent.JOB_CANCELED);
return;
} else {
throw new PrintException("Job could not be cancelled.");
}
}
}
}
| [
"[email protected]"
] | |
48754b1e3ad98821380f63ce8c2712fae9f92d18 | 1e105b9e1458ea38094a5ad59170cb7eb68c3a32 | /src/com/itmo/collections/inner/UserGenerator.java | 1233a049533789e27553b4bb13d522a853679448 | [] | no_license | dapastushenko/dapastushenkoITMONew | 80d29c6beda3fd6c2613d15f786d18456e6699c8 | b8af9fb163608946257dc9931f8fc92512da2c1b | refs/heads/master | 2021-08-31T07:57:12.536634 | 2017-12-20T18:03:57 | 2017-12-20T18:03:57 | 109,152,011 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,463 | java | package com.itmo.collections.inner;
import java.util.*;
/**
* Created by xmitya on 20.10.16.
*/
public class UserGenerator {
private static final List<String> COMPANIES = Arrays.asList("SpaceX", "Gazprom", "ITMO", "Lukoil", "TSystems");
private static final List<String> NAMES = Arrays.asList("Bob", "Alice", "Nick", "Ted", "Quentin", "David", "Zack", "Stacy", "Helen", "Julia");
private static final int MIN_AGE = 21;
private static final int MAX_AGE = 65;
private static final int MIN_SALARY = 15_000;
private static final int MAX_SALARY = 100_000;
public static List<User> generate(int num) {
if (num <= 0)
return Collections.emptyList();
List<User> users = new ArrayList<>(num);
Random rnd = new Random();
for (int i = 0; i < num; i++) {
users.add(new User(
NAMES.get(rnd.nextInt(NAMES.size())),
generateInRange(MIN_AGE, MAX_AGE, rnd),
round(generateInRange(MIN_SALARY, MAX_SALARY, rnd), 1000),
COMPANIES.get(rnd.nextInt(COMPANIES.size()))
));
}
return users;
}
private static int generateInRange(int min, int max, Random rnd) {
int res = -1;
while (res < min)
res = rnd.nextInt(max + 1);
return res;
}
private static int round(int num, int roundTo) {
return num / roundTo * roundTo;
}
}
| [
"[email protected]"
] | |
67e290e6c382fcbf08462ad4fc568f9f095db9eb | 2febdc8f9af81322e6285cb0975d7dca587dd8fe | /tops-eterm-interface/tz-eterm-interface-service/src/main/java/com/travelzen/etermface/service/ticket/IRawResultProvider.java | fc3453406601764cf51682a3eca29ad0226b48c5 | [] | no_license | Lixianshengchao/tzleft | c461594b5d09f74b5279d0976ad8e34e1d27f357 | 159edd11f9d5945703d9b9f36c0e116a45674e5c | refs/heads/master | 2020-07-12T13:35:33.195721 | 2016-06-12T06:49:03 | 2016-06-12T06:49:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 112 | java | package com.travelzen.etermface.service.ticket;
public interface IRawResultProvider {
String getString();
}
| [
"[email protected]"
] | |
3c604be087ea12e4e9a83b88a80fb4bffefeb1bb | 1327665ddac4a831bd402d3ea6d203042d59e408 | /common/src/main/java/com/tuwan/common/utils/runtimepermissions/PermissionsManager.java | ec189d3b1846cf059f2b4de88e7fb8673d6bcfb5 | [] | no_license | 767954322/Android2 | 7dfeb522e087e75eabd4ce56230f965f1a794d64 | c542bc326c61f74a38f22bb6ae427d5af5da1b54 | refs/heads/master | 2020-03-19T01:19:57.837798 | 2018-05-31T05:52:14 | 2018-05-31T05:52:14 | 135,538,043 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,886 | java | /**
* Copyright 2015 Anthony Restaino
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing
permissions and limitations under the License.
*/
package com.tuwan.common.utils.runtimepermissions;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.util.Log;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* A class to help you manage your permissions simply.
*/
public class PermissionsManager {
private static final String TAG = PermissionsManager.class.getSimpleName();
private final Set<String> mPendingRequests = new HashSet<String>(1);
private final Set<String> mPermissions = new HashSet<String>(1);
private final List<WeakReference<PermissionsResultAction>> mPendingActions = new ArrayList<WeakReference<PermissionsResultAction>>(1);
private static PermissionsManager mInstance = null;
public static PermissionsManager getInstance() {
if (mInstance == null) {
mInstance = new PermissionsManager();
}
return mInstance;
}
private PermissionsManager() {
initializePermissionsMap();
}
/**
* This method uses reflection to read all the permissions in the Manifest class.
* This is necessary because some permissions do not exist on older versions of Android,
* since they do not exist, they will be denied when you check whether you have permission
* which is problematic since a new permission is often added where there was no previous
* permission required. We initialize a Set of available permissions and check the set
* when checking if we have permission since we want to know when we are denied a permission
* because it doesn't exist yet.
*/
private synchronized void initializePermissionsMap() {
Field[] fields = Manifest.permission.class.getFields();
for (Field field : fields) {
String name = null;
try {
name = (String) field.get("");
} catch (IllegalAccessException e) {
Log.e(TAG, "Could not access field", e);
}
mPermissions.add(name);
}
}
/**
* This method retrieves all the permissions declared in the application's manifest.
* It returns a non null array of permisions that can be declared.
*
* @param activity the Activity necessary to check what permissions we have.
* @return a non null array of permissions that are declared in the application manifest.
*/
@NonNull
private synchronized String[] getManifestPermissions(@NonNull final Activity activity) {
PackageInfo packageInfo = null;
List<String> list = new ArrayList<String>(1);
try {
Log.d(TAG, activity.getPackageName());
packageInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), PackageManager.GET_PERMISSIONS);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "A problem occurred when retrieving permissions", e);
}
if (packageInfo != null) {
String[] permissions = packageInfo.requestedPermissions;
if (permissions != null) {
for (String perm : permissions) {
Log.d(TAG, "Manifest contained permission: " + perm);
list.add(perm);
}
}
}
return list.toArray(new String[list.size()]);
}
/**
* This method adds the {@link PermissionsResultAction} to the current list
* of pending actions that will be completed when the permissions are
* received. The list of permissions passed to this method are registered
* in the PermissionsResultAction object so that it will be notified of changes
* made to these permissions.
*
* @param permissions the required permissions for the action to be executed.
* @param action the action to add to the current list of pending actions.
*/
private synchronized void addPendingAction(@NonNull String[] permissions,
@Nullable PermissionsResultAction action) {
if (action == null) {
return;
}
action.registerPermissions(permissions);
mPendingActions.add(new WeakReference<PermissionsResultAction>(action));
}
/**
* This method removes a pending action from the list of pending actions.
* It is used for cases where the permission has already been granted, so
* you immediately wish to remove the pending action from the queue and
* execute the action.
*
* @param action the action to remove
*/
private synchronized void removePendingAction(@Nullable PermissionsResultAction action) {
for (Iterator<WeakReference<PermissionsResultAction>> iterator = mPendingActions.iterator();
iterator.hasNext(); ) {
WeakReference<PermissionsResultAction> weakRef = iterator.next();
if (weakRef.get() == action || weakRef.get() == null) {
iterator.remove();
}
}
}
/**
* This static method can be used to check whether or not you have a specific permission.
* It is basically a less verbose method of using {@link ActivityCompat#checkSelfPermission(Context, String)}
* and will simply return a boolean whether or not you have the permission. If you pass
* in a null Context object, it will return false as otherwise it cannot check the permission.
* However, the Activity parameter is nullable so that you can pass in a reference that you
* are not always sure will be valid or not (e.g. getActivity() from Fragment).
*
* @param context the Context necessary to check the permission
* @param permission the permission to check
* @return true if you have been granted the permission, false otherwise
*/
@SuppressWarnings("unused")
public synchronized boolean hasPermission(@Nullable Context context, @NonNull String permission) {
return context != null && (ActivityCompat.checkSelfPermission(context, permission)
== PackageManager.PERMISSION_GRANTED || !mPermissions.contains(permission));
}
/**
* This static method can be used to check whether or not you have several specific permissions.
* It is simpler than checking using {@link ActivityCompat#checkSelfPermission(Context, String)}
* for each permission and will simply return a boolean whether or not you have all the permissions.
* If you pass in a null Context object, it will return false as otherwise it cannot check the
* permission. However, the Activity parameter is nullable so that you can pass in a reference
* that you are not always sure will be valid or not (e.g. getActivity() from Fragment).
*
* @param context the Context necessary to check the permission
* @param permissions the permissions to check
* @return true if you have been granted all the permissions, false otherwise
*/
@SuppressWarnings("unused")
public synchronized boolean hasAllPermissions(@Nullable Context context, @NonNull String[] permissions) {
if (context == null) {
return false;
}
boolean hasAllPermissions = true;
for (String perm : permissions) {
hasAllPermissions &= hasPermission(context, perm);
}
return hasAllPermissions;
}
/**
* This method will request all the permissions declared in your application manifest
* for the specified {@link PermissionsResultAction}. The purpose of this method is to enable
* all permissions to be requested at one shot. The PermissionsResultAction is used to notify
* you of the user allowing or denying each permission. The Activity and PermissionsResultAction
* parameters are both annotated Nullable, but this method will not work if the Activity
* is null. It is only annotated Nullable as a courtesy to prevent crashes in the case
* that you call this from a Fragment where {@link Fragment#getActivity()} could yield
* null. Additionally, you will not receive any notification of permissions being granted
* if you provide a null PermissionsResultAction.
*
* @param activity the Activity necessary to request and check permissions.
* @param action the PermissionsResultAction used to notify you of permissions being accepted.
*/
@SuppressWarnings("unused")
public synchronized void requestAllManifestPermissionsIfNecessary(final @Nullable Activity activity,
final @Nullable PermissionsResultAction action) {
if (activity == null) {
return;
}
String[] perms = getManifestPermissions(activity);
requestPermissionsIfNecessaryForResult(activity, perms, action);
}
/**
* This method should be used to execute a {@link PermissionsResultAction} for the array
* of permissions passed to this method. This method will request the permissions if
* they need to be requested (i.e. we don't have permission yet) and will add the
* PermissionsResultAction to the queue to be notified of permissions being granted or
* denied. In the case of pre-Android Marshmallow, permissions will be granted immediately.
* The Activity variable is nullable, but if it is null, the method will fail to execute.
* This is only nullable as a courtesy for Fragments where getActivity() may yeild null
* if the Fragment is not currently added to its parent Activity.
*
* @param activity the activity necessary to request the permissions.
* @param permissions the list of permissions to request for the {@link PermissionsResultAction}.
* @param action the PermissionsResultAction to notify when the permissions are granted or denied.
*/
@SuppressWarnings("unused")
public synchronized void requestPermissionsIfNecessaryForResult(@Nullable Activity activity,
@NonNull String[] permissions,
@Nullable PermissionsResultAction action) {
if (activity == null) {
return;
}
addPendingAction(permissions, action);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
doPermissionWorkBeforeAndroidM(activity, permissions, action);
} else {
List<String> permList = getPermissionsListToRequest(activity, permissions, action);
if (permList.isEmpty()) {
//if there is no permission to request, there is no reason to keep the action int the list
removePendingAction(action);
} else {
String[] permsToRequest = permList.toArray(new String[permList.size()]);
mPendingRequests.addAll(permList);
ActivityCompat.requestPermissions(activity, permsToRequest, 1);
}
}
}
/**
* This method should be used to execute a {@link PermissionsResultAction} for the array
* of permissions passed to this method. This method will request the permissions if
* they need to be requested (i.e. we don't have permission yet) and will add the
* PermissionsResultAction to the queue to be notified of permissions being granted or
* denied. In the case of pre-Android Marshmallow, permissions will be granted immediately.
* The Fragment variable is used, but if {@link Fragment#getActivity()} returns null, this method
* will fail to work as the activity reference is necessary to check for permissions.
*
* @param fragment the fragment necessary to request the permissions.
* @param permissions the list of permissions to request for the {@link PermissionsResultAction}.
* @param action the PermissionsResultAction to notify when the permissions are granted or denied.
*/
@SuppressWarnings("unused")
public synchronized void requestPermissionsIfNecessaryForResult(@NonNull Fragment fragment,
@NonNull String[] permissions,
@Nullable PermissionsResultAction action) {
Activity activity = fragment.getActivity();
if (activity == null) {
return;
}
addPendingAction(permissions, action);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
doPermissionWorkBeforeAndroidM(activity, permissions, action);
} else {
List<String> permList = getPermissionsListToRequest(activity, permissions, action);
if (permList.isEmpty()) {
//if there is no permission to request, there is no reason to keep the action int the list
removePendingAction(action);
} else {
String[] permsToRequest = permList.toArray(new String[permList.size()]);
mPendingRequests.addAll(permList);
fragment.requestPermissions(permsToRequest, 1);
}
}
}
/**
* This method notifies the PermissionsManager that the permissions have change. If you are making
* the permissions requests using an Activity, then this method should be called from the
* Activity callback onRequestPermissionsResult() with the variables passed to that method. If
* you are passing a Fragment to make the permissions request, then you should call this in
* the {@link Fragment#onRequestPermissionsResult(int, String[], int[])} method.
* It will notify all the pending PermissionsResultAction objects currently
* in the queue, and will remove the permissions request from the list of pending requests.
*
* @param permissions the permissions that have changed.
* @param results the values for each permission.
*/
@SuppressWarnings("unused")
public synchronized void notifyPermissionsChange(@NonNull String[] permissions, @NonNull int[] results) {
int size = permissions.length;
if (results.length < size) {
size = results.length;
}
Iterator<WeakReference<PermissionsResultAction>> iterator = mPendingActions.iterator();
while (iterator.hasNext()) {
PermissionsResultAction action = iterator.next().get();
for (int n = 0; n < size; n++) {
if (action == null || action.onResult(permissions[n], results[n])) {
iterator.remove();
break;
}
}
}
for (int n = 0; n < size; n++) {
mPendingRequests.remove(permissions[n]);
}
}
/**
* When request permissions on devices before Android M (Android 6.0, API Level 23)
* Do the granted or denied work directly according to the permission status
*
* @param activity the activity to check permissions
* @param permissions the permissions names
* @param action the callback work object, containing what we what to do after
* permission check
*/
private void doPermissionWorkBeforeAndroidM(@NonNull Activity activity,
@NonNull String[] permissions,
@Nullable PermissionsResultAction action) {
for (String perm : permissions) {
if (action != null) {
if (!mPermissions.contains(perm)) {
action.onResult(perm, Permissions.NOT_FOUND);
} else if (ActivityCompat.checkSelfPermission(activity, perm)
!= PackageManager.PERMISSION_GRANTED) {
action.onResult(perm, Permissions.DENIED);
} else {
action.onResult(perm, Permissions.GRANTED);
}
}
}
}
/**
* Filter the permissions list:
* If a permission is not granted, add it to the result list
* if a permission is granted, do the granted work, do not add it to the result list
*
* @param activity the activity to check permissions
* @param permissions all the permissions names
* @param action the callback work object, containing what we what to do after
* permission check
* @return a list of permissions names that are not granted yet
*/
@NonNull
private List<String> getPermissionsListToRequest(@NonNull Activity activity,
@NonNull String[] permissions,
@Nullable PermissionsResultAction action) {
List<String> permList = new ArrayList<String>(permissions.length);
for (String perm : permissions) {
if (!mPermissions.contains(perm)) {
if (action != null) {
action.onResult(perm, Permissions.NOT_FOUND);
}
} else if (ActivityCompat.checkSelfPermission(activity, perm) != PackageManager.PERMISSION_GRANTED) {
if (!mPendingRequests.contains(perm)) {
permList.add(perm);
}
} else {
if (action != null) {
action.onResult(perm, Permissions.GRANTED);
}
}
}
return permList;
}
} | [
"[email protected]"
] | |
876e2375bdb7ac44513c6b7ab874b2e7fdc92f55 | 91839d567ceb5c509d293818e0fb476a43349d2f | /app/src/main/java/com/technoidtintin/android/justdoit/Activities/AddTaskActivity.java | c67ab6ba3c9232073c859755d393f32d7cc23f51 | [] | no_license | harshabhadra/Just-Do-It | e1e5c8e4c2977d585aa0f1d6373f86c34bd1c2a9 | ecd3f28dc1152b7b0b92d275cafad8c0faa32d93 | refs/heads/master | 2020-06-27T03:18:37.369271 | 2019-09-10T18:34:04 | 2019-09-10T18:34:04 | 199,829,772 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,218 | java | package com.technoidtintin.android.justdoit.Activities;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.technoidtintin.android.justdoit.Adapters.CategoryAdapter;
import com.technoidtintin.android.justdoit.Model.CompletedTask;
import com.technoidtintin.android.justdoit.Model.TaskItem;
import com.technoidtintin.android.justdoit.R;
import com.technoidtintin.android.justdoit.StatefulRecyclerView;
import com.technoidtintin.android.justdoit.TaskViewModel;
import com.squareup.picasso.Picasso;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class AddTaskActivity extends AppCompatActivity implements CategoryAdapter.onCategoryItemClickListener {
StatefulRecyclerView categoryRecyclerView;
CategoryAdapter categoryAdapter;
ConstraintLayout addTaskTemplateLayout;
TextView chooseCategoryTV;
Button startButton;
Button saveTaskButton;
TextView timerLabelTv;
CardView timerCard;
Button saveButton;
ImageView taskImage;
Spinner timerSpinner;
EditText taskName;
EditText taskDescription;
EditText hourEditText;
String notificationMessage;
EditText minuteEditText;
TaskViewModel taskViewModel;
String time;
String amOrpm = "AM";
int image;
String hh;
String mm;
boolean isYesButtonClicked = false;
String currentTime;
String timeSetByUser;
int DEFAULT_TASK_ID = -1;
long delay = 0;
int taskId = DEFAULT_TASK_ID;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_task);
setTitle("Add New Task");
addTaskTemplateLayout = findViewById(R.id.addTask_template);
categoryRecyclerView = findViewById(R.id.category_recycler);
chooseCategoryTV = findViewById(R.id.choose_category);
startButton = findViewById(R.id.start_now);
saveTaskButton = findViewById(R.id.save_task);
timerLabelTv = findViewById(R.id.start_time_label);
timerCard = findViewById(R.id.timer_card);
saveButton = findViewById(R.id.save_button);
taskImage = findViewById(R.id.task_image);
timerSpinner = findViewById(R.id.time_spinner);
taskName = findViewById(R.id.task_name);
taskDescription = findViewById(R.id.task_description);
hourEditText = findViewById(R.id.hour);
minuteEditText = findViewById(R.id.minute);
final Button yesButton = findViewById(R.id.yes_button);
final Button noButton = findViewById(R.id.no_button);
final TextView notificationLabel = findViewById(R.id.notification_label);
yesButton.setBackgroundColor(Color.GREEN);
noButton.setBackgroundColor(Color.RED);
timerLabelTv.setVisibility(View.GONE);
timerCard.setVisibility(View.GONE);
saveButton.setVisibility(View.GONE);
addTaskTemplateLayout.setVisibility(View.GONE);
Intent intent = getIntent();
if (intent.hasExtra("savedTask")) {
setTitle("Update Task");
final TaskItem taskItem = intent.getParcelableExtra("savedTask");
if (taskItem != null) {
taskId = taskItem.getId();
timerLabelTv.setVisibility(View.VISIBLE);
yesButton.setVisibility(View.VISIBLE);
noButton.setVisibility(View.VISIBLE);
addTaskTemplateLayout.setVisibility(View.VISIBLE);
categoryRecyclerView.setVisibility(View.GONE);
startButton.setVisibility(View.GONE);
saveTaskButton.setVisibility(View.GONE);
chooseCategoryTV.setVisibility(View.GONE);
if (taskItem.getTaskName() != null) {
taskName.setText(taskItem.getTaskName());
}
if (!taskItem.getTaskDescription().isEmpty()) {
taskDescription.setText(taskItem.getTaskDescription());
}
if (taskItem.getCategoryImage() != null) {
image = taskItem.getCategoryImage();
Picasso.get().load(taskItem.getCategoryImage()).into(taskImage);
}
time = taskItem.getTimeinSeconds();
notificationLabel.setText(String.format("Start Time is: %s", time));
}
timerLabelTv.setText(getResources().getString(R.string.do_u_want));
saveButton.setText(getResources().getString(R.string.update));
} else {
Log.e("AddTaskActivity", "No Intent");
}
yesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
isYesButtonClicked = true;
timerCard.setVisibility(View.VISIBLE);
yesButton.setVisibility(View.GONE);
noButton.setVisibility(View.GONE);
saveButton.setVisibility(View.VISIBLE);
}
});
noButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
saveButton.setVisibility(View.VISIBLE);
yesButton.setVisibility(View.GONE);
noButton.setVisibility(View.GONE);
}
});
//Setting up spinner
setUpSpinner();
// If user is updating a task
if (taskId != DEFAULT_TASK_ID) {
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!taskName.getText().toString().isEmpty()) {
if (isYesButtonClicked) {
hh = hourEditText.getText().toString();
mm = minuteEditText.getText().toString();
timeSetByUser = hh + ":" + mm + " " + amOrpm;
} else {
timeSetByUser = time;
}
TaskItem taskItem1 = new TaskItem(taskId, image, taskName.getText().toString(),
taskDescription.getText().toString(), timeSetByUser);
taskViewModel.updateSingleTask(taskItem1);
finish();
} else {
Toast.makeText(getApplicationContext(), "Task must have a name", Toast.LENGTH_LONG).show();
taskName.setHighlightColor(Color.RED);
}
}
});
} else {
//If user is adding a new task
//Set action for save button
saveButton.setOnClickListener(new View.OnClickListener() {
@SuppressLint("SetTextI18n")
@Override
public void onClick(View view) {
hh = hourEditText.getText().toString();
mm = minuteEditText.getText().toString();
if (!hh.isEmpty() && !mm.isEmpty()) {
int hour = Integer.valueOf(hh);
int minute = Integer.valueOf(mm);
if ((hour >= 0 && hour <= 12) && (minute >= 0 && minute <= 59)) {
timeSetByUser = hh + ":" + mm + " " + amOrpm;
Log.e("AddTaskActivity", "Time set by user: " + timeSetByUser);
String currentTime = getCurrentTime();
Log.e("AddTaskActivity", "Current Time: " + currentTime);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mm a", Locale.getDefault());
LocalTime start = LocalTime.parse(currentTime, formatter);
LocalTime end = LocalTime.parse(timeSetByUser, formatter);
Duration duration = Duration.between(start, end);
delay = duration.toMinutes();
Log.e("AddTaskActivity", "DateTimeFormatter Delay is: " + delay);
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
SimpleDateFormat dateFormat = new SimpleDateFormat("h:mm a", Locale.getDefault());
try {
Date date = dateFormat.parse(timeSetByUser);
Date date1 = dateFormat.parse(currentTime);
Log.e("AddTaskActivity", "date: " + date);
Log.e("AddTaskActivity", "date1: " + date1);
long difference = date.getTime() - date1.getTime();
Log.e("AddTaskActivity", "difference: " + difference);
int days = (int) (difference / (1000 * 60 * 60 * 24));
int hours = (int) ((difference - (1000 * 60 * 60 * 24 * days)) / (1000 * 60 * 60));
delay = (int) (difference - (1000 * 60 * 60 * 24 * days) - (1000 * 60 * 60 * hours)) / (1000 * 60);
Log.e("AddTaskActivity", "SimpleDateFormatter Delay is: " + delay);
} catch (Exception e) {
e.printStackTrace();
}
}
if (delay >= 5 && delay <= 1440) {
notificationMessage = taskName.getText().toString();
TaskItem taskItem = new TaskItem(image, taskName.getText().toString(), taskDescription.getText().toString(), timeSetByUser);
taskViewModel.insertTask(taskItem);
taskViewModel.setNotification(notificationMessage, (delay - 1));
finish();
} else {
timerLabelTv.setText(getResources().getString(R.string.invalid_time));
timerLabelTv.setTextColor(Color.RED);
notificationLabel.setText("Minimum delay: 5 min" + "\n" + "Maximum delay: 24 hr");
Log.e("AddTaskActivity", "delay is: " + delay);
}
} else {
timerLabelTv.setText(getResources().getString(R.string.invalid_time));
timerLabelTv.setTextColor(Color.RED);
notificationLabel.setText("Minimum delay: 5 min" + "\n" + "Maximum delay: 24 hr");
Log.e("AddTaskActivity", "delay is: " + delay);
}
} else {
timerLabelTv.setText(getResources().getString(R.string.invalid_time));
timerLabelTv.setTextColor(Color.RED);
notificationLabel.setText("Minimum delay: 5 min" + "\n" + "Maximum delay: 24 hr");
Log.e("AddTaskActivity", "delay is: " + delay);
}
}
});
}
//Set action for start now button
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Getting the current locale time
currentTime = getCurrentTime();
TaskItem taskItem = new TaskItem(image, taskName.getText().toString(), taskDescription.getText().toString(), currentTime);
CompletedTask completedTask = new CompletedTask(image, taskName.getText().toString(), taskDescription.getText().toString(), currentTime);
String currentTaskName = taskName.getText().toString();
if (!currentTaskName.isEmpty()) {
taskViewModel.insertCompletedTask(completedTask);
Intent startIntent = new Intent(AddTaskActivity.this, MainActivity.class);
startIntent.putExtra("startNow", taskItem);
startActivity(startIntent);
finish();
} else {
Toast.makeText(getApplicationContext(), "Task must have a name", Toast.LENGTH_LONG).show();
taskName.setHighlightColor(Color.RED);
}
}
});
//Initializing the ViewModel class
taskViewModel = ViewModelProviders.of(this).get(TaskViewModel.class);
//Set action for save task button click
saveTaskButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!taskName.getText().toString().isEmpty()) {
startButton.setVisibility(View.GONE);
saveTaskButton.setVisibility(View.GONE);
timerLabelTv.setVisibility(View.VISIBLE);
timerCard.setVisibility(View.VISIBLE);
saveButton.setVisibility(View.VISIBLE);
} else {
Toast.makeText(getApplicationContext(), "Task must have a name", Toast.LENGTH_LONG).show();
taskName.setHighlightColor(Color.RED);
}
}
});
//Setting up CategoryRecycler
categoryRecyclerView.setHasFixedSize(true);
categoryRecyclerView.setLayoutManager(new LinearLayoutManager(this));
categoryAdapter = new CategoryAdapter(AddTaskActivity.this, AddTaskActivity.this);
categoryRecyclerView.setAdapter(categoryAdapter);
}
//setup the spinner
private void setUpSpinner() {
ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(this, R.array.spinner, android.R.layout.simple_spinner_item);
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
timerSpinner.setAdapter(arrayAdapter);
timerSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
amOrpm = adapterView.getItemAtPosition(i).toString();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}
//Get the current time
private String getCurrentTime() {
Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
Date currentLocalTime = calendar.getTime();
DateFormat time = new SimpleDateFormat("h:mm a", Locale.getDefault());
time.setTimeZone(TimeZone.getDefault());
return time.format(currentLocalTime);
}
@Override
public void onCategoryItemClick(int position) {
chooseCategoryTV.setVisibility(View.GONE);
categoryRecyclerView.setVisibility(View.GONE);
addTaskTemplateLayout.setVisibility(View.VISIBLE);
image = categoryAdapter.getImage(position);
taskImage.setImageResource(image);
}
}
| [
"[email protected]"
] | |
2b1dc6f7cb478dec706ffedfb0d83f64446cd58a | b442fecae64f573f8c323822bf51544aa4fe363c | /src/main/java/ai/fma/mpi_yarn/ApplicationMaster.java | 69c2d37b5af7ea67e8348310f3c15454068206ee | [
"Apache-2.0"
] | permissive | stevenybw/mpi-yarn | 1fcbfa50bb3fcc879aa4a2b5dd585dd8bbabf803 | b41d09dac11bea945d635b43aa74ab4674c1fc6d | refs/heads/master | 2021-06-04T21:53:45.334343 | 2017-05-24T08:35:39 | 2017-05-24T08:35:39 | 92,269,114 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,997 | java | package ai.fma.mpi_yarn;
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.yarn.api.ApplicationConstants;
import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.api.records.ContainerStatus;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.LocalResource;
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.client.api.AMRMClient;
import org.apache.hadoop.yarn.client.api.AMRMClient.ContainerRequest;
import org.apache.hadoop.yarn.client.api.NMClient;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.util.Records;
public class ApplicationMaster {
public static void clientPrint(FSDataOutputStream outputStream, String mesg) throws IOException {
System.out.print(mesg);
outputStream.writeBytes(mesg);
outputStream.hsync();
}
public static void clientPrintln(FSDataOutputStream outputStream, String mesg) throws IOException {
System.out.println(mesg);
outputStream.writeBytes(mesg + "\n");
outputStream.hsync();
}
public static void main(String[] args) throws Exception {
System.out.println("AM Start");
// Initialize clients to ResourceManager and NodeManagers
Configuration conf = new YarnConfiguration();
FileSystem dfs = FileSystem.get(conf);
MyConf myConf = MyConf.deserialize(System.getenv(MyConf.EnvName));
String hdfsPrefix = myConf.getHdfsPrefix();
int responseId = 0;
System.out.println("append output into " + myConf.getOutputPath());
Path outputPath = new Path(myConf.getOutputPath());
FSDataOutputStream outputStream = dfs.create(outputPath);
AMRMClient<ContainerRequest> rmClient = AMRMClient.createAMRMClient();
rmClient.init(conf);
rmClient.start();
NMClient nmClient = NMClient.createNMClient();
nmClient.init(conf);
nmClient.start();
// Register with ResourceManager
System.out.println("registerApplicationMaster 0");
rmClient.registerApplicationMaster("", 0, "");
System.out.println("registerApplicationMaster 1");
// Priority for worker containers - priorities are intra-application
Priority priority = Records.newRecord(Priority.class);
priority.setPriority(0);
ArrayList<Container> containers = new ArrayList<Container>();
HashMap<String, ArrayList<Container>> hostContainers = new HashMap<String, ArrayList<Container>>();
if (myConf.getLocalityType() == LocalityType.NONE) {
int n = myConf.getNumProcs();
System.out.println("request " + String.valueOf(n) + " container; container memory = "
+ String.valueOf(myConf.getContainerMemoryMb()) + "MB");
// Resource requirements for worker containers
Resource capability = Records.newRecord(Resource.class);
capability.setMemory(myConf.getContainerMemoryMb());
capability.setVirtualCores(1);
// Make container requests to ResourceManager
for (int i = 0; i < n; ++i) {
ContainerRequest containerAsk = new ContainerRequest(capability, null, null, priority);
System.out.println("Making res-req " + i);
rmClient.addContainerRequest(containerAsk);
}
// Obtain allocated containers
while (containers.size() < n) {
AllocateResponse response = rmClient.allocate(responseId++);
for (Container container : response.getAllocatedContainers()) {
NodeId nodeId = container.getNodeId();
String host = nodeId.getHost();
System.out.println("Acquired container " + container.getId() + " at host " + host);
containers.add(container);
if (!hostContainers.containsKey(host)) {
hostContainers.put(host, new ArrayList<Container>());
}
hostContainers.get(host).add(container);
}
Thread.sleep(100);
}
} else if (myConf.getLocalityType() == LocalityType.GROUP) {
int N = myConf.getNumNodes();
int ppn = myConf.getNumProcsPerNode();
System.out.println("request " + N + " groups; each group has " + ppn + " containers; container memory = "
+ String.valueOf(myConf.getContainerMemoryMb()));
// Resource requirement is the same as above
Resource capability = Records.newRecord(Resource.class);
capability.setMemory(myConf.getContainerMemoryMb());
capability.setVirtualCores(1);
// acquired group is a group which has more than ppn nodes
int numAcquiredGroup = 0;
// request one container at a time, until we have enough groups
while (numAcquiredGroup < N) {
ContainerRequest containerAsk = new ContainerRequest(capability, null, null, priority);
rmClient.addContainerRequest(containerAsk);
// wait for one container
while (true) {
AllocateResponse response = rmClient.allocate(responseId++);
if (response.getAllocatedContainers().size() > 0) {
Container container = response.getAllocatedContainers().get(0);
NodeId nodeId = container.getNodeId();
String host = nodeId.getHost();
System.out.println("Acquired container " + container.getId() + " at host " + host);
if (!hostContainers.containsKey(host)) {
hostContainers.put(host, new ArrayList<Container>());
}
hostContainers.get(host).add(container);
if (hostContainers.get(host).size() == ppn) {
numAcquiredGroup++;
}
break;
}
}
}
{
ArrayList<Container> redundantContainers = new ArrayList<Container>();
// find the redundant containers & update containers
for (String host : hostContainers.keySet()) {
ArrayList<Container> Cs = hostContainers.get(host);
if (Cs.size() < ppn) {
redundantContainers.addAll(Cs);
hostContainers.remove(host);
} else {
for (int i = 0; i < (Cs.size() - ppn); i++) {
redundantContainers.add(Cs.remove(0));
}
containers.addAll(Cs);
}
}
// release the redundant containers
for (Container container : redundantContainers) {
System.out.println("Releasing redundant container " + container.getId());
rmClient.releaseAssignedContainer(container.getId());
}
}
}
clientPrintln(outputStream, "acquired node list: ");
for (String host : hostContainers.keySet()) {
clientPrintln(outputStream, " " + host + ":" + hostContainers.get(host).size());
}
Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
{
Path executablePath = new Path(hdfsPrefix + "/" + myConf.getExecutableName());
LocalResource executableResource = Records.newRecord(LocalResource.class);
MyConf.setupLocalResource(dfs, executablePath, executableResource);
localResources.put(executablePath.getName(), executableResource);
}
{
Path pmiProxyPath = new Path(hdfsPrefix + "/" + MyConf.PMI_PROXY);
LocalResource pmiProxyResource = Records.newRecord(LocalResource.class);
MyConf.setupLocalResource(dfs, pmiProxyPath, pmiProxyResource);
localResources.put(pmiProxyPath.getName(), pmiProxyResource);
}
for (String sofile : myConf.getSharedObjectPathList()) {
Path src = new Path(sofile);
Path target = new Path(hdfsPrefix + "/sofiles/" + src.getName());
LocalResource soResource = Records.newRecord(LocalResource.class);
MyConf.setupLocalResource(dfs, target, soResource);
localResources.put(target.getName(), soResource);
}
HashSet<String> envList = myConf.getEnvList();
Map<String, String> containerEnv = new HashMap<String, String>();
for (String envName : System.getenv().keySet()) {
if (envList.contains(envName)) {
containerEnv.put(envName, System.getenv(envName));
}
}
String ldLibraryPath = containerEnv.get("LD_LIBRARY_PATH");
if (ldLibraryPath == null) {
ldLibraryPath = "./sofiles";
} else {
ldLibraryPath = "./sofiles:" + ldLibraryPath;
}
containerEnv.put("LD_LIBRARY_PATH", ldLibraryPath);
System.out.println("=== Environment ===");
System.out.println(containerEnv);
System.out.println("===================");
ArrayList<Container> containerSequence = new ArrayList<Container>();
StringBuilder hostSb = new StringBuilder();
{
boolean first = true;
for (String host : hostContainers.keySet()) {
for (Container container : hostContainers.get(host)) {
if (first) {
first = false;
} else {
hostSb.append(",");
}
hostSb.append(host);
containerSequence.add(container);
}
}
}
try {
InputStream mpirunIstream;
InputStream mpirunEstream;
Scanner mpirunScanner;
Scanner mpirunEscanner;
{
String cmd = MessageFormat.format("./{0} -launcher manual -ppn 1 -hosts {1} ./{2} {3}", MyConf.MPIEXEC,
hostSb.toString(), myConf.getExecutableName(), myConf.getExecutableArgs());
System.out.println("invoke " + cmd);
ProcessBuilder pb = new ProcessBuilder(cmd.split("\\s"));
Process p = pb.start();
mpirunIstream = p.getInputStream();
mpirunEstream = p.getErrorStream();
mpirunScanner = new Scanner(mpirunIstream);
mpirunEscanner = new Scanner(mpirunEstream);
for (Container container : containerSequence) {
String line = mpirunScanner.nextLine();
// HYDRA_LAUNCH:
// /Users/ybw/local/mpich-3.2/bin/hydra_pmi_proxy
// --control-port 172.23.100.68:58247 --rmk user --launcher
// manual --demux poll --pgid 0 --retries 10 --usize -2
// --proxy-id 0
String[] sp = line.split(" ");
String[] sub_sp = Arrays.copyOfRange(sp, 2, sp.length);
String container_cmd = "./" + MyConf.PMI_PROXY + " " + StringUtils.join(sub_sp, " ");
ContainerLaunchContext ctx = Records.newRecord(ContainerLaunchContext.class);
ctx.setLocalResources(localResources);
ArrayList<String> commands = new ArrayList<String>();
commands.add(container_cmd + " 1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdout" + " 2>"
+ ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stderr");
// commands.add("echo ContainerFinished!");
ctx.setCommands(commands);
nmClient.startContainer(container, ctx);
System.out.println("Launching container " + container.getId() + " with cmd " + container_cmd);
}
{
String nextLine = mpirunScanner.nextLine();
if (!nextLine.startsWith("HYDRA_LAUNCH_END")) {
throw new RuntimeException("Not Start With HYDRA_LAUNCH_END, but " + nextLine);
}
}
}
// Wait for containers
int bufferBytes = 4096;
byte[] buffer = new byte[bufferBytes];
int completedContainers = 0;
boolean iStreamClosed = false;
boolean eStreamClosed = false;
while (completedContainers < containers.size()) {
AllocateResponse response = rmClient.allocate(responseId++);
for (ContainerStatus status : response.getCompletedContainersStatuses()) {
++completedContainers;
if (status.getExitStatus() != 0) {
clientPrintln(outputStream, "Completed container " + status.getContainerId()
+ " with exit code " + status.getExitStatus());
} else {
System.out.println("Completed container " + status.getContainerId() + " with exit code "
+ status.getExitStatus());
}
}
if (mpirunIstream.available() > 0) {
int bytes = mpirunIstream.read(buffer, 0, bufferBytes);
if (bytes == -1) {
iStreamClosed = true;
} else {
String next = new String(buffer, 0, bytes);
clientPrint(outputStream, next);
}
}
if (mpirunEstream.available() > 0) {
int bytes = mpirunEstream.read(buffer, 0, bufferBytes);
if (bytes == -1) {
eStreamClosed = true;
} else {
String next = new String(buffer, 0, bytes);
clientPrint(outputStream, next);
}
}
Thread.sleep(100);
}
{
int bytes = 0;
while (!iStreamClosed) {
bytes = mpirunIstream.read(buffer, 0, bufferBytes);
if (bytes == -1) {
iStreamClosed = true;
} else {
String next = new String(buffer, 0, bytes);
clientPrint(outputStream, next);
}
}
}
{
int bytes = 0;
while (!eStreamClosed) {
bytes = mpirunEstream.read(buffer, 0, bufferBytes);
if (bytes == -1) {
eStreamClosed = true;
} else {
String next = new String(buffer, 0, bytes);
clientPrint(outputStream, next);
}
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
throw new RuntimeException();
}
// Un-register with ResourceManager
rmClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, "", "");
}
}
| [
"[email protected]"
] | |
009d4fb9f643f9a038b91a0c3ead9dbb406d8e61 | ad4933feb7ef2fcf4e4b8fa83c60b1ff0f3c8065 | /src/test/java/com/plutotv/common/layer/endpoint/v2/channels/series/ChannelsSeriesEndpointsV2.java | 6cef860bd174c6e583aa2d8ebbafd920d926508b | [] | no_license | seanmenezes/service-media-store | 03b447bfee47f2d7d1999ef671ff8da875fa5c00 | 2c1e92078a6d03a4e5a2015ef023649abf716f3c | refs/heads/master | 2023-04-19T20:25:48.243723 | 2021-05-07T04:45:12 | 2021-05-07T04:45:12 | 365,115,565 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,121 | java | /*
* (c) 2021 Pluto Inc.
*/
package com.plutotv.common.layer.endpoint.v2.channels.series;
import com.plutotv.common.config.v2.channels.ChannelsEndpointV2;
import com.plutotv.common.config.v2.channels.ChannelsEndpointV2Manager;
import com.plutotv.common.helper.RequestHelper;
import io.qameta.allure.Step;
import io.restassured.response.Response;
import java.util.Map;
import static com.plutotv.common.url.UrlBuilder.buildRequestUrl;
import static com.plutotv.test.BaseTest.DEFAULT_HEADERS;
public class ChannelsSeriesEndpointsV2 {
private static final ChannelsEndpointV2 ENDPOINT = ChannelsEndpointV2Manager.getEndpoint();
private final RequestHelper requestHelper = new RequestHelper();
@Step("Get v2/channels/series")
public Response getChannelsSeries(Map<String, String> params) {
return requestHelper.getRequest(DEFAULT_HEADERS, params, buildRequestUrl(ENDPOINT.v2ChannelsSeries()));
}
@Step("Head v2/channels/series")
public Response headChannelsSeries() {
return requestHelper.headRequest(DEFAULT_HEADERS, buildRequestUrl(ENDPOINT.v2ChannelsSeries()));
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.