repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
ghjansen/cas | cas-core/src/test/java/com/ghjansen/cas/core/physics/DimensionalTime.java | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
| import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException; | /*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.physics;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public class DimensionalTime extends Time {
public DimensionalTime(final int limit, int... limits) | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
// Path: cas-core/src/test/java/com/ghjansen/cas/core/physics/DimensionalTime.java
import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException;
/*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.physics;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public class DimensionalTime extends Time {
public DimensionalTime(final int limit, int... limits) | throws InvalidAbsoluteTimeLimitException, InvalidRelativeTimeLimitException, CloneNotSupportedException { |
ghjansen/cas | cas-core/src/test/java/com/ghjansen/cas/core/physics/DimensionalTime.java | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
| import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException; | /*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.physics;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public class DimensionalTime extends Time {
public DimensionalTime(final int limit, int... limits) | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
// Path: cas-core/src/test/java/com/ghjansen/cas/core/physics/DimensionalTime.java
import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException;
/*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.physics;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public class DimensionalTime extends Time {
public DimensionalTime(final int limit, int... limits) | throws InvalidAbsoluteTimeLimitException, InvalidRelativeTimeLimitException, CloneNotSupportedException { |
ghjansen/cas | cas-core/src/main/java/com/ghjansen/cas/core/ca/Transition.java | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidCombinationException.java
// public class InvalidCombinationException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 884762124844706448L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidStateException.java
// public class InvalidStateException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -7435119307025647318L;
//
// }
| import com.ghjansen.cas.core.exception.InvalidCombinationException;
import com.ghjansen.cas.core.exception.InvalidStateException; | /*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.ca;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public abstract class Transition<O extends Combination, A extends State> {
private O combination;
private A state;
| // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidCombinationException.java
// public class InvalidCombinationException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 884762124844706448L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidStateException.java
// public class InvalidStateException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -7435119307025647318L;
//
// }
// Path: cas-core/src/main/java/com/ghjansen/cas/core/ca/Transition.java
import com.ghjansen.cas.core.exception.InvalidCombinationException;
import com.ghjansen.cas.core.exception.InvalidStateException;
/*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.ca;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public abstract class Transition<O extends Combination, A extends State> {
private O combination;
private A state;
| protected Transition(O combination, A state) throws InvalidCombinationException, InvalidStateException { |
ghjansen/cas | cas-core/src/main/java/com/ghjansen/cas/core/ca/Transition.java | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidCombinationException.java
// public class InvalidCombinationException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 884762124844706448L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidStateException.java
// public class InvalidStateException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -7435119307025647318L;
//
// }
| import com.ghjansen.cas.core.exception.InvalidCombinationException;
import com.ghjansen.cas.core.exception.InvalidStateException; | /*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.ca;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public abstract class Transition<O extends Combination, A extends State> {
private O combination;
private A state;
| // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidCombinationException.java
// public class InvalidCombinationException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 884762124844706448L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidStateException.java
// public class InvalidStateException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -7435119307025647318L;
//
// }
// Path: cas-core/src/main/java/com/ghjansen/cas/core/ca/Transition.java
import com.ghjansen.cas.core.exception.InvalidCombinationException;
import com.ghjansen.cas.core.exception.InvalidStateException;
/*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.ca;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public abstract class Transition<O extends Combination, A extends State> {
private O combination;
private A state;
| protected Transition(O combination, A state) throws InvalidCombinationException, InvalidStateException { |
ghjansen/cas | cas-core/src/test/java/com/ghjansen/cas/core/physics/TimeTest.java | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/TimeLimitReachedException.java
// public class TimeLimitReachedException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -6359890788325087840L;
//
// }
| import org.junit.Assert;
import org.junit.Test;
import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException;
import com.ghjansen.cas.core.exception.TimeLimitReachedException; | /*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.physics;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public class TimeTest {
@Test
public void unlimitedTimeContructor() {
final Time unlimitedTime = new UnlimitedTime();
Assert.assertTrue(unlimitedTime.getAbsolute() == 0);
Assert.assertNull(unlimitedTime.getRelative());
}
@Test | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/TimeLimitReachedException.java
// public class TimeLimitReachedException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -6359890788325087840L;
//
// }
// Path: cas-core/src/test/java/com/ghjansen/cas/core/physics/TimeTest.java
import org.junit.Assert;
import org.junit.Test;
import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException;
import com.ghjansen.cas.core.exception.TimeLimitReachedException;
/*
* CAS - Cellular Automata Simulator
* Copyright (C) 2016 Guilherme Humberto Jansen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.ghjansen.cas.core.physics;
/**
* @author Guilherme Humberto Jansen (contact.ghjansen@gmail.com)
*/
public class TimeTest {
@Test
public void unlimitedTimeContructor() {
final Time unlimitedTime = new UnlimitedTime();
Assert.assertTrue(unlimitedTime.getAbsolute() == 0);
Assert.assertNull(unlimitedTime.getRelative());
}
@Test | public void unlimitedTimeIncreasing() throws TimeLimitReachedException { |
ghjansen/cas | cas-core/src/test/java/com/ghjansen/cas/core/physics/TimeTest.java | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/TimeLimitReachedException.java
// public class TimeLimitReachedException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -6359890788325087840L;
//
// }
| import org.junit.Assert;
import org.junit.Test;
import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException;
import com.ghjansen.cas.core.exception.TimeLimitReachedException; | Assert.assertTrue(unlimitedTime.getAbsolute() == 0);
Assert.assertNull(unlimitedTime.getRelative());
}
@Test
public void unlimitedTimeIncreasing() throws TimeLimitReachedException {
final int amount = 1000;
final Time unlimitedTime = new UnlimitedTime();
for (int i = 0; i < amount; i++) {
unlimitedTime.increase();
}
Assert.assertTrue(unlimitedTime.getAbsolute() == amount);
Assert.assertNull(unlimitedTime.getRelative());
}
@Test
public void unlimitedTimeReset() throws TimeLimitReachedException {
final int amount = 1000;
final int reset = 0;
final Time unlimitedTime = new UnlimitedTime();
for (int i = 0; i < amount; i++) {
unlimitedTime.increase();
}
Assert.assertTrue(unlimitedTime.getAbsolute() == amount);
unlimitedTime.resetAbsoluteTime();
Assert.assertTrue(unlimitedTime.getAbsolute() == reset);
Assert.assertNull(unlimitedTime.getRelative());
}
@Test | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/TimeLimitReachedException.java
// public class TimeLimitReachedException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -6359890788325087840L;
//
// }
// Path: cas-core/src/test/java/com/ghjansen/cas/core/physics/TimeTest.java
import org.junit.Assert;
import org.junit.Test;
import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException;
import com.ghjansen.cas.core.exception.TimeLimitReachedException;
Assert.assertTrue(unlimitedTime.getAbsolute() == 0);
Assert.assertNull(unlimitedTime.getRelative());
}
@Test
public void unlimitedTimeIncreasing() throws TimeLimitReachedException {
final int amount = 1000;
final Time unlimitedTime = new UnlimitedTime();
for (int i = 0; i < amount; i++) {
unlimitedTime.increase();
}
Assert.assertTrue(unlimitedTime.getAbsolute() == amount);
Assert.assertNull(unlimitedTime.getRelative());
}
@Test
public void unlimitedTimeReset() throws TimeLimitReachedException {
final int amount = 1000;
final int reset = 0;
final Time unlimitedTime = new UnlimitedTime();
for (int i = 0; i < amount; i++) {
unlimitedTime.increase();
}
Assert.assertTrue(unlimitedTime.getAbsolute() == amount);
unlimitedTime.resetAbsoluteTime();
Assert.assertTrue(unlimitedTime.getAbsolute() == reset);
Assert.assertNull(unlimitedTime.getRelative());
}
@Test | public void limitedTimeConstructor() throws InvalidAbsoluteTimeLimitException { |
ghjansen/cas | cas-core/src/test/java/com/ghjansen/cas/core/physics/TimeTest.java | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/TimeLimitReachedException.java
// public class TimeLimitReachedException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -6359890788325087840L;
//
// }
| import org.junit.Assert;
import org.junit.Test;
import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException;
import com.ghjansen.cas.core.exception.TimeLimitReachedException; | @Test(expected = InvalidAbsoluteTimeLimitException.class)
public void limitedTimeConstructorNegative() throws InvalidAbsoluteTimeLimitException {
final int limit = -1;
new LimitedTime(limit);
}
@Test
public void limitedTimeIncreasing() throws InvalidAbsoluteTimeLimitException, TimeLimitReachedException {
final int limit = 1000;
final int iterationLimit = limit - 1;
final Time limitedTime = new LimitedTime(limit);
for (int i = 0; i < iterationLimit; i++) {
limitedTime.increase();
}
Assert.assertTrue(limitedTime.getAbsolute() == limit - 1);
Assert.assertNull(limitedTime.getRelative());
}
@Test(expected = TimeLimitReachedException.class)
public void limitedTimeIncreasingBeyondLimit() throws InvalidAbsoluteTimeLimitException, TimeLimitReachedException {
final int limit = 1000;
final int amount = 1000;
final Time limitedTime = new LimitedTime(limit);
for (int i = 0; i < amount; i++) {
limitedTime.increase();
}
}
@Test
public void dimensionalTimeConstructor() | // Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidAbsoluteTimeLimitException.java
// public class InvalidAbsoluteTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = 8503779819489685979L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/InvalidRelativeTimeLimitException.java
// public class InvalidRelativeTimeLimitException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -8421027467680752602L;
//
// }
//
// Path: cas-core/src/main/java/com/ghjansen/cas/core/exception/TimeLimitReachedException.java
// public class TimeLimitReachedException extends Exception {
//
// /**
// * Serialization management
// */
// private static final long serialVersionUID = -6359890788325087840L;
//
// }
// Path: cas-core/src/test/java/com/ghjansen/cas/core/physics/TimeTest.java
import org.junit.Assert;
import org.junit.Test;
import com.ghjansen.cas.core.exception.InvalidAbsoluteTimeLimitException;
import com.ghjansen.cas.core.exception.InvalidRelativeTimeLimitException;
import com.ghjansen.cas.core.exception.TimeLimitReachedException;
@Test(expected = InvalidAbsoluteTimeLimitException.class)
public void limitedTimeConstructorNegative() throws InvalidAbsoluteTimeLimitException {
final int limit = -1;
new LimitedTime(limit);
}
@Test
public void limitedTimeIncreasing() throws InvalidAbsoluteTimeLimitException, TimeLimitReachedException {
final int limit = 1000;
final int iterationLimit = limit - 1;
final Time limitedTime = new LimitedTime(limit);
for (int i = 0; i < iterationLimit; i++) {
limitedTime.increase();
}
Assert.assertTrue(limitedTime.getAbsolute() == limit - 1);
Assert.assertNull(limitedTime.getRelative());
}
@Test(expected = TimeLimitReachedException.class)
public void limitedTimeIncreasingBeyondLimit() throws InvalidAbsoluteTimeLimitException, TimeLimitReachedException {
final int limit = 1000;
final int amount = 1000;
final Time limitedTime = new LimitedTime(limit);
for (int i = 0; i < amount; i++) {
limitedTime.increase();
}
}
@Test
public void dimensionalTimeConstructor() | throws InvalidAbsoluteTimeLimitException, InvalidRelativeTimeLimitException, CloneNotSupportedException { |
lordi/tickmate | app/src/main/java/de/smasi/tickmate/views/TickColorListAdapter.java | // Path: app/src/main/java/de/smasi/tickmate/TickColor.java
// public class TickColor {
// private static final String TAG = "TickColor";
// private String mName = "Not named";
// private int mColorValue = 0;
//
// private static Drawable sUnTickedButton;
// private static Drawable sTickedButton;
//
// // Material design colors, 400-600
// // https://www.google.com/design/spec/style/color.html
// private static int[] sColors = new int[] {
// 0xf44336,
// 0xec407a,
// 0xab47bc,
// 0x673ab7,
// 0x5c6bc0,
// 0x1e88e5,
// 0x039be5,
// 0x00bcd4,
// 0x26a69a,
// 0x81c784,
// 0x7cb342,
// 0xc0ca33,
// 0xfdd835,
// 0xffb300,
// 0xfb8c00,
// 0xf4511e,
// 0xbcaaa4,
// 0xbdbdbd,
// 0xb0bec5,
// 0x4ea6e0 // pre 1.4 tickmate color
// };
// private static List<TickColor> sTickColors;
//
// public TickColor(int color) {
// mColorValue = color;
// mName = Integer.toHexString(color);
// }
//
// public Drawable getDrawable(int alpha) {
// Log.d(TAG, "getTickedButtonDrawable " + getName());
// ColorDrawable cd = new ColorDrawable(Color.parseColor(hex()));
// cd.setAlpha(alpha);
// return cd;
// }
//
// public Drawable getTickedButtonDrawable(Context c) {
// Log.d(TAG, "getTickedButtonDrawable " + getName());
// return getTickedButtonDrawable(c, mColorValue);
// }
//
// public static Drawable getTickedButtonDrawable(Context context, int tickButtonColor) {
// // Prepare the layers & color filter for the LayerDrawable
// ColorFilter cf = new LightingColorFilter(tickButtonColor, 0);
// //ColorDrawable buttonCenterDrawable = new ColorDrawable(0xFF000000 + tickButtonColor);
// Drawable buttonCenterDrawable = ContextCompat.getDrawable(context, R.drawable.mask_64);
// Drawable buttonBorderDrawable = ContextCompat.getDrawable(context, R.drawable.on_64);
// buttonCenterDrawable.setColorFilter(cf);
// sTickedButton = new LayerDrawable(new Drawable[]{buttonCenterDrawable, buttonBorderDrawable});
// return sTickedButton;
// }
//
// public static Drawable getUnTickedButtonDrawable(Context context) {
// if (sUnTickedButton == null) {
// sUnTickedButton = ContextCompat.getDrawable(context, R.drawable.off_64);
// }
// return sUnTickedButton;
// }
//
// public String hex() {
// return String.format("#%06X", mColorValue);
// }
//
// public String getName() {
// return hex();
// }
//
// public int getColorValue() {
// return mColorValue;
// }
//
// // TODO rename this
// // Give the drawables used for the preference dialog
// public static Drawable getPreferenceDrawable(Context c, int index) {
// return getTickedButtonDrawable(c, sColors[index]);
// }
//
// public static TickColor getColor(int index) {
// if (sTickColors == null) {
// sTickColors = new ArrayList();
// for (int i = 0; i < sColors.length; i++) {
// sTickColors.add(new TickColor(sColors[i]));
// }
// }
// return sTickColors.get(index);
// }
//
// public static int getNumberOfColors() {
// return sColors.length;
// }
//
// public void setColorValue(int colorValue) {
// mColorValue = colorValue;
// }
//
// }
| import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import java.util.List;
import de.smasi.tickmate.TickColor; | package de.smasi.tickmate.views;
public class TickColorListAdapter extends BaseAdapter {
private Context mContext;
private List<String> mTickColorNames;
public TickColorListAdapter(Context c) {
mContext = c;
}
public int getCount() { | // Path: app/src/main/java/de/smasi/tickmate/TickColor.java
// public class TickColor {
// private static final String TAG = "TickColor";
// private String mName = "Not named";
// private int mColorValue = 0;
//
// private static Drawable sUnTickedButton;
// private static Drawable sTickedButton;
//
// // Material design colors, 400-600
// // https://www.google.com/design/spec/style/color.html
// private static int[] sColors = new int[] {
// 0xf44336,
// 0xec407a,
// 0xab47bc,
// 0x673ab7,
// 0x5c6bc0,
// 0x1e88e5,
// 0x039be5,
// 0x00bcd4,
// 0x26a69a,
// 0x81c784,
// 0x7cb342,
// 0xc0ca33,
// 0xfdd835,
// 0xffb300,
// 0xfb8c00,
// 0xf4511e,
// 0xbcaaa4,
// 0xbdbdbd,
// 0xb0bec5,
// 0x4ea6e0 // pre 1.4 tickmate color
// };
// private static List<TickColor> sTickColors;
//
// public TickColor(int color) {
// mColorValue = color;
// mName = Integer.toHexString(color);
// }
//
// public Drawable getDrawable(int alpha) {
// Log.d(TAG, "getTickedButtonDrawable " + getName());
// ColorDrawable cd = new ColorDrawable(Color.parseColor(hex()));
// cd.setAlpha(alpha);
// return cd;
// }
//
// public Drawable getTickedButtonDrawable(Context c) {
// Log.d(TAG, "getTickedButtonDrawable " + getName());
// return getTickedButtonDrawable(c, mColorValue);
// }
//
// public static Drawable getTickedButtonDrawable(Context context, int tickButtonColor) {
// // Prepare the layers & color filter for the LayerDrawable
// ColorFilter cf = new LightingColorFilter(tickButtonColor, 0);
// //ColorDrawable buttonCenterDrawable = new ColorDrawable(0xFF000000 + tickButtonColor);
// Drawable buttonCenterDrawable = ContextCompat.getDrawable(context, R.drawable.mask_64);
// Drawable buttonBorderDrawable = ContextCompat.getDrawable(context, R.drawable.on_64);
// buttonCenterDrawable.setColorFilter(cf);
// sTickedButton = new LayerDrawable(new Drawable[]{buttonCenterDrawable, buttonBorderDrawable});
// return sTickedButton;
// }
//
// public static Drawable getUnTickedButtonDrawable(Context context) {
// if (sUnTickedButton == null) {
// sUnTickedButton = ContextCompat.getDrawable(context, R.drawable.off_64);
// }
// return sUnTickedButton;
// }
//
// public String hex() {
// return String.format("#%06X", mColorValue);
// }
//
// public String getName() {
// return hex();
// }
//
// public int getColorValue() {
// return mColorValue;
// }
//
// // TODO rename this
// // Give the drawables used for the preference dialog
// public static Drawable getPreferenceDrawable(Context c, int index) {
// return getTickedButtonDrawable(c, sColors[index]);
// }
//
// public static TickColor getColor(int index) {
// if (sTickColors == null) {
// sTickColors = new ArrayList();
// for (int i = 0; i < sColors.length; i++) {
// sTickColors.add(new TickColor(sColors[i]));
// }
// }
// return sTickColors.get(index);
// }
//
// public static int getNumberOfColors() {
// return sColors.length;
// }
//
// public void setColorValue(int colorValue) {
// mColorValue = colorValue;
// }
//
// }
// Path: app/src/main/java/de/smasi/tickmate/views/TickColorListAdapter.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import java.util.List;
import de.smasi.tickmate.TickColor;
package de.smasi.tickmate.views;
public class TickColorListAdapter extends BaseAdapter {
private Context mContext;
private List<String> mTickColorNames;
public TickColorListAdapter(Context c) {
mContext = c;
}
public int getCount() { | return TickColor.getNumberOfColors(); |
lordi/tickmate | app/src/main/java/de/smasi/tickmate/models/Track.java | // Path: app/src/main/java/de/smasi/tickmate/TickColor.java
// public class TickColor {
// private static final String TAG = "TickColor";
// private String mName = "Not named";
// private int mColorValue = 0;
//
// private static Drawable sUnTickedButton;
// private static Drawable sTickedButton;
//
// // Material design colors, 400-600
// // https://www.google.com/design/spec/style/color.html
// private static int[] sColors = new int[] {
// 0xf44336,
// 0xec407a,
// 0xab47bc,
// 0x673ab7,
// 0x5c6bc0,
// 0x1e88e5,
// 0x039be5,
// 0x00bcd4,
// 0x26a69a,
// 0x81c784,
// 0x7cb342,
// 0xc0ca33,
// 0xfdd835,
// 0xffb300,
// 0xfb8c00,
// 0xf4511e,
// 0xbcaaa4,
// 0xbdbdbd,
// 0xb0bec5,
// 0x4ea6e0 // pre 1.4 tickmate color
// };
// private static List<TickColor> sTickColors;
//
// public TickColor(int color) {
// mColorValue = color;
// mName = Integer.toHexString(color);
// }
//
// public Drawable getDrawable(int alpha) {
// Log.d(TAG, "getTickedButtonDrawable " + getName());
// ColorDrawable cd = new ColorDrawable(Color.parseColor(hex()));
// cd.setAlpha(alpha);
// return cd;
// }
//
// public Drawable getTickedButtonDrawable(Context c) {
// Log.d(TAG, "getTickedButtonDrawable " + getName());
// return getTickedButtonDrawable(c, mColorValue);
// }
//
// public static Drawable getTickedButtonDrawable(Context context, int tickButtonColor) {
// // Prepare the layers & color filter for the LayerDrawable
// ColorFilter cf = new LightingColorFilter(tickButtonColor, 0);
// //ColorDrawable buttonCenterDrawable = new ColorDrawable(0xFF000000 + tickButtonColor);
// Drawable buttonCenterDrawable = ContextCompat.getDrawable(context, R.drawable.mask_64);
// Drawable buttonBorderDrawable = ContextCompat.getDrawable(context, R.drawable.on_64);
// buttonCenterDrawable.setColorFilter(cf);
// sTickedButton = new LayerDrawable(new Drawable[]{buttonCenterDrawable, buttonBorderDrawable});
// return sTickedButton;
// }
//
// public static Drawable getUnTickedButtonDrawable(Context context) {
// if (sUnTickedButton == null) {
// sUnTickedButton = ContextCompat.getDrawable(context, R.drawable.off_64);
// }
// return sUnTickedButton;
// }
//
// public String hex() {
// return String.format("#%06X", mColorValue);
// }
//
// public String getName() {
// return hex();
// }
//
// public int getColorValue() {
// return mColorValue;
// }
//
// // TODO rename this
// // Give the drawables used for the preference dialog
// public static Drawable getPreferenceDrawable(Context c, int index) {
// return getTickedButtonDrawable(c, sColors[index]);
// }
//
// public static TickColor getColor(int index) {
// if (sTickColors == null) {
// sTickColors = new ArrayList();
// for (int i = 0; i < sColors.length; i++) {
// sTickColors.add(new TickColor(sColors[i]));
// }
// }
// return sTickColors.get(index);
// }
//
// public static int getNumberOfColors() {
// return sColors.length;
// }
//
// public void setColorValue(int colorValue) {
// mColorValue = colorValue;
// }
//
// }
| import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import de.smasi.tickmate.TickColor; | package de.smasi.tickmate.models;
public class Track {
private static final String TAG = "Track";
String name;
String description;
String icon;
int mId;
boolean enabled;
boolean multiple_entries_enabled;
int iconId; | // Path: app/src/main/java/de/smasi/tickmate/TickColor.java
// public class TickColor {
// private static final String TAG = "TickColor";
// private String mName = "Not named";
// private int mColorValue = 0;
//
// private static Drawable sUnTickedButton;
// private static Drawable sTickedButton;
//
// // Material design colors, 400-600
// // https://www.google.com/design/spec/style/color.html
// private static int[] sColors = new int[] {
// 0xf44336,
// 0xec407a,
// 0xab47bc,
// 0x673ab7,
// 0x5c6bc0,
// 0x1e88e5,
// 0x039be5,
// 0x00bcd4,
// 0x26a69a,
// 0x81c784,
// 0x7cb342,
// 0xc0ca33,
// 0xfdd835,
// 0xffb300,
// 0xfb8c00,
// 0xf4511e,
// 0xbcaaa4,
// 0xbdbdbd,
// 0xb0bec5,
// 0x4ea6e0 // pre 1.4 tickmate color
// };
// private static List<TickColor> sTickColors;
//
// public TickColor(int color) {
// mColorValue = color;
// mName = Integer.toHexString(color);
// }
//
// public Drawable getDrawable(int alpha) {
// Log.d(TAG, "getTickedButtonDrawable " + getName());
// ColorDrawable cd = new ColorDrawable(Color.parseColor(hex()));
// cd.setAlpha(alpha);
// return cd;
// }
//
// public Drawable getTickedButtonDrawable(Context c) {
// Log.d(TAG, "getTickedButtonDrawable " + getName());
// return getTickedButtonDrawable(c, mColorValue);
// }
//
// public static Drawable getTickedButtonDrawable(Context context, int tickButtonColor) {
// // Prepare the layers & color filter for the LayerDrawable
// ColorFilter cf = new LightingColorFilter(tickButtonColor, 0);
// //ColorDrawable buttonCenterDrawable = new ColorDrawable(0xFF000000 + tickButtonColor);
// Drawable buttonCenterDrawable = ContextCompat.getDrawable(context, R.drawable.mask_64);
// Drawable buttonBorderDrawable = ContextCompat.getDrawable(context, R.drawable.on_64);
// buttonCenterDrawable.setColorFilter(cf);
// sTickedButton = new LayerDrawable(new Drawable[]{buttonCenterDrawable, buttonBorderDrawable});
// return sTickedButton;
// }
//
// public static Drawable getUnTickedButtonDrawable(Context context) {
// if (sUnTickedButton == null) {
// sUnTickedButton = ContextCompat.getDrawable(context, R.drawable.off_64);
// }
// return sUnTickedButton;
// }
//
// public String hex() {
// return String.format("#%06X", mColorValue);
// }
//
// public String getName() {
// return hex();
// }
//
// public int getColorValue() {
// return mColorValue;
// }
//
// // TODO rename this
// // Give the drawables used for the preference dialog
// public static Drawable getPreferenceDrawable(Context c, int index) {
// return getTickedButtonDrawable(c, sColors[index]);
// }
//
// public static TickColor getColor(int index) {
// if (sTickColors == null) {
// sTickColors = new ArrayList();
// for (int i = 0; i < sColors.length; i++) {
// sTickColors.add(new TickColor(sColors[i]));
// }
// }
// return sTickColors.get(index);
// }
//
// public static int getNumberOfColors() {
// return sColors.length;
// }
//
// public void setColorValue(int colorValue) {
// mColorValue = colorValue;
// }
//
// }
// Path: app/src/main/java/de/smasi/tickmate/models/Track.java
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
import de.smasi.tickmate.TickColor;
package de.smasi.tickmate.models;
public class Track {
private static final String TAG = "Track";
String name;
String description;
String icon;
int mId;
boolean enabled;
boolean multiple_entries_enabled;
int iconId; | TickColor mTickColor = new TickColor(0x0022DD); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/core/IRtmpConnection.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/RtmpConnectListener.java
// public interface RtmpConnectListener {
// void onUrlInvalid();
// void onSocketConnectSuccess();
// void onSocketConnectFail();
// void onHandshakeSuccess();
// void onHandshakeFail();
// void onRtmpConnectSuccess();
// void onRtmpConnectFail();
// void onCreateStreamSuccess();
// void onCreateStreamFail();
// void onPublishSuccess();
// void onPublishFail();
// void onSocketDisconnect();
// void onStreamEnd();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
| import android.support.annotation.WorkerThread;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.RtmpConnectListener;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue; | package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/30.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IRtmpConnection {
//base function
@WorkerThread
void connect(String url);
void publishAudioData(byte[] data, int type);
void publishVideoData(byte[] data, int type);
void stop();
//setting | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/RtmpConnectListener.java
// public interface RtmpConnectListener {
// void onUrlInvalid();
// void onSocketConnectSuccess();
// void onSocketConnectFail();
// void onHandshakeSuccess();
// void onHandshakeFail();
// void onRtmpConnectSuccess();
// void onRtmpConnectFail();
// void onCreateStreamSuccess();
// void onCreateStreamFail();
// void onPublishSuccess();
// void onPublishFail();
// void onSocketDisconnect();
// void onStreamEnd();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IRtmpConnection.java
import android.support.annotation.WorkerThread;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.RtmpConnectListener;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/30.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IRtmpConnection {
//base function
@WorkerThread
void connect(String url);
void publishAudioData(byte[] data, int type);
void publishVideoData(byte[] data, int type);
void stop();
//setting | void setConnectListener(RtmpConnectListener listener); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/core/IRtmpConnection.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/RtmpConnectListener.java
// public interface RtmpConnectListener {
// void onUrlInvalid();
// void onSocketConnectSuccess();
// void onSocketConnectFail();
// void onHandshakeSuccess();
// void onHandshakeFail();
// void onRtmpConnectSuccess();
// void onRtmpConnectFail();
// void onCreateStreamSuccess();
// void onCreateStreamFail();
// void onPublishSuccess();
// void onPublishFail();
// void onSocketDisconnect();
// void onStreamEnd();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
| import android.support.annotation.WorkerThread;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.RtmpConnectListener;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue; | package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/30.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IRtmpConnection {
//base function
@WorkerThread
void connect(String url);
void publishAudioData(byte[] data, int type);
void publishVideoData(byte[] data, int type);
void stop();
//setting
void setConnectListener(RtmpConnectListener listener);
| // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/RtmpConnectListener.java
// public interface RtmpConnectListener {
// void onUrlInvalid();
// void onSocketConnectSuccess();
// void onSocketConnectFail();
// void onHandshakeSuccess();
// void onHandshakeFail();
// void onRtmpConnectSuccess();
// void onRtmpConnectFail();
// void onCreateStreamSuccess();
// void onCreateStreamFail();
// void onPublishSuccess();
// void onPublishFail();
// void onSocketDisconnect();
// void onStreamEnd();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IRtmpConnection.java
import android.support.annotation.WorkerThread;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.RtmpConnectListener;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/30.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IRtmpConnection {
//base function
@WorkerThread
void connect(String url);
void publishAudioData(byte[] data, int type);
void publishVideoData(byte[] data, int type);
void stop();
//setting
void setConnectListener(RtmpConnectListener listener);
| void setSendQueue(ISendQueue sendQueue); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/ReadThread.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
| import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream; | package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's read thread
*
* @author francois, leo
*/
class ReadThread extends Thread {
private RtmpDecoder rtmpDecoder;
private InputStream in;
private OnReadListener listener;
private volatile boolean startFlag;
ReadThread(InputStream in, SessionInfo sessionInfo) {
this.in = in;
this.rtmpDecoder = new RtmpDecoder(sessionInfo);
startFlag = true;
}
void setOnReadListener(OnReadListener listener) {
this.listener = listener;
}
@Override
public void run() {
while (startFlag) {
try { | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/ReadThread.java
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's read thread
*
* @author francois, leo
*/
class ReadThread extends Thread {
private RtmpDecoder rtmpDecoder;
private InputStream in;
private OnReadListener listener;
private volatile boolean startFlag;
ReadThread(InputStream in, SessionInfo sessionInfo) {
this.in = in;
this.rtmpDecoder = new RtmpDecoder(sessionInfo);
startFlag = true;
}
void setOnReadListener(OnReadListener listener) {
this.listener = listener;
}
@Override
public void run() {
while (startFlag) {
try { | Chunk chunk = rtmpDecoder.readPacket(in); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/core/IAudio.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IAudioEncodeDelegate.java
// public interface IAudioEncodeDelegate {
// void onAudioEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
| import org.yeshen.video.librtmp.core.delegate.IAudioEncodeDelegate; | package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/21.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IAudio {
void start();
void stop();
void pause();
void resume();
void mute(boolean mute);
int getSessionId(); | // Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IAudioEncodeDelegate.java
// public interface IAudioEncodeDelegate {
// void onAudioEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IAudio.java
import org.yeshen.video.librtmp.core.delegate.IAudioEncodeDelegate;
package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/21.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IAudio {
void start();
void stop();
void pause();
void resume();
void mute(boolean mute);
int getSessionId(); | void setAudioEncodeListener(IAudioEncodeDelegate listener); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/LivingView.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/ILivingView.java
// public interface ILivingView {
//
// void syncConfig();
//
// void setDelegate(@NonNull ICameraOpenDelegate delegate);
//
// IRenderer getRenderer();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/ICameraOpenDelegate.java
// public interface ICameraOpenDelegate {
// int CAMERA_NOT_SUPPORT = 1;
// int NO_CAMERA = 2;
// int CAMERA_DISABLED = 3;
// int CAMERA_OPEN_FAILED = 4;
//
// void onOpenSuccess();
// void onOpenFail(int error);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
| import android.annotation.TargetApi;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.yeshen.video.librtmp.R;
import org.yeshen.video.librtmp.core.ILivingView;
import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.delegate.ICameraOpenDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg; | package org.yeshen.video.librtmp.unstable;
/*********************************************************************
* Created by yeshen on 2017/05/21.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public class LivingView extends FrameLayout implements ILivingView {
private ICameraOpenDelegate mLivingDelegate;
private boolean isRenderSurfaceViewShowing = true;
private SurfaceHolder.Callback mSurfaceHolderCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceDestroyed(SurfaceHolder holder) { | // Path: app/src/main/java/org/yeshen/video/librtmp/core/ILivingView.java
// public interface ILivingView {
//
// void syncConfig();
//
// void setDelegate(@NonNull ICameraOpenDelegate delegate);
//
// IRenderer getRenderer();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/ICameraOpenDelegate.java
// public interface ICameraOpenDelegate {
// int CAMERA_NOT_SUPPORT = 1;
// int NO_CAMERA = 2;
// int CAMERA_DISABLED = 3;
// int CAMERA_OPEN_FAILED = 4;
//
// void onOpenSuccess();
// void onOpenFail(int error);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/LivingView.java
import android.annotation.TargetApi;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.yeshen.video.librtmp.R;
import org.yeshen.video.librtmp.core.ILivingView;
import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.delegate.ICameraOpenDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg;
package org.yeshen.video.librtmp.unstable;
/*********************************************************************
* Created by yeshen on 2017/05/21.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public class LivingView extends FrameLayout implements ILivingView {
private ICameraOpenDelegate mLivingDelegate;
private boolean isRenderSurfaceViewShowing = true;
private SurfaceHolder.Callback mSurfaceHolderCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceDestroyed(SurfaceHolder holder) { | Lg.d("SurfaceView destroy"); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/LivingView.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/ILivingView.java
// public interface ILivingView {
//
// void syncConfig();
//
// void setDelegate(@NonNull ICameraOpenDelegate delegate);
//
// IRenderer getRenderer();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/ICameraOpenDelegate.java
// public interface ICameraOpenDelegate {
// int CAMERA_NOT_SUPPORT = 1;
// int NO_CAMERA = 2;
// int CAMERA_DISABLED = 3;
// int CAMERA_OPEN_FAILED = 4;
//
// void onOpenSuccess();
// void onOpenFail(int error);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
| import android.annotation.TargetApi;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.yeshen.video.librtmp.R;
import org.yeshen.video.librtmp.core.ILivingView;
import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.delegate.ICameraOpenDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg; | super.setVisibility(visibility);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
float mAspectRatio = 9.0f / 16;
if (widthSpecMode == MeasureSpec.EXACTLY && heightSpecMode == MeasureSpec.AT_MOST) {
heightSpecSize = (int) (widthSpecSize / mAspectRatio);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSpecSize,
MeasureSpec.EXACTLY);
} else if (widthSpecMode == MeasureSpec.AT_MOST && heightSpecMode == MeasureSpec.EXACTLY) {
widthSpecSize = (int) (heightSpecSize * mAspectRatio);
widthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSpecSize,
MeasureSpec.EXACTLY);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
public void setDelegate(@NonNull ICameraOpenDelegate delegate) {
mLivingDelegate = delegate;
}
@Override | // Path: app/src/main/java/org/yeshen/video/librtmp/core/ILivingView.java
// public interface ILivingView {
//
// void syncConfig();
//
// void setDelegate(@NonNull ICameraOpenDelegate delegate);
//
// IRenderer getRenderer();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/ICameraOpenDelegate.java
// public interface ICameraOpenDelegate {
// int CAMERA_NOT_SUPPORT = 1;
// int NO_CAMERA = 2;
// int CAMERA_DISABLED = 3;
// int CAMERA_OPEN_FAILED = 4;
//
// void onOpenSuccess();
// void onOpenFail(int error);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/LivingView.java
import android.annotation.TargetApi;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.yeshen.video.librtmp.R;
import org.yeshen.video.librtmp.core.ILivingView;
import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.delegate.ICameraOpenDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg;
super.setVisibility(visibility);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
float mAspectRatio = 9.0f / 16;
if (widthSpecMode == MeasureSpec.EXACTLY && heightSpecMode == MeasureSpec.AT_MOST) {
heightSpecSize = (int) (widthSpecSize / mAspectRatio);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSpecSize,
MeasureSpec.EXACTLY);
} else if (widthSpecMode == MeasureSpec.AT_MOST && heightSpecMode == MeasureSpec.EXACTLY) {
widthSpecSize = (int) (heightSpecSize * mAspectRatio);
widthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSpecSize,
MeasureSpec.EXACTLY);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
public void setDelegate(@NonNull ICameraOpenDelegate delegate) {
mLivingDelegate = delegate;
}
@Override | public IRenderer getRenderer() { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Toasts.java | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
| import android.widget.Toast;
import org.yeshen.video.librtmp.App; | package org.yeshen.video.librtmp.unstable.tools;
/*********************************************************************
* Created by yeshen on 2017/05/20.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public class Toasts {
public static void str(String msg) { | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Toasts.java
import android.widget.Toast;
import org.yeshen.video.librtmp.App;
package org.yeshen.video.librtmp.unstable.tools;
/*********************************************************************
* Created by yeshen on 2017/05/20.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public class Toasts {
public static void str(String msg) { | Toast.makeText(App.getInstance(), msg, Toast.LENGTH_SHORT).show(); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/core/IVideo.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
| import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate; | package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/21.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IVideo {
void start();
void stop();
void pause();
void resume();
boolean setVideoBps(int bps); | // Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IVideo.java
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate;
package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/21.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IVideo {
void start();
void stop();
void pause();
void resume();
boolean setVideoBps(int bps); | void setVideoEncoderListener(IVideoEncodeDelegate listener); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/core/IRecorder.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
| import android.support.annotation.NonNull;
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate; | package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/28.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IRecorder {
void pause();
void resume(); | // Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IRecorder.java
import android.support.annotation.NonNull;
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate;
package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/28.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface IRecorder {
void pause();
void resume(); | void prepare(@NonNull IVideoEncodeDelegate delegate); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
| import org.yeshen.video.librtmp.unstable.net.Frame; | package org.yeshen.video.librtmp.unstable.net.sender.sendqueue;
/**
* @Title: ISendQueue
* @Package org.yeshen.video.librtmp.afix.net.sender.sendqueue
* @Description:
* @Author Jim
* @Date 2016/11/21
* @Time 上午10:15
* @Version
*/
public interface ISendQueue {
void start();
void stop();
void setBufferSize(int size); | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
import org.yeshen.video.librtmp.unstable.net.Frame;
package org.yeshen.video.librtmp.unstable.net.sender.sendqueue;
/**
* @Title: ISendQueue
* @Package org.yeshen.video.librtmp.afix.net.sender.sendqueue
* @Description:
* @Author Jim
* @Date 2016/11/21
* @Time 上午10:15
* @Version
*/
public interface ISendQueue {
void start();
void stop();
void setBufferSize(int size); | void putFrame(Frame frame); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/ControllerCameraVideo.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IVideo.java
// public interface IVideo {
// void start();
// void stop();
// void pause();
// void resume();
// boolean setVideoBps(int bps);
// void setVideoEncoderListener(IVideoEncodeDelegate listener);
// void setVideoConfiguration();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
| import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.IVideo;
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg; | package org.yeshen.video.librtmp.unstable;
public class ControllerCameraVideo implements IVideo {
private RecorderImpl mRecorderImpl; | // Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IVideo.java
// public interface IVideo {
// void start();
// void stop();
// void pause();
// void resume();
// boolean setVideoBps(int bps);
// void setVideoEncoderListener(IVideoEncodeDelegate listener);
// void setVideoConfiguration();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/ControllerCameraVideo.java
import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.IVideo;
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg;
package org.yeshen.video.librtmp.unstable;
public class ControllerCameraVideo implements IVideo {
private RecorderImpl mRecorderImpl; | private IRenderer mRenderer; |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/ControllerCameraVideo.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IVideo.java
// public interface IVideo {
// void start();
// void stop();
// void pause();
// void resume();
// boolean setVideoBps(int bps);
// void setVideoEncoderListener(IVideoEncodeDelegate listener);
// void setVideoConfiguration();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
| import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.IVideo;
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg; | package org.yeshen.video.librtmp.unstable;
public class ControllerCameraVideo implements IVideo {
private RecorderImpl mRecorderImpl;
private IRenderer mRenderer; | // Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IVideo.java
// public interface IVideo {
// void start();
// void stop();
// void pause();
// void resume();
// boolean setVideoBps(int bps);
// void setVideoEncoderListener(IVideoEncodeDelegate listener);
// void setVideoConfiguration();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/ControllerCameraVideo.java
import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.IVideo;
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg;
package org.yeshen.video.librtmp.unstable;
public class ControllerCameraVideo implements IVideo {
private RecorderImpl mRecorderImpl;
private IRenderer mRenderer; | private IVideoEncodeDelegate mListener; |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/ControllerCameraVideo.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IVideo.java
// public interface IVideo {
// void start();
// void stop();
// void pause();
// void resume();
// boolean setVideoBps(int bps);
// void setVideoEncoderListener(IVideoEncodeDelegate listener);
// void setVideoConfiguration();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
| import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.IVideo;
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg; | package org.yeshen.video.librtmp.unstable;
public class ControllerCameraVideo implements IVideo {
private RecorderImpl mRecorderImpl;
private IRenderer mRenderer;
private IVideoEncodeDelegate mListener;
public ControllerCameraVideo(IRenderer renderer) {
mRenderer = renderer;
mRenderer.syncVideoConfig();
}
public void setVideoConfiguration() {
mRenderer.syncVideoConfig();
}
public void setVideoEncoderListener(IVideoEncodeDelegate listener) {
mListener = listener;
}
public void start() {
if(mListener == null) {
return;
} | // Path: app/src/main/java/org/yeshen/video/librtmp/core/IRenderer.java
// public interface IRenderer extends GLSurfaceView.Renderer
// , SurfaceTexture.OnFrameAvailableListener {
//
// //render status
// int NO_ERROR = 0;
// int VIDEO_TYPE_ERROR = 1;
// int AUDIO_TYPE_ERROR = 2;
// int VIDEO_CONFIGURATION_ERROR = 3;
// int AUDIO_CONFIGURATION_ERROR = 4;
// int CAMERA_ERROR = 5;
// int AUDIO_ERROR = 6;
// int AUDIO_AEC_ERROR = 7;
// int SDK_VERSION_ERROR = 8;
//
// void setCameraOpenListener(ICameraOpenDelegate cameraOpenListener);
// void syncVideoConfig();
// void enableRecord(@NonNull RecorderImpl recorderImpl);
// void disableRecord();
// int checkStatus();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/IVideo.java
// public interface IVideo {
// void start();
// void stop();
// void pause();
// void resume();
// boolean setVideoBps(int bps);
// void setVideoEncoderListener(IVideoEncodeDelegate listener);
// void setVideoConfiguration();
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/IVideoEncodeDelegate.java
// public interface IVideoEncodeDelegate {
// void onVideoEncode(ByteBuffer bb, MediaCodec.BufferInfo bi);
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/ControllerCameraVideo.java
import org.yeshen.video.librtmp.core.IRenderer;
import org.yeshen.video.librtmp.core.IVideo;
import org.yeshen.video.librtmp.core.delegate.IVideoEncodeDelegate;
import org.yeshen.video.librtmp.unstable.tools.Lg;
package org.yeshen.video.librtmp.unstable;
public class ControllerCameraVideo implements IVideo {
private RecorderImpl mRecorderImpl;
private IRenderer mRenderer;
private IVideoEncodeDelegate mListener;
public ControllerCameraVideo(IRenderer renderer) {
mRenderer = renderer;
mRenderer.syncVideoConfig();
}
public void setVideoConfiguration() {
mRenderer.syncVideoConfig();
}
public void setVideoEncoderListener(IVideoEncodeDelegate listener) {
mListener = listener;
}
public void start() {
if(mListener == null) {
return;
} | Lg.d( "Start video recording"); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
| import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk; | package org.yeshen.video.librtmp.unstable.net;
/*********************************************************************
* Created by yeshen on 2017/05/21.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public class Frame {
public static final int FRAME_TYPE_AUDIO = 1;
public static final int FRAME_TYPE_KEY_FRAME = 2;
public static final int FRAME_TYPE_INTER_FRAME = 3;
public static final int FRAME_TYPE_CONFIGURATION = 4;
| // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
package org.yeshen.video.librtmp.unstable.net;
/*********************************************************************
* Created by yeshen on 2017/05/21.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public class Frame {
public static final int FRAME_TYPE_AUDIO = 1;
public static final int FRAME_TYPE_KEY_FRAME = 2;
public static final int FRAME_TYPE_INTER_FRAME = 3;
public static final int FRAME_TYPE_CONFIGURATION = 4;
| public Chunk data; |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Audio.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/SessionInfo.java
// public class SessionInfo {
//
// public static final byte RTMP_STREAM_CHANNEL = 0x05;
// public static final byte RTMP_COMMAND_CHANNEL = 0x03;
// public static final byte RTMP_VIDEO_CHANNEL = 0x06;
// public static final byte RTMP_AUDIO_CHANNEL = 0x07;
// public static final byte RTMP_CONTROL_CHANNEL = 0x02;
//
// /** The window acknowledgement size for this RTMP session, in bytes; default to max to avoid unnecessary "Acknowledgment" messages from being sent */
// private int acknowledgementWindowSize = Integer.MAX_VALUE;
// /** Used internally to store the total number of bytes read (used when sending Acknowledgement messages) */
// private int totalBytesRead = 0;
//
// /** Default chunk size is 128 bytes */
// private int rxChunkSize = 128;
// private int txChunkSize = 128;
// private Map<Integer, ChunkHeader> chunkReceiveChannels = new HashMap<>();
// private Map<Integer, ChunkHeader> chunkSendChannels = new HashMap<>();
// private Map<Integer, String> invokedMethods = new ConcurrentHashMap<>();
//
// public ChunkHeader getPreReceiveChunkHeader(int chunkStreamId) {
// return chunkReceiveChannels.get(chunkStreamId);
// }
//
// public void putPreReceiveChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkReceiveChannels.put(chunkStreamId, chunkHeader);
// }
//
// public ChunkHeader getPreSendChunkHeader(int chunkStreamId) {
// return chunkSendChannels.get(chunkStreamId);
// }
//
// public void putPreSendChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkSendChannels.put(chunkStreamId, chunkHeader);
// }
//
// public String takeInvokedCommand(int transactionId) {
// return invokedMethods.remove(transactionId);
// }
//
// public String addInvokedCommand(int transactionId, String commandName) {
// return invokedMethods.put(transactionId, commandName);
// }
//
// public int getRxChunkSize() {
// return rxChunkSize;
// }
//
// public void setRxChunkSize(int chunkSize) {
// this.rxChunkSize = chunkSize;
// }
//
// public int getTxChunkSize() {
// return txChunkSize;
// }
//
// public void setTxChunkSize(int chunkSize) {
// this.txChunkSize = chunkSize;
// }
//
// public int getAcknowledgementWindowSize() {
// return acknowledgementWindowSize;
// }
//
// public void setAcknowledgmentWindowSize(int acknowledgementWindowSize) {
// this.acknowledgementWindowSize = acknowledgementWindowSize;
// }
//
// private static long sessionBeginTimestamp;
//
// /** Sets the session beginning timestamp for all chunks */
// public static void markSessionTimestampTx() {
// sessionBeginTimestamp = System.nanoTime() / 1000000;
// }
//
// /** Utility method for calculating & synchronizing transmitted timestamps */
// public long markAbsoluteTimestampTx() {
// return System.nanoTime() / 1000000 - sessionBeginTimestamp;
// }
// }
| import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.SessionInfo; | package org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets;
/**
* Audio data packet
*
* @author francois
*/
public class Audio extends ContentData {
public Audio(ChunkHeader header) {
super(header);
}
public Audio() { | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/SessionInfo.java
// public class SessionInfo {
//
// public static final byte RTMP_STREAM_CHANNEL = 0x05;
// public static final byte RTMP_COMMAND_CHANNEL = 0x03;
// public static final byte RTMP_VIDEO_CHANNEL = 0x06;
// public static final byte RTMP_AUDIO_CHANNEL = 0x07;
// public static final byte RTMP_CONTROL_CHANNEL = 0x02;
//
// /** The window acknowledgement size for this RTMP session, in bytes; default to max to avoid unnecessary "Acknowledgment" messages from being sent */
// private int acknowledgementWindowSize = Integer.MAX_VALUE;
// /** Used internally to store the total number of bytes read (used when sending Acknowledgement messages) */
// private int totalBytesRead = 0;
//
// /** Default chunk size is 128 bytes */
// private int rxChunkSize = 128;
// private int txChunkSize = 128;
// private Map<Integer, ChunkHeader> chunkReceiveChannels = new HashMap<>();
// private Map<Integer, ChunkHeader> chunkSendChannels = new HashMap<>();
// private Map<Integer, String> invokedMethods = new ConcurrentHashMap<>();
//
// public ChunkHeader getPreReceiveChunkHeader(int chunkStreamId) {
// return chunkReceiveChannels.get(chunkStreamId);
// }
//
// public void putPreReceiveChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkReceiveChannels.put(chunkStreamId, chunkHeader);
// }
//
// public ChunkHeader getPreSendChunkHeader(int chunkStreamId) {
// return chunkSendChannels.get(chunkStreamId);
// }
//
// public void putPreSendChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkSendChannels.put(chunkStreamId, chunkHeader);
// }
//
// public String takeInvokedCommand(int transactionId) {
// return invokedMethods.remove(transactionId);
// }
//
// public String addInvokedCommand(int transactionId, String commandName) {
// return invokedMethods.put(transactionId, commandName);
// }
//
// public int getRxChunkSize() {
// return rxChunkSize;
// }
//
// public void setRxChunkSize(int chunkSize) {
// this.rxChunkSize = chunkSize;
// }
//
// public int getTxChunkSize() {
// return txChunkSize;
// }
//
// public void setTxChunkSize(int chunkSize) {
// this.txChunkSize = chunkSize;
// }
//
// public int getAcknowledgementWindowSize() {
// return acknowledgementWindowSize;
// }
//
// public void setAcknowledgmentWindowSize(int acknowledgementWindowSize) {
// this.acknowledgementWindowSize = acknowledgementWindowSize;
// }
//
// private static long sessionBeginTimestamp;
//
// /** Sets the session beginning timestamp for all chunks */
// public static void markSessionTimestampTx() {
// sessionBeginTimestamp = System.nanoTime() / 1000000;
// }
//
// /** Utility method for calculating & synchronizing transmitted timestamps */
// public long markAbsoluteTimestampTx() {
// return System.nanoTime() / 1000000 - sessionBeginTimestamp;
// }
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Audio.java
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.SessionInfo;
package org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets;
/**
* Audio data packet
*
* @author francois
*/
public class Audio extends ContentData {
public Audio(ChunkHeader header) {
super(header);
}
public Audio() { | super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_AUDIO_CHANNEL, MessageType.AUDIO)); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME; | package org.yeshen.video.librtmp.unstable.net.sender.sendqueue;
/**
* @Title: NormalSendQueue
* @Package org.yeshen.video.librtmp.afix.net.sender.sendqueue
* @Description:
* @Author Jim
* @Date 2016/11/21
* @Time 上午10:33
* @Version
*/
public class NormalSendQueue implements ISendQueue {
private static final int NORMAL_FRAME_BUFFER_SIZE = 800; | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME;
package org.yeshen.video.librtmp.unstable.net.sender.sendqueue;
/**
* @Title: NormalSendQueue
* @Package org.yeshen.video.librtmp.afix.net.sender.sendqueue
* @Description:
* @Author Jim
* @Date 2016/11/21
* @Time 上午10:33
* @Version
*/
public class NormalSendQueue implements ISendQueue {
private static final int NORMAL_FRAME_BUFFER_SIZE = 800; | private ArrayBlockingQueue<Frame> mFrameBuffer; |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME; | mFrameBuffer.put(frame);
mInFrameCount.getAndIncrement();
mTotalFrameCount.getAndIncrement();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public Frame takeFrame() {
if (mFrameBuffer == null) {
return null;
}
Frame frame = null;
try {
frame = mFrameBuffer.take();
mOutFrameCount.getAndIncrement();
mTotalFrameCount.getAndDecrement();
} catch (InterruptedException e) {
//do nothing
}
return frame;
}
private void abandonData() {
if (mTotalFrameCount.get() >= (mFullQueueCount / 2)) {
//从队列头部开始搜索,删除最早发现的连续P帧
boolean pFrameDelete = false;
boolean start = false;
for (Frame frame : mFrameBuffer) { | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME;
mFrameBuffer.put(frame);
mInFrameCount.getAndIncrement();
mTotalFrameCount.getAndIncrement();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public Frame takeFrame() {
if (mFrameBuffer == null) {
return null;
}
Frame frame = null;
try {
frame = mFrameBuffer.take();
mOutFrameCount.getAndIncrement();
mTotalFrameCount.getAndDecrement();
} catch (InterruptedException e) {
//do nothing
}
return frame;
}
private void abandonData() {
if (mTotalFrameCount.get() >= (mFullQueueCount / 2)) {
//从队列头部开始搜索,删除最早发现的连续P帧
boolean pFrameDelete = false;
boolean start = false;
for (Frame frame : mFrameBuffer) { | if (frame.frameType == FRAME_TYPE_INTER_FRAME) { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME; | public Frame takeFrame() {
if (mFrameBuffer == null) {
return null;
}
Frame frame = null;
try {
frame = mFrameBuffer.take();
mOutFrameCount.getAndIncrement();
mTotalFrameCount.getAndDecrement();
} catch (InterruptedException e) {
//do nothing
}
return frame;
}
private void abandonData() {
if (mTotalFrameCount.get() >= (mFullQueueCount / 2)) {
//从队列头部开始搜索,删除最早发现的连续P帧
boolean pFrameDelete = false;
boolean start = false;
for (Frame frame : mFrameBuffer) {
if (frame.frameType == FRAME_TYPE_INTER_FRAME) {
start = true;
}
if (start) {
if (frame.frameType == FRAME_TYPE_INTER_FRAME) {
mFrameBuffer.remove(frame);
mTotalFrameCount.getAndDecrement();
mGiveUpFrameCount.getAndIncrement();
pFrameDelete = true; | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME;
public Frame takeFrame() {
if (mFrameBuffer == null) {
return null;
}
Frame frame = null;
try {
frame = mFrameBuffer.take();
mOutFrameCount.getAndIncrement();
mTotalFrameCount.getAndDecrement();
} catch (InterruptedException e) {
//do nothing
}
return frame;
}
private void abandonData() {
if (mTotalFrameCount.get() >= (mFullQueueCount / 2)) {
//从队列头部开始搜索,删除最早发现的连续P帧
boolean pFrameDelete = false;
boolean start = false;
for (Frame frame : mFrameBuffer) {
if (frame.frameType == FRAME_TYPE_INTER_FRAME) {
start = true;
}
if (start) {
if (frame.frameType == FRAME_TYPE_INTER_FRAME) {
mFrameBuffer.remove(frame);
mTotalFrameCount.getAndDecrement();
mGiveUpFrameCount.getAndIncrement();
pFrameDelete = true; | } else if (frame.frameType == FRAME_TYPE_KEY_FRAME) { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME; | if (frame.frameType == FRAME_TYPE_INTER_FRAME) {
start = true;
}
if (start) {
if (frame.frameType == FRAME_TYPE_INTER_FRAME) {
mFrameBuffer.remove(frame);
mTotalFrameCount.getAndDecrement();
mGiveUpFrameCount.getAndIncrement();
pFrameDelete = true;
} else if (frame.frameType == FRAME_TYPE_KEY_FRAME) {
break;
}
}
}
boolean kFrameDelete = false;
//从队列头部开始搜索,删除最早发现的I帧
if (!pFrameDelete) {
for (Frame frame : mFrameBuffer) {
if (frame.frameType == FRAME_TYPE_KEY_FRAME) {
mFrameBuffer.remove(frame);
mTotalFrameCount.getAndDecrement();
mGiveUpFrameCount.getAndIncrement();
kFrameDelete = true;
break;
}
}
}
//从队列头部开始搜索,删除音频
if (!pFrameDelete && !kFrameDelete) {
for (Frame frame : mFrameBuffer) { | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME;
if (frame.frameType == FRAME_TYPE_INTER_FRAME) {
start = true;
}
if (start) {
if (frame.frameType == FRAME_TYPE_INTER_FRAME) {
mFrameBuffer.remove(frame);
mTotalFrameCount.getAndDecrement();
mGiveUpFrameCount.getAndIncrement();
pFrameDelete = true;
} else if (frame.frameType == FRAME_TYPE_KEY_FRAME) {
break;
}
}
}
boolean kFrameDelete = false;
//从队列头部开始搜索,删除最早发现的I帧
if (!pFrameDelete) {
for (Frame frame : mFrameBuffer) {
if (frame.frameType == FRAME_TYPE_KEY_FRAME) {
mFrameBuffer.remove(frame);
mTotalFrameCount.getAndDecrement();
mGiveUpFrameCount.getAndIncrement();
kFrameDelete = true;
break;
}
}
}
//从队列头部开始搜索,删除音频
if (!pFrameDelete && !kFrameDelete) {
for (Frame frame : mFrameBuffer) { | if (frame.frameType == FRAME_TYPE_AUDIO) { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME; | mTotalFrameCount.getAndDecrement();
mGiveUpFrameCount.getAndIncrement();
break;
}
}
}
}
}
private class ScanThread extends Thread {
private static final int SCAN_MAX_TIME = 6;
private int mCurrentScanTime = 0;
private ArrayList<ScanSnapShot> mScanSnapShotList = new ArrayList<>();
@Override
public void run() {
while (mScanFlag) {
//达到仲裁次数了
if (mCurrentScanTime == SCAN_MAX_TIME) {
int averageDif = 0;
int negativeCounter = 0;
String strLog = "";
for (int i = 0; i < SCAN_MAX_TIME; i++) {
int dif = mScanSnapShotList.get(i).outCount - mScanSnapShotList.get(i).inCount;
if (dif < 0) {
negativeCounter++;
}
averageDif += dif;
strLog = strLog + String.format(Locale.CHINA, "n%d:%d ", i, dif);
} | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_AUDIO = 1;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_INTER_FRAME = 3;
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/NormalSendQueue.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.util.ArrayList;
import java.util.Locale;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_AUDIO;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_INTER_FRAME;
import static org.yeshen.video.librtmp.unstable.net.Frame.FRAME_TYPE_KEY_FRAME;
mTotalFrameCount.getAndDecrement();
mGiveUpFrameCount.getAndIncrement();
break;
}
}
}
}
}
private class ScanThread extends Thread {
private static final int SCAN_MAX_TIME = 6;
private int mCurrentScanTime = 0;
private ArrayList<ScanSnapShot> mScanSnapShotList = new ArrayList<>();
@Override
public void run() {
while (mScanFlag) {
//达到仲裁次数了
if (mCurrentScanTime == SCAN_MAX_TIME) {
int averageDif = 0;
int negativeCounter = 0;
String strLog = "";
for (int i = 0; i < SCAN_MAX_TIME; i++) {
int dif = mScanSnapShotList.get(i).outCount - mScanSnapShotList.get(i).inCount;
if (dif < 0) {
negativeCounter++;
}
averageDif += dif;
strLog = strLog + String.format(Locale.CHINA, "n%d:%d ", i, dif);
} | Lg.d(strLog); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/SessionInfo.java
// public class SessionInfo {
//
// public static final byte RTMP_STREAM_CHANNEL = 0x05;
// public static final byte RTMP_COMMAND_CHANNEL = 0x03;
// public static final byte RTMP_VIDEO_CHANNEL = 0x06;
// public static final byte RTMP_AUDIO_CHANNEL = 0x07;
// public static final byte RTMP_CONTROL_CHANNEL = 0x02;
//
// /** The window acknowledgement size for this RTMP session, in bytes; default to max to avoid unnecessary "Acknowledgment" messages from being sent */
// private int acknowledgementWindowSize = Integer.MAX_VALUE;
// /** Used internally to store the total number of bytes read (used when sending Acknowledgement messages) */
// private int totalBytesRead = 0;
//
// /** Default chunk size is 128 bytes */
// private int rxChunkSize = 128;
// private int txChunkSize = 128;
// private Map<Integer, ChunkHeader> chunkReceiveChannels = new HashMap<>();
// private Map<Integer, ChunkHeader> chunkSendChannels = new HashMap<>();
// private Map<Integer, String> invokedMethods = new ConcurrentHashMap<>();
//
// public ChunkHeader getPreReceiveChunkHeader(int chunkStreamId) {
// return chunkReceiveChannels.get(chunkStreamId);
// }
//
// public void putPreReceiveChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkReceiveChannels.put(chunkStreamId, chunkHeader);
// }
//
// public ChunkHeader getPreSendChunkHeader(int chunkStreamId) {
// return chunkSendChannels.get(chunkStreamId);
// }
//
// public void putPreSendChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkSendChannels.put(chunkStreamId, chunkHeader);
// }
//
// public String takeInvokedCommand(int transactionId) {
// return invokedMethods.remove(transactionId);
// }
//
// public String addInvokedCommand(int transactionId, String commandName) {
// return invokedMethods.put(transactionId, commandName);
// }
//
// public int getRxChunkSize() {
// return rxChunkSize;
// }
//
// public void setRxChunkSize(int chunkSize) {
// this.rxChunkSize = chunkSize;
// }
//
// public int getTxChunkSize() {
// return txChunkSize;
// }
//
// public void setTxChunkSize(int chunkSize) {
// this.txChunkSize = chunkSize;
// }
//
// public int getAcknowledgementWindowSize() {
// return acknowledgementWindowSize;
// }
//
// public void setAcknowledgmentWindowSize(int acknowledgementWindowSize) {
// this.acknowledgementWindowSize = acknowledgementWindowSize;
// }
//
// private static long sessionBeginTimestamp;
//
// /** Sets the session beginning timestamp for all chunks */
// public static void markSessionTimestampTx() {
// sessionBeginTimestamp = System.nanoTime() / 1000000;
// }
//
// /** Utility method for calculating & synchronizing transmitted timestamps */
// public long markAbsoluteTimestampTx() {
// return System.nanoTime() / 1000000 - sessionBeginTimestamp;
// }
// }
| import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.SessionInfo;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; | package org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets;
/**
*
* @author francois, leo
*/
public abstract class Chunk {
protected ChunkHeader header;
public Chunk(ChunkHeader header) {
this.header = header;
}
public ChunkHeader getChunkHeader() {
return header;
}
public abstract void readBody(InputStream in) throws IOException;
protected abstract void writeBody(OutputStream out) throws IOException;
| // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/SessionInfo.java
// public class SessionInfo {
//
// public static final byte RTMP_STREAM_CHANNEL = 0x05;
// public static final byte RTMP_COMMAND_CHANNEL = 0x03;
// public static final byte RTMP_VIDEO_CHANNEL = 0x06;
// public static final byte RTMP_AUDIO_CHANNEL = 0x07;
// public static final byte RTMP_CONTROL_CHANNEL = 0x02;
//
// /** The window acknowledgement size for this RTMP session, in bytes; default to max to avoid unnecessary "Acknowledgment" messages from being sent */
// private int acknowledgementWindowSize = Integer.MAX_VALUE;
// /** Used internally to store the total number of bytes read (used when sending Acknowledgement messages) */
// private int totalBytesRead = 0;
//
// /** Default chunk size is 128 bytes */
// private int rxChunkSize = 128;
// private int txChunkSize = 128;
// private Map<Integer, ChunkHeader> chunkReceiveChannels = new HashMap<>();
// private Map<Integer, ChunkHeader> chunkSendChannels = new HashMap<>();
// private Map<Integer, String> invokedMethods = new ConcurrentHashMap<>();
//
// public ChunkHeader getPreReceiveChunkHeader(int chunkStreamId) {
// return chunkReceiveChannels.get(chunkStreamId);
// }
//
// public void putPreReceiveChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkReceiveChannels.put(chunkStreamId, chunkHeader);
// }
//
// public ChunkHeader getPreSendChunkHeader(int chunkStreamId) {
// return chunkSendChannels.get(chunkStreamId);
// }
//
// public void putPreSendChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkSendChannels.put(chunkStreamId, chunkHeader);
// }
//
// public String takeInvokedCommand(int transactionId) {
// return invokedMethods.remove(transactionId);
// }
//
// public String addInvokedCommand(int transactionId, String commandName) {
// return invokedMethods.put(transactionId, commandName);
// }
//
// public int getRxChunkSize() {
// return rxChunkSize;
// }
//
// public void setRxChunkSize(int chunkSize) {
// this.rxChunkSize = chunkSize;
// }
//
// public int getTxChunkSize() {
// return txChunkSize;
// }
//
// public void setTxChunkSize(int chunkSize) {
// this.txChunkSize = chunkSize;
// }
//
// public int getAcknowledgementWindowSize() {
// return acknowledgementWindowSize;
// }
//
// public void setAcknowledgmentWindowSize(int acknowledgementWindowSize) {
// this.acknowledgementWindowSize = acknowledgementWindowSize;
// }
//
// private static long sessionBeginTimestamp;
//
// /** Sets the session beginning timestamp for all chunks */
// public static void markSessionTimestampTx() {
// sessionBeginTimestamp = System.nanoTime() / 1000000;
// }
//
// /** Utility method for calculating & synchronizing transmitted timestamps */
// public long markAbsoluteTimestampTx() {
// return System.nanoTime() / 1000000 - sessionBeginTimestamp;
// }
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.SessionInfo;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
package org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets;
/**
*
* @author francois, leo
*/
public abstract class Chunk {
protected ChunkHeader header;
public Chunk(ChunkHeader header) {
this.header = header;
}
public ChunkHeader getChunkHeader() {
return header;
}
public abstract void readBody(InputStream in) throws IOException;
protected abstract void writeBody(OutputStream out) throws IOException;
| public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Video.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/SessionInfo.java
// public class SessionInfo {
//
// public static final byte RTMP_STREAM_CHANNEL = 0x05;
// public static final byte RTMP_COMMAND_CHANNEL = 0x03;
// public static final byte RTMP_VIDEO_CHANNEL = 0x06;
// public static final byte RTMP_AUDIO_CHANNEL = 0x07;
// public static final byte RTMP_CONTROL_CHANNEL = 0x02;
//
// /** The window acknowledgement size for this RTMP session, in bytes; default to max to avoid unnecessary "Acknowledgment" messages from being sent */
// private int acknowledgementWindowSize = Integer.MAX_VALUE;
// /** Used internally to store the total number of bytes read (used when sending Acknowledgement messages) */
// private int totalBytesRead = 0;
//
// /** Default chunk size is 128 bytes */
// private int rxChunkSize = 128;
// private int txChunkSize = 128;
// private Map<Integer, ChunkHeader> chunkReceiveChannels = new HashMap<>();
// private Map<Integer, ChunkHeader> chunkSendChannels = new HashMap<>();
// private Map<Integer, String> invokedMethods = new ConcurrentHashMap<>();
//
// public ChunkHeader getPreReceiveChunkHeader(int chunkStreamId) {
// return chunkReceiveChannels.get(chunkStreamId);
// }
//
// public void putPreReceiveChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkReceiveChannels.put(chunkStreamId, chunkHeader);
// }
//
// public ChunkHeader getPreSendChunkHeader(int chunkStreamId) {
// return chunkSendChannels.get(chunkStreamId);
// }
//
// public void putPreSendChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkSendChannels.put(chunkStreamId, chunkHeader);
// }
//
// public String takeInvokedCommand(int transactionId) {
// return invokedMethods.remove(transactionId);
// }
//
// public String addInvokedCommand(int transactionId, String commandName) {
// return invokedMethods.put(transactionId, commandName);
// }
//
// public int getRxChunkSize() {
// return rxChunkSize;
// }
//
// public void setRxChunkSize(int chunkSize) {
// this.rxChunkSize = chunkSize;
// }
//
// public int getTxChunkSize() {
// return txChunkSize;
// }
//
// public void setTxChunkSize(int chunkSize) {
// this.txChunkSize = chunkSize;
// }
//
// public int getAcknowledgementWindowSize() {
// return acknowledgementWindowSize;
// }
//
// public void setAcknowledgmentWindowSize(int acknowledgementWindowSize) {
// this.acknowledgementWindowSize = acknowledgementWindowSize;
// }
//
// private static long sessionBeginTimestamp;
//
// /** Sets the session beginning timestamp for all chunks */
// public static void markSessionTimestampTx() {
// sessionBeginTimestamp = System.nanoTime() / 1000000;
// }
//
// /** Utility method for calculating & synchronizing transmitted timestamps */
// public long markAbsoluteTimestampTx() {
// return System.nanoTime() / 1000000 - sessionBeginTimestamp;
// }
// }
| import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.SessionInfo; | package org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets;
/**
* Video data packet
*
* @author francois
*/
public class Video extends ContentData {
public Video(ChunkHeader header) {
super(header);
}
public Video() { | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/SessionInfo.java
// public class SessionInfo {
//
// public static final byte RTMP_STREAM_CHANNEL = 0x05;
// public static final byte RTMP_COMMAND_CHANNEL = 0x03;
// public static final byte RTMP_VIDEO_CHANNEL = 0x06;
// public static final byte RTMP_AUDIO_CHANNEL = 0x07;
// public static final byte RTMP_CONTROL_CHANNEL = 0x02;
//
// /** The window acknowledgement size for this RTMP session, in bytes; default to max to avoid unnecessary "Acknowledgment" messages from being sent */
// private int acknowledgementWindowSize = Integer.MAX_VALUE;
// /** Used internally to store the total number of bytes read (used when sending Acknowledgement messages) */
// private int totalBytesRead = 0;
//
// /** Default chunk size is 128 bytes */
// private int rxChunkSize = 128;
// private int txChunkSize = 128;
// private Map<Integer, ChunkHeader> chunkReceiveChannels = new HashMap<>();
// private Map<Integer, ChunkHeader> chunkSendChannels = new HashMap<>();
// private Map<Integer, String> invokedMethods = new ConcurrentHashMap<>();
//
// public ChunkHeader getPreReceiveChunkHeader(int chunkStreamId) {
// return chunkReceiveChannels.get(chunkStreamId);
// }
//
// public void putPreReceiveChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkReceiveChannels.put(chunkStreamId, chunkHeader);
// }
//
// public ChunkHeader getPreSendChunkHeader(int chunkStreamId) {
// return chunkSendChannels.get(chunkStreamId);
// }
//
// public void putPreSendChunkHeader(int chunkStreamId, ChunkHeader chunkHeader) {
// chunkSendChannels.put(chunkStreamId, chunkHeader);
// }
//
// public String takeInvokedCommand(int transactionId) {
// return invokedMethods.remove(transactionId);
// }
//
// public String addInvokedCommand(int transactionId, String commandName) {
// return invokedMethods.put(transactionId, commandName);
// }
//
// public int getRxChunkSize() {
// return rxChunkSize;
// }
//
// public void setRxChunkSize(int chunkSize) {
// this.rxChunkSize = chunkSize;
// }
//
// public int getTxChunkSize() {
// return txChunkSize;
// }
//
// public void setTxChunkSize(int chunkSize) {
// this.txChunkSize = chunkSize;
// }
//
// public int getAcknowledgementWindowSize() {
// return acknowledgementWindowSize;
// }
//
// public void setAcknowledgmentWindowSize(int acknowledgementWindowSize) {
// this.acknowledgementWindowSize = acknowledgementWindowSize;
// }
//
// private static long sessionBeginTimestamp;
//
// /** Sets the session beginning timestamp for all chunks */
// public static void markSessionTimestampTx() {
// sessionBeginTimestamp = System.nanoTime() / 1000000;
// }
//
// /** Utility method for calculating & synchronizing transmitted timestamps */
// public long markAbsoluteTimestampTx() {
// return System.nanoTime() / 1000000 - sessionBeginTimestamp;
// }
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Video.java
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.io.SessionInfo;
package org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets;
/**
* Video data packet
*
* @author francois
*/
public class Video extends ContentData {
public Video(ChunkHeader header) {
super(header);
}
public Video() { | super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_VIDEO_CHANNEL, MessageType.VIDEO)); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/packer/AnnexbHelper.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
| import android.media.MediaCodec;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.nio.ByteBuffer;
import java.util.ArrayList; | void onVideo(byte[] data, boolean isKeyFrame);
}
public void setAnnexbNaluListener(AnnexbNaluListener listener) {
mListener = listener;
}
public void stop() {
mListener = null;
mPps = null;
mSps = null;
mUploadPpsSps = true;
}
/**
* 将硬编得到的视频数据进行处理生成每一帧视频数据,然后传给flv打包器
* @param bb 硬编后的数据buffer
* @param bi 硬编的BufferInfo
*/
public void analyseVideoData(ByteBuffer bb, MediaCodec.BufferInfo bi) {
bb.position(bi.offset);
bb.limit(bi.offset + bi.size);
ArrayList<byte[]> frames = new ArrayList<>();
boolean isKeyFrame = false;
while(bb.position() < bi.offset + bi.size) {
byte[] frame = annexbDemux(bb, bi);
if(frame == null) { | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/Lg.java
// public class Lg {
//
// private static final String TAG = Lg.class.getSimpleName();
//
// public static void e(@Nullable String value) {
// Log.e(TAG, value);
// }
//
// public static void e(@Nullable Exception value) {
// Log.e(TAG, Error.UN_KNOW);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void e(@NonNull String msg, @Nullable Exception value) {
// Log.e(TAG, msg);
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@Nullable String value) {
// Log.d(TAG, value);
// }
//
// public static void d(@Nullable Exception value) {
// if (value == null) return;
// value.printStackTrace();
// }
//
// public static void d(@NonNull String msg, @Nullable String value) {
// Log.d(TAG, msg + " >> " + value);
// }
//
//
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/packer/AnnexbHelper.java
import android.media.MediaCodec;
import org.yeshen.video.librtmp.unstable.tools.Lg;
import java.nio.ByteBuffer;
import java.util.ArrayList;
void onVideo(byte[] data, boolean isKeyFrame);
}
public void setAnnexbNaluListener(AnnexbNaluListener listener) {
mListener = listener;
}
public void stop() {
mListener = null;
mPps = null;
mSps = null;
mUploadPpsSps = true;
}
/**
* 将硬编得到的视频数据进行处理生成每一帧视频数据,然后传给flv打包器
* @param bb 硬编后的数据buffer
* @param bi 硬编的BufferInfo
*/
public void analyseVideoData(ByteBuffer bb, MediaCodec.BufferInfo bi) {
bb.position(bi.offset);
bb.limit(bi.offset + bi.size);
ArrayList<byte[]> frames = new ArrayList<>();
boolean isKeyFrame = false;
while(bb.position() < bi.offset + bi.size) {
byte[] frame = annexbDemux(bb, bi);
if(frame == null) { | Lg.d( "annexb not match."); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/core/ILivingView.java | // Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/ICameraOpenDelegate.java
// public interface ICameraOpenDelegate {
// int CAMERA_NOT_SUPPORT = 1;
// int NO_CAMERA = 2;
// int CAMERA_DISABLED = 3;
// int CAMERA_OPEN_FAILED = 4;
//
// void onOpenSuccess();
// void onOpenFail(int error);
// }
| import android.support.annotation.NonNull;
import org.yeshen.video.librtmp.core.delegate.ICameraOpenDelegate; | package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/28.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface ILivingView {
void syncConfig();
| // Path: app/src/main/java/org/yeshen/video/librtmp/core/delegate/ICameraOpenDelegate.java
// public interface ICameraOpenDelegate {
// int CAMERA_NOT_SUPPORT = 1;
// int NO_CAMERA = 2;
// int CAMERA_DISABLED = 3;
// int CAMERA_OPEN_FAILED = 4;
//
// void onOpenSuccess();
// void onOpenFail(int error);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/core/ILivingView.java
import android.support.annotation.NonNull;
import org.yeshen.video.librtmp.core.delegate.ICameraOpenDelegate;
package org.yeshen.video.librtmp.core;
/*********************************************************************
* Created by yeshen on 2017/05/28.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
public interface ILivingView {
void syncConfig();
| void setDelegate(@NonNull ICameraOpenDelegate delegate); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
| import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List; | package org.yeshen.video.librtmp.unstable.tools;
/*********************************************************************
* Created by yeshen on 2017/05/25.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
@SuppressWarnings("deprecation")
public class AndroidUntil {
public final static int FOCUS_WIDTH = 80;
public final static int FOCUS_HEIGHT = 80;
public static final String SHARDE_NULL_VERTEX = "attribute vec4 position;\n" +
"attribute vec4 inputTextureCoordinate;\n" +
"\n" +
"uniform mat4 uPosMtx;\n" +
"uniform mat4 uTexMtx;\n" +
"varying vec2 textureCoordinate;\n" +
"void main() {\n" +
" gl_Position = uPosMtx * position;\n" +
" textureCoordinate = (uTexMtx * inputTextureCoordinate).xy;\n" +
"}";
public static final String SHARDE_NULL_FRAGMENT = "#extension GL_OES_EGL_image_external : require\n" +
"precision mediump float;\n" +
"varying vec2 textureCoordinate;\n" +
"uniform samplerExternalOES sTexture;\n" +
"void main() {\n" +
" vec4 tc = texture2D(sTexture, textureCoordinate);\n" +
" gl_FragColor = vec4(tc.r, tc.g, tc.b, 1.0);\n" +
"}";
| // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java
import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
package org.yeshen.video.librtmp.unstable.tools;
/*********************************************************************
* Created by yeshen on 2017/05/25.
* Copyright (c) 2017 yeshen.org. - All Rights Reserved
*********************************************************************/
@SuppressWarnings("deprecation")
public class AndroidUntil {
public final static int FOCUS_WIDTH = 80;
public final static int FOCUS_HEIGHT = 80;
public static final String SHARDE_NULL_VERTEX = "attribute vec4 position;\n" +
"attribute vec4 inputTextureCoordinate;\n" +
"\n" +
"uniform mat4 uPosMtx;\n" +
"uniform mat4 uTexMtx;\n" +
"varying vec2 textureCoordinate;\n" +
"void main() {\n" +
" gl_Position = uPosMtx * position;\n" +
" textureCoordinate = (uTexMtx * inputTextureCoordinate).xy;\n" +
"}";
public static final String SHARDE_NULL_FRAGMENT = "#extension GL_OES_EGL_image_external : require\n" +
"precision mediump float;\n" +
"varying vec2 textureCoordinate;\n" +
"uniform samplerExternalOES sTexture;\n" +
"void main() {\n" +
" vec4 tc = texture2D(sTexture, textureCoordinate);\n" +
" gl_FragColor = vec4(tc.r, tc.g, tc.b, 1.0);\n" +
"}";
| public static List<CameraMessage> getAllCamerasData(boolean isBackFirst) { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
| import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List; | " vec4 tc = texture2D(sTexture, textureCoordinate);\n" +
" gl_FragColor = vec4(tc.r, tc.g, tc.b, 1.0);\n" +
"}";
public static List<CameraMessage> getAllCamerasData(boolean isBackFirst) {
ArrayList<CameraMessage> cameraDatas = new ArrayList<>();
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
CameraMessage cameraData = new CameraMessage(i, CameraMessage.FACING_FRONT);
if(isBackFirst) {
cameraDatas.add(cameraData);
} else {
cameraDatas.add(0, cameraData);
}
} else if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
CameraMessage cameraData = new CameraMessage(i, CameraMessage.FACING_BACK);
if(isBackFirst) {
cameraDatas.add(0, cameraData);
} else {
cameraDatas.add(cameraData);
}
}
}
return cameraDatas;
}
public static void initCameraParams(Camera camera, CameraMessage cameraData, boolean isTouchMode) | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java
import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
" vec4 tc = texture2D(sTexture, textureCoordinate);\n" +
" gl_FragColor = vec4(tc.r, tc.g, tc.b, 1.0);\n" +
"}";
public static List<CameraMessage> getAllCamerasData(boolean isBackFirst) {
ArrayList<CameraMessage> cameraDatas = new ArrayList<>();
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
int numberOfCameras = Camera.getNumberOfCameras();
for (int i = 0; i < numberOfCameras; i++) {
Camera.getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
CameraMessage cameraData = new CameraMessage(i, CameraMessage.FACING_FRONT);
if(isBackFirst) {
cameraDatas.add(cameraData);
} else {
cameraDatas.add(0, cameraData);
}
} else if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
CameraMessage cameraData = new CameraMessage(i, CameraMessage.FACING_BACK);
if(isBackFirst) {
cameraDatas.add(0, cameraData);
} else {
cameraDatas.add(cameraData);
}
}
}
return cameraDatas;
}
public static void initCameraParams(Camera camera, CameraMessage cameraData, boolean isTouchMode) | throws CameraNotSupportException { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
| import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List; | if (Math.abs(size.width - width) < minWidthDiff) {
minWidthDiff = Math.abs(size.width - width);
}
}
//在宽度差距最小的里面,找到高度差距最小的
for(Camera.Size size:sizes){
if(Math.abs(size.width - width) == minWidthDiff) {
if(Math.abs(size.height - height) < minHeightDiff) {
optimalSize = size;
minHeightDiff = Math.abs(size.height - height);
}
}
}
return optimalSize;
}
public static int getDisplayOrientation(int cameraId) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation + 360) % 360;
}
return result;
}
public static void checkCameraService(Context context) | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java
import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
if (Math.abs(size.width - width) < minWidthDiff) {
minWidthDiff = Math.abs(size.width - width);
}
}
//在宽度差距最小的里面,找到高度差距最小的
for(Camera.Size size:sizes){
if(Math.abs(size.width - width) == minWidthDiff) {
if(Math.abs(size.height - height) < minHeightDiff) {
optimalSize = size;
minHeightDiff = Math.abs(size.height - height);
}
}
}
return optimalSize;
}
public static int getDisplayOrientation(int cameraId) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation + 360) % 360;
}
return result;
}
public static void checkCameraService(Context context) | throws CameraDisabledException, NoCameraException { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
| import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List; | if (Math.abs(size.width - width) < minWidthDiff) {
minWidthDiff = Math.abs(size.width - width);
}
}
//在宽度差距最小的里面,找到高度差距最小的
for(Camera.Size size:sizes){
if(Math.abs(size.width - width) == minWidthDiff) {
if(Math.abs(size.height - height) < minHeightDiff) {
optimalSize = size;
minHeightDiff = Math.abs(size.height - height);
}
}
}
return optimalSize;
}
public static int getDisplayOrientation(int cameraId) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation + 360) % 360;
}
return result;
}
public static void checkCameraService(Context context) | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java
import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
if (Math.abs(size.width - width) < minWidthDiff) {
minWidthDiff = Math.abs(size.width - width);
}
}
//在宽度差距最小的里面,找到高度差距最小的
for(Camera.Size size:sizes){
if(Math.abs(size.width - width) == minWidthDiff) {
if(Math.abs(size.height - height) < minHeightDiff) {
optimalSize = size;
minHeightDiff = Math.abs(size.height - height);
}
}
}
return optimalSize;
}
public static int getDisplayOrientation(int cameraId) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation + 360) % 360;
}
return result;
}
public static void checkCameraService(Context context) | throws CameraDisabledException, NoCameraException { |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
| import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List; | return result;
}
public static int getRecordBufferSize() {
int frequency = Options.getInstance().audio.frequency;
int audioEncoding = Options.getInstance().audio.encoding;
int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
if(Options.getInstance().audio.channelCount == 2) {
channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
}
return AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
}
@TargetApi(18)
public static AudioRecord getAudioRecord() {
int frequency = Options.getInstance().audio.frequency;
int audioEncoding = Options.getInstance().audio.encoding;
int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
if(Options.getInstance().audio.channelCount == 2) {
channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
}
int audioSource = MediaRecorder.AudioSource.MIC;
if(Options.getInstance().audio.aec) {
audioSource = MediaRecorder.AudioSource.VOICE_COMMUNICATION;
}
return new AudioRecord(audioSource, frequency,
channelConfiguration, audioEncoding, getRecordBufferSize());
}
public static void enableVocieMode() { | // Path: app/src/main/java/org/yeshen/video/librtmp/App.java
// public class App extends Application {
//
// public static App ins;
//
// public static App getInstance() {
// return ins;
// }
//
// public static Context getContext() {
// return ins.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// ins = this;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/Cameras.java
// public static class CameraMessage {
//
// public static final int FACING_FRONT = 1;
// public static final int FACING_BACK = 2;
//
// public int cameraID; //camera的id
// public int cameraFacing; //区分前后摄像头
// public int cameraWidth; //camera的宽度
// public int cameraHeight; //camera的高度
// public boolean hasLight;
// public int orientation;
// public boolean supportTouchFocus;
// public boolean touchFocusMode;
//
// public CameraMessage(int id, int facing) {
// cameraID = id;
// cameraFacing = facing;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraDisabledException.java
// public class CameraDisabledException extends Exception{
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/CameraNotSupportException.java
// public class CameraNotSupportException extends Exception {
//
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/exception/NoCameraException.java
// public class NoCameraException extends Exception {
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/tools/AndroidUntil.java
import android.annotation.TargetApi;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.opengl.EGL14;
import android.opengl.GLES20;
import android.opengl.Matrix;
import android.os.Build;
import org.yeshen.video.librtmp.App;
import org.yeshen.video.librtmp.unstable.Cameras.CameraMessage;
import org.yeshen.video.librtmp.unstable.exception.CameraDisabledException;
import org.yeshen.video.librtmp.unstable.exception.CameraNotSupportException;
import org.yeshen.video.librtmp.unstable.exception.NoCameraException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
return result;
}
public static int getRecordBufferSize() {
int frequency = Options.getInstance().audio.frequency;
int audioEncoding = Options.getInstance().audio.encoding;
int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
if(Options.getInstance().audio.channelCount == 2) {
channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
}
return AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
}
@TargetApi(18)
public static AudioRecord getAudioRecord() {
int frequency = Options.getInstance().audio.frequency;
int audioEncoding = Options.getInstance().audio.encoding;
int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
if(Options.getInstance().audio.channelCount == 2) {
channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
}
int audioSource = MediaRecorder.AudioSource.MIC;
if(Options.getInstance().audio.aec) {
audioSource = MediaRecorder.AudioSource.VOICE_COMMUNICATION;
}
return new AudioRecord(audioSource, frequency,
channelConfiguration, audioEncoding, getRecordBufferSize());
}
public static void enableVocieMode() { | AudioManager audioManager = (AudioManager) App.getInstance().getSystemService(Context.AUDIO_SERVICE); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/WriteThread.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Command.java
// public class Command extends VariableBodyRtmpPacket {
//
// private static final String TAG = "Command";
//
// private String commandName;
// private int transactionId;
//
// public Command(ChunkHeader header) {
// super(header);
// }
//
// public Command(String commandName, int transactionId) {
// super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_COMMAND_CHANNEL, MessageType.COMMAND_AMF0));
// this.commandName = commandName;
// this.transactionId = transactionId;
// }
//
// public String getCommandName() {
// return commandName;
// }
//
// public void setCommandName(String commandName) {
// this.commandName = commandName;
// }
//
// public int getTransactionId() {
// return transactionId;
// }
//
// public void setTransactionId(int transactionId) {
// this.transactionId = transactionId;
// }
//
// @Override
// public void readBody(InputStream in) throws IOException {
// // The command name and transaction ID are always present (AMF string followed by number)
// commandName = AmfString.readStringFrom(in, false);
// transactionId = (int) AmfNumber.readNumberFrom(in);
// int bytesRead = AmfString.sizeOf(commandName, false) + AmfNumber.SIZE;
// readVariableData(in, bytesRead);
// }
//
// @Override
// protected void writeBody(OutputStream out) throws IOException {
// AmfString.writeStringTo(out, commandName, false);
// AmfNumber.writeNumberTo(out, transactionId);
// // Write body data
// writeVariableData(out);
// }
//
// @Override
// public String toString() {
// return "RTMP Command (command: " + commandName + ", transaction ID: " + transactionId + ")";
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Command;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
import java.io.IOException;
import java.io.OutputStream; | package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's write thread
*
* @author francois, leo
*/
class WriteThread extends Thread {
private OutputStream out;
private SessionInfo sessionInfo;
private OnWriteListener listener; | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Command.java
// public class Command extends VariableBodyRtmpPacket {
//
// private static final String TAG = "Command";
//
// private String commandName;
// private int transactionId;
//
// public Command(ChunkHeader header) {
// super(header);
// }
//
// public Command(String commandName, int transactionId) {
// super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_COMMAND_CHANNEL, MessageType.COMMAND_AMF0));
// this.commandName = commandName;
// this.transactionId = transactionId;
// }
//
// public String getCommandName() {
// return commandName;
// }
//
// public void setCommandName(String commandName) {
// this.commandName = commandName;
// }
//
// public int getTransactionId() {
// return transactionId;
// }
//
// public void setTransactionId(int transactionId) {
// this.transactionId = transactionId;
// }
//
// @Override
// public void readBody(InputStream in) throws IOException {
// // The command name and transaction ID are always present (AMF string followed by number)
// commandName = AmfString.readStringFrom(in, false);
// transactionId = (int) AmfNumber.readNumberFrom(in);
// int bytesRead = AmfString.sizeOf(commandName, false) + AmfNumber.SIZE;
// readVariableData(in, bytesRead);
// }
//
// @Override
// protected void writeBody(OutputStream out) throws IOException {
// AmfString.writeStringTo(out, commandName, false);
// AmfNumber.writeNumberTo(out, transactionId);
// // Write body data
// writeVariableData(out);
// }
//
// @Override
// public String toString() {
// return "RTMP Command (command: " + commandName + ", transaction ID: " + transactionId + ")";
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/WriteThread.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Command;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
import java.io.IOException;
import java.io.OutputStream;
package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's write thread
*
* @author francois, leo
*/
class WriteThread extends Thread {
private OutputStream out;
private SessionInfo sessionInfo;
private OnWriteListener listener; | private ISendQueue mSendQueue; |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/WriteThread.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Command.java
// public class Command extends VariableBodyRtmpPacket {
//
// private static final String TAG = "Command";
//
// private String commandName;
// private int transactionId;
//
// public Command(ChunkHeader header) {
// super(header);
// }
//
// public Command(String commandName, int transactionId) {
// super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_COMMAND_CHANNEL, MessageType.COMMAND_AMF0));
// this.commandName = commandName;
// this.transactionId = transactionId;
// }
//
// public String getCommandName() {
// return commandName;
// }
//
// public void setCommandName(String commandName) {
// this.commandName = commandName;
// }
//
// public int getTransactionId() {
// return transactionId;
// }
//
// public void setTransactionId(int transactionId) {
// this.transactionId = transactionId;
// }
//
// @Override
// public void readBody(InputStream in) throws IOException {
// // The command name and transaction ID are always present (AMF string followed by number)
// commandName = AmfString.readStringFrom(in, false);
// transactionId = (int) AmfNumber.readNumberFrom(in);
// int bytesRead = AmfString.sizeOf(commandName, false) + AmfNumber.SIZE;
// readVariableData(in, bytesRead);
// }
//
// @Override
// protected void writeBody(OutputStream out) throws IOException {
// AmfString.writeStringTo(out, commandName, false);
// AmfNumber.writeNumberTo(out, transactionId);
// // Write body data
// writeVariableData(out);
// }
//
// @Override
// public String toString() {
// return "RTMP Command (command: " + commandName + ", transaction ID: " + transactionId + ")";
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Command;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
import java.io.IOException;
import java.io.OutputStream; | package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's write thread
*
* @author francois, leo
*/
class WriteThread extends Thread {
private OutputStream out;
private SessionInfo sessionInfo;
private OnWriteListener listener;
private ISendQueue mSendQueue;
private volatile boolean startFlag;
WriteThread(OutputStream out, SessionInfo sessionInfo) {
this.out = out;
this.sessionInfo = sessionInfo;
this.startFlag = true;
}
void setWriteListener(OnWriteListener listener) {
this.listener = listener;
}
@Override
public void run() {
while (startFlag) {
try { | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Command.java
// public class Command extends VariableBodyRtmpPacket {
//
// private static final String TAG = "Command";
//
// private String commandName;
// private int transactionId;
//
// public Command(ChunkHeader header) {
// super(header);
// }
//
// public Command(String commandName, int transactionId) {
// super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_COMMAND_CHANNEL, MessageType.COMMAND_AMF0));
// this.commandName = commandName;
// this.transactionId = transactionId;
// }
//
// public String getCommandName() {
// return commandName;
// }
//
// public void setCommandName(String commandName) {
// this.commandName = commandName;
// }
//
// public int getTransactionId() {
// return transactionId;
// }
//
// public void setTransactionId(int transactionId) {
// this.transactionId = transactionId;
// }
//
// @Override
// public void readBody(InputStream in) throws IOException {
// // The command name and transaction ID are always present (AMF string followed by number)
// commandName = AmfString.readStringFrom(in, false);
// transactionId = (int) AmfNumber.readNumberFrom(in);
// int bytesRead = AmfString.sizeOf(commandName, false) + AmfNumber.SIZE;
// readVariableData(in, bytesRead);
// }
//
// @Override
// protected void writeBody(OutputStream out) throws IOException {
// AmfString.writeStringTo(out, commandName, false);
// AmfNumber.writeNumberTo(out, transactionId);
// // Write body data
// writeVariableData(out);
// }
//
// @Override
// public String toString() {
// return "RTMP Command (command: " + commandName + ", transaction ID: " + transactionId + ")";
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/WriteThread.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Command;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
import java.io.IOException;
import java.io.OutputStream;
package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's write thread
*
* @author francois, leo
*/
class WriteThread extends Thread {
private OutputStream out;
private SessionInfo sessionInfo;
private OnWriteListener listener;
private ISendQueue mSendQueue;
private volatile boolean startFlag;
WriteThread(OutputStream out, SessionInfo sessionInfo) {
this.out = out;
this.sessionInfo = sessionInfo;
this.startFlag = true;
}
void setWriteListener(OnWriteListener listener) {
this.listener = listener;
}
@Override
public void run() {
while (startFlag) {
try { | Frame frame = mSendQueue.takeFrame(); |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/WriteThread.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Command.java
// public class Command extends VariableBodyRtmpPacket {
//
// private static final String TAG = "Command";
//
// private String commandName;
// private int transactionId;
//
// public Command(ChunkHeader header) {
// super(header);
// }
//
// public Command(String commandName, int transactionId) {
// super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_COMMAND_CHANNEL, MessageType.COMMAND_AMF0));
// this.commandName = commandName;
// this.transactionId = transactionId;
// }
//
// public String getCommandName() {
// return commandName;
// }
//
// public void setCommandName(String commandName) {
// this.commandName = commandName;
// }
//
// public int getTransactionId() {
// return transactionId;
// }
//
// public void setTransactionId(int transactionId) {
// this.transactionId = transactionId;
// }
//
// @Override
// public void readBody(InputStream in) throws IOException {
// // The command name and transaction ID are always present (AMF string followed by number)
// commandName = AmfString.readStringFrom(in, false);
// transactionId = (int) AmfNumber.readNumberFrom(in);
// int bytesRead = AmfString.sizeOf(commandName, false) + AmfNumber.SIZE;
// readVariableData(in, bytesRead);
// }
//
// @Override
// protected void writeBody(OutputStream out) throws IOException {
// AmfString.writeStringTo(out, commandName, false);
// AmfNumber.writeNumberTo(out, transactionId);
// // Write body data
// writeVariableData(out);
// }
//
// @Override
// public String toString() {
// return "RTMP Command (command: " + commandName + ", transaction ID: " + transactionId + ")";
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Command;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
import java.io.IOException;
import java.io.OutputStream; | package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's write thread
*
* @author francois, leo
*/
class WriteThread extends Thread {
private OutputStream out;
private SessionInfo sessionInfo;
private OnWriteListener listener;
private ISendQueue mSendQueue;
private volatile boolean startFlag;
WriteThread(OutputStream out, SessionInfo sessionInfo) {
this.out = out;
this.sessionInfo = sessionInfo;
this.startFlag = true;
}
void setWriteListener(OnWriteListener listener) {
this.listener = listener;
}
@Override
public void run() {
while (startFlag) {
try {
Frame frame = mSendQueue.takeFrame();
if(frame != null) { | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Command.java
// public class Command extends VariableBodyRtmpPacket {
//
// private static final String TAG = "Command";
//
// private String commandName;
// private int transactionId;
//
// public Command(ChunkHeader header) {
// super(header);
// }
//
// public Command(String commandName, int transactionId) {
// super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_COMMAND_CHANNEL, MessageType.COMMAND_AMF0));
// this.commandName = commandName;
// this.transactionId = transactionId;
// }
//
// public String getCommandName() {
// return commandName;
// }
//
// public void setCommandName(String commandName) {
// this.commandName = commandName;
// }
//
// public int getTransactionId() {
// return transactionId;
// }
//
// public void setTransactionId(int transactionId) {
// this.transactionId = transactionId;
// }
//
// @Override
// public void readBody(InputStream in) throws IOException {
// // The command name and transaction ID are always present (AMF string followed by number)
// commandName = AmfString.readStringFrom(in, false);
// transactionId = (int) AmfNumber.readNumberFrom(in);
// int bytesRead = AmfString.sizeOf(commandName, false) + AmfNumber.SIZE;
// readVariableData(in, bytesRead);
// }
//
// @Override
// protected void writeBody(OutputStream out) throws IOException {
// AmfString.writeStringTo(out, commandName, false);
// AmfNumber.writeNumberTo(out, transactionId);
// // Write body data
// writeVariableData(out);
// }
//
// @Override
// public String toString() {
// return "RTMP Command (command: " + commandName + ", transaction ID: " + transactionId + ")";
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/WriteThread.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Command;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
import java.io.IOException;
import java.io.OutputStream;
package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's write thread
*
* @author francois, leo
*/
class WriteThread extends Thread {
private OutputStream out;
private SessionInfo sessionInfo;
private OnWriteListener listener;
private ISendQueue mSendQueue;
private volatile boolean startFlag;
WriteThread(OutputStream out, SessionInfo sessionInfo) {
this.out = out;
this.sessionInfo = sessionInfo;
this.startFlag = true;
}
void setWriteListener(OnWriteListener listener) {
this.listener = listener;
}
@Override
public void run() {
while (startFlag) {
try {
Frame frame = mSendQueue.takeFrame();
if(frame != null) { | Chunk chunk = frame.data; |
wuyisheng/libRtmp | app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/WriteThread.java | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Command.java
// public class Command extends VariableBodyRtmpPacket {
//
// private static final String TAG = "Command";
//
// private String commandName;
// private int transactionId;
//
// public Command(ChunkHeader header) {
// super(header);
// }
//
// public Command(String commandName, int transactionId) {
// super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_COMMAND_CHANNEL, MessageType.COMMAND_AMF0));
// this.commandName = commandName;
// this.transactionId = transactionId;
// }
//
// public String getCommandName() {
// return commandName;
// }
//
// public void setCommandName(String commandName) {
// this.commandName = commandName;
// }
//
// public int getTransactionId() {
// return transactionId;
// }
//
// public void setTransactionId(int transactionId) {
// this.transactionId = transactionId;
// }
//
// @Override
// public void readBody(InputStream in) throws IOException {
// // The command name and transaction ID are always present (AMF string followed by number)
// commandName = AmfString.readStringFrom(in, false);
// transactionId = (int) AmfNumber.readNumberFrom(in);
// int bytesRead = AmfString.sizeOf(commandName, false) + AmfNumber.SIZE;
// readVariableData(in, bytesRead);
// }
//
// @Override
// protected void writeBody(OutputStream out) throws IOException {
// AmfString.writeStringTo(out, commandName, false);
// AmfNumber.writeNumberTo(out, transactionId);
// // Write body data
// writeVariableData(out);
// }
//
// @Override
// public String toString() {
// return "RTMP Command (command: " + commandName + ", transaction ID: " + transactionId + ")";
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
| import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Command;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
import java.io.IOException;
import java.io.OutputStream; | package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's write thread
*
* @author francois, leo
*/
class WriteThread extends Thread {
private OutputStream out;
private SessionInfo sessionInfo;
private OnWriteListener listener;
private ISendQueue mSendQueue;
private volatile boolean startFlag;
WriteThread(OutputStream out, SessionInfo sessionInfo) {
this.out = out;
this.sessionInfo = sessionInfo;
this.startFlag = true;
}
void setWriteListener(OnWriteListener listener) {
this.listener = listener;
}
@Override
public void run() {
while (startFlag) {
try {
Frame frame = mSendQueue.takeFrame();
if(frame != null) {
Chunk chunk = frame.data;
chunk.writeTo(out, sessionInfo); | // Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/Frame.java
// public class Frame {
// public static final int FRAME_TYPE_AUDIO = 1;
// public static final int FRAME_TYPE_KEY_FRAME = 2;
// public static final int FRAME_TYPE_INTER_FRAME = 3;
// public static final int FRAME_TYPE_CONFIGURATION = 4;
//
// public Chunk data;
// public int packetType;
// public int frameType;
//
// public Frame(Chunk data, int packetType, int frameType) {
// this.data = data;
// this.packetType = packetType;
// this.frameType = frameType;
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Chunk.java
// public abstract class Chunk {
//
// protected ChunkHeader header;
//
// public Chunk(ChunkHeader header) {
// this.header = header;
// }
//
// public ChunkHeader getChunkHeader() {
// return header;
// }
//
// public abstract void readBody(InputStream in) throws IOException;
//
// protected abstract void writeBody(OutputStream out) throws IOException;
//
// public void writeTo(OutputStream out, final SessionInfo sessionInfo) throws IOException {
// int chunkSize = sessionInfo.getTxChunkSize();
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// writeBody(baos);
// byte[] body = baos.toByteArray();
// header.setPacketLength(body.length);
// // Write header for first chunk
// header.writeTo(out, ChunkType.TYPE_0_FULL, sessionInfo);
// int remainingBytes = body.length;
// int pos = 0;
// while (remainingBytes > chunkSize) {
// // Write packet for chunk
// out.write(body, pos, chunkSize);
// remainingBytes -= chunkSize;
// pos += chunkSize;
// // Write header for remain chunk
// header.writeTo(out, ChunkType.TYPE_3_NO_BYTE, sessionInfo);
// }
// out.write(body, pos, remainingBytes);
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/packets/Command.java
// public class Command extends VariableBodyRtmpPacket {
//
// private static final String TAG = "Command";
//
// private String commandName;
// private int transactionId;
//
// public Command(ChunkHeader header) {
// super(header);
// }
//
// public Command(String commandName, int transactionId) {
// super(new ChunkHeader(ChunkType.TYPE_0_FULL, SessionInfo.RTMP_COMMAND_CHANNEL, MessageType.COMMAND_AMF0));
// this.commandName = commandName;
// this.transactionId = transactionId;
// }
//
// public String getCommandName() {
// return commandName;
// }
//
// public void setCommandName(String commandName) {
// this.commandName = commandName;
// }
//
// public int getTransactionId() {
// return transactionId;
// }
//
// public void setTransactionId(int transactionId) {
// this.transactionId = transactionId;
// }
//
// @Override
// public void readBody(InputStream in) throws IOException {
// // The command name and transaction ID are always present (AMF string followed by number)
// commandName = AmfString.readStringFrom(in, false);
// transactionId = (int) AmfNumber.readNumberFrom(in);
// int bytesRead = AmfString.sizeOf(commandName, false) + AmfNumber.SIZE;
// readVariableData(in, bytesRead);
// }
//
// @Override
// protected void writeBody(OutputStream out) throws IOException {
// AmfString.writeStringTo(out, commandName, false);
// AmfNumber.writeNumberTo(out, transactionId);
// // Write body data
// writeVariableData(out);
// }
//
// @Override
// public String toString() {
// return "RTMP Command (command: " + commandName + ", transaction ID: " + transactionId + ")";
// }
// }
//
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/sendqueue/ISendQueue.java
// public interface ISendQueue {
// void start();
// void stop();
// void setBufferSize(int size);
// void putFrame(Frame frame);
// Frame takeFrame();
// void setSendQueueListener(SendQueueListener listener);
// }
// Path: app/src/main/java/org/yeshen/video/librtmp/unstable/net/sender/rtmp/io/WriteThread.java
import org.yeshen.video.librtmp.unstable.net.Frame;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Chunk;
import org.yeshen.video.librtmp.unstable.net.sender.rtmp.packets.Command;
import org.yeshen.video.librtmp.unstable.net.sender.sendqueue.ISendQueue;
import java.io.IOException;
import java.io.OutputStream;
package org.yeshen.video.librtmp.unstable.net.sender.rtmp.io;
/**
* RTMPConnection's write thread
*
* @author francois, leo
*/
class WriteThread extends Thread {
private OutputStream out;
private SessionInfo sessionInfo;
private OnWriteListener listener;
private ISendQueue mSendQueue;
private volatile boolean startFlag;
WriteThread(OutputStream out, SessionInfo sessionInfo) {
this.out = out;
this.sessionInfo = sessionInfo;
this.startFlag = true;
}
void setWriteListener(OnWriteListener listener) {
this.listener = listener;
}
@Override
public void run() {
while (startFlag) {
try {
Frame frame = mSendQueue.takeFrame();
if(frame != null) {
Chunk chunk = frame.data;
chunk.writeTo(out, sessionInfo); | if (chunk instanceof Command) { |
GreenfieldTech/irked | src/test/java/tech/greenfield/vertx/irked/status/StatusTest.java | // Path: src/main/java/tech/greenfield/vertx/irked/HttpError.java
// public class HttpError extends Exception {
//
// public class UncheckedHttpError extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private UncheckedHttpError() {
// super(HttpError.this);
// }
// }
//
// private static final long serialVersionUID = -7084405660609573926L;
//
// private int statusCode;
// private String statusText;
// private HeadersMultiMap headers = HeadersMultiMap.httpHeaders();
//
// public HttpError(int statusCode, String statusText) {
// super(statusText);
// this.statusCode = statusCode;
// this.statusText = statusText;
// }
//
// public HttpError(int statusCode, String statusText, String message) {
// super(message);
// this.statusCode = statusCode;
// this.statusText = statusText;
// }
//
// public HttpError(int statusCode, String statusText, Throwable throwable) {
// super(statusText, throwable);
// this.statusCode = statusCode;
// this.statusText = statusText;
// }
//
// public HttpError(int statusCode, String statusText, String message, Throwable throwable) {
// super(message, throwable);
// this.statusCode = statusCode;
// this.statusText = statusText;
// }
//
// public int getStatusCode() {
// return statusCode;
// }
//
// public String getStatusText() {
// return statusText;
// }
//
// public HttpError addHeader(String header, String value) {
// this.headers.add(header, value);
// return this;
// }
//
// public MultiMap getHeaders() {
// return headers;
// }
//
// /**
// * Alias to {@link #unchecked()}
// * @return unchecked {@link RuntimeException} wrapping this status instance
// */
// public RuntimeException uncheckedWrap() {
// return new UncheckedHttpError();
// }
//
// /**
// * Helper method to make it easier to throw HTTP statuses out of lambdas.
// * Outside the lambda you should catch a {@link RuntimeException} and use
// * {@link HttpError#unwrap(Throwable)} to get the original exception
// * @return unchecked {@link RuntimeException} wrapping this status instance
// */
// public RuntimeException unchecked() {
// return new UncheckedHttpError();
// }
//
// /**
// * Unwrap {@link RuntimeException} wrappers around a logical exception
// * (hopefully an instance of HttpError)
// * @param t Throweable to unwrap
// * @return the first non RuntimeException found
// */
// public static Throwable unwrap(Throwable t) {
// Throwable orig = t;
// while (!(t instanceof HttpError)) {
// t = t.getCause();
// if (t == null)
// return orig; // can't find HTTP Error
// }
// return t; // must be an HTTP Error
// }
//
// /**
// * Helper method for OnFail handlers to locate a wrapped HttpError or
// * create an InternalServerError from an unexpected exception (whether it
// * is wrapped or not)
// * @param t Throwable to be analyzed
// * @return the wrapped HttpError instance or a new {@link InternalServerError} wrapping
// * the real exception
// */
// public static HttpError toHttpError(Throwable t) {
// t = unwrap(t);
// if (t instanceof HttpError)
// return (HttpError)t;
// return new InternalServerError(t);
// }
//
// /**
// * Helper method for OnFail handlers to create an appropriate HTTP error class
// * for a failed {@link RoutingContext}, by reading the failed status code or
// * failure exception.
// *
// * If {@link RoutingContext#failure()} returns a (possibly wrapped)
// * {@link HttpError} then that what will be returned, otherwise either an
// * {@link InternalServerError} will be returned (for an exception failure) or
// * an appropriate default HTTP status instance according to the failed status code.
// *
// * Note that if the {@link RoutingContext#failed()} {@code == false}, then an {@link OK}
// * HTTP status class instance will be returned.
// * @param ctx failed {@code RoutingContext} to investigate
// * @return an {@code HttpError} instance representing the status of the {@code RoutingContext}
// */
// public static HttpError toHttpError(RoutingContext ctx) {
// if (!ctx.failed())
// return new OK();
// if (Objects.nonNull(ctx.failure()))
// return toHttpError(ctx.failure());
// if (!HttpStatuses.HTTP_STATUS_CODES.containsKey(ctx.statusCode()))
// return new InternalServerError("Unknown HTTP status code " + ctx.statusCode());
// try {
// return HttpStatuses.create(ctx.statusCode());
// } catch (InstantiationException e) {
// // should never happen, assuming we know all valid HTTP status codes
// return new InternalServerError("Failed to translate failed context to HTTP error");
// }
// }
//
// @Override
// public String toString() {
// return "HTTP " + statusCode + " " + statusText;
// }
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import org.junit.jupiter.api.Test;
import tech.greenfield.vertx.irked.HttpError; | package tech.greenfield.vertx.irked.status;
public class StatusTest {
@Test
public void testNotFound() { | // Path: src/main/java/tech/greenfield/vertx/irked/HttpError.java
// public class HttpError extends Exception {
//
// public class UncheckedHttpError extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private UncheckedHttpError() {
// super(HttpError.this);
// }
// }
//
// private static final long serialVersionUID = -7084405660609573926L;
//
// private int statusCode;
// private String statusText;
// private HeadersMultiMap headers = HeadersMultiMap.httpHeaders();
//
// public HttpError(int statusCode, String statusText) {
// super(statusText);
// this.statusCode = statusCode;
// this.statusText = statusText;
// }
//
// public HttpError(int statusCode, String statusText, String message) {
// super(message);
// this.statusCode = statusCode;
// this.statusText = statusText;
// }
//
// public HttpError(int statusCode, String statusText, Throwable throwable) {
// super(statusText, throwable);
// this.statusCode = statusCode;
// this.statusText = statusText;
// }
//
// public HttpError(int statusCode, String statusText, String message, Throwable throwable) {
// super(message, throwable);
// this.statusCode = statusCode;
// this.statusText = statusText;
// }
//
// public int getStatusCode() {
// return statusCode;
// }
//
// public String getStatusText() {
// return statusText;
// }
//
// public HttpError addHeader(String header, String value) {
// this.headers.add(header, value);
// return this;
// }
//
// public MultiMap getHeaders() {
// return headers;
// }
//
// /**
// * Alias to {@link #unchecked()}
// * @return unchecked {@link RuntimeException} wrapping this status instance
// */
// public RuntimeException uncheckedWrap() {
// return new UncheckedHttpError();
// }
//
// /**
// * Helper method to make it easier to throw HTTP statuses out of lambdas.
// * Outside the lambda you should catch a {@link RuntimeException} and use
// * {@link HttpError#unwrap(Throwable)} to get the original exception
// * @return unchecked {@link RuntimeException} wrapping this status instance
// */
// public RuntimeException unchecked() {
// return new UncheckedHttpError();
// }
//
// /**
// * Unwrap {@link RuntimeException} wrappers around a logical exception
// * (hopefully an instance of HttpError)
// * @param t Throweable to unwrap
// * @return the first non RuntimeException found
// */
// public static Throwable unwrap(Throwable t) {
// Throwable orig = t;
// while (!(t instanceof HttpError)) {
// t = t.getCause();
// if (t == null)
// return orig; // can't find HTTP Error
// }
// return t; // must be an HTTP Error
// }
//
// /**
// * Helper method for OnFail handlers to locate a wrapped HttpError or
// * create an InternalServerError from an unexpected exception (whether it
// * is wrapped or not)
// * @param t Throwable to be analyzed
// * @return the wrapped HttpError instance or a new {@link InternalServerError} wrapping
// * the real exception
// */
// public static HttpError toHttpError(Throwable t) {
// t = unwrap(t);
// if (t instanceof HttpError)
// return (HttpError)t;
// return new InternalServerError(t);
// }
//
// /**
// * Helper method for OnFail handlers to create an appropriate HTTP error class
// * for a failed {@link RoutingContext}, by reading the failed status code or
// * failure exception.
// *
// * If {@link RoutingContext#failure()} returns a (possibly wrapped)
// * {@link HttpError} then that what will be returned, otherwise either an
// * {@link InternalServerError} will be returned (for an exception failure) or
// * an appropriate default HTTP status instance according to the failed status code.
// *
// * Note that if the {@link RoutingContext#failed()} {@code == false}, then an {@link OK}
// * HTTP status class instance will be returned.
// * @param ctx failed {@code RoutingContext} to investigate
// * @return an {@code HttpError} instance representing the status of the {@code RoutingContext}
// */
// public static HttpError toHttpError(RoutingContext ctx) {
// if (!ctx.failed())
// return new OK();
// if (Objects.nonNull(ctx.failure()))
// return toHttpError(ctx.failure());
// if (!HttpStatuses.HTTP_STATUS_CODES.containsKey(ctx.statusCode()))
// return new InternalServerError("Unknown HTTP status code " + ctx.statusCode());
// try {
// return HttpStatuses.create(ctx.statusCode());
// } catch (InstantiationException e) {
// // should never happen, assuming we know all valid HTTP status codes
// return new InternalServerError("Failed to translate failed context to HTTP error");
// }
// }
//
// @Override
// public String toString() {
// return "HTTP " + statusCode + " " + statusText;
// }
// }
// Path: src/test/java/tech/greenfield/vertx/irked/status/StatusTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import org.junit.jupiter.api.Test;
import tech.greenfield.vertx.irked.HttpError;
package tech.greenfield.vertx.irked.status;
public class StatusTest {
@Test
public void testNotFound() { | assertThat(new NotFound(), instanceOf(HttpError.class)); |
GreenfieldTech/irked | src/main/java/tech/greenfield/vertx/irked/Router.java | // Path: src/main/java/tech/greenfield/vertx/irked/exceptions/InvalidRouteConfiguration.java
// public class InvalidRouteConfiguration extends Exception {
//
// private static final long serialVersionUID = 4458613845508649189L;
//
// public InvalidRouteConfiguration(String message) {
// super(message);
// }
//
// }
| import java.io.PrintStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.ext.web.AllowForwardHeaders;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;
import tech.greenfield.vertx.irked.annotations.*;
import tech.greenfield.vertx.irked.exceptions.InvalidRouteConfiguration; | package tech.greenfield.vertx.irked;
public class Router implements io.vertx.ext.web.Router {
static Logger log = LoggerFactory.getLogger(Router.class);
private Vertx vertx;
private io.vertx.ext.web.Router router;
private Set<Route> routePaths = new HashSet<>(); // used for debugging only
public Router(Vertx vertx) {
this.vertx = vertx;
this.router = io.vertx.ext.web.Router.router(this.vertx);
}
| // Path: src/main/java/tech/greenfield/vertx/irked/exceptions/InvalidRouteConfiguration.java
// public class InvalidRouteConfiguration extends Exception {
//
// private static final long serialVersionUID = 4458613845508649189L;
//
// public InvalidRouteConfiguration(String message) {
// super(message);
// }
//
// }
// Path: src/main/java/tech/greenfield/vertx/irked/Router.java
import java.io.PrintStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.ext.web.AllowForwardHeaders;
import io.vertx.ext.web.Route;
import io.vertx.ext.web.RoutingContext;
import tech.greenfield.vertx.irked.annotations.*;
import tech.greenfield.vertx.irked.exceptions.InvalidRouteConfiguration;
package tech.greenfield.vertx.irked;
public class Router implements io.vertx.ext.web.Router {
static Logger log = LoggerFactory.getLogger(Router.class);
private Vertx vertx;
private io.vertx.ext.web.Router router;
private Set<Route> routePaths = new HashSet<>(); // used for debugging only
public Router(Vertx vertx) {
this.vertx = vertx;
this.router = io.vertx.ext.web.Router.router(this.vertx);
}
| public Router with(Controller api) throws InvalidRouteConfiguration { |
GreenfieldTech/irked | src/main/java/tech/greenfield/vertx/irked/helpers/DigestAuthenticate.java | // Path: src/main/java/tech/greenfield/vertx/irked/auth/ParameterEncodedAuthorizationToken.java
// public class ParameterEncodedAuthorizationToken extends AuthorizationToken {
//
// Map<String,String> parameters = new HashMap<>();
//
// /* (non-Javadoc)
// * @see tech.greenfield.vertx.irked.auth.AuthorizationToken#update(java.lang.String, java.lang.String)
// */
// @Override
// protected AuthorizationToken update(String type, String token) {
// super.update(type, token);
// for (Map.Entry<String,String> e : parseParameters(token)) {
// parameters.put(e.getKey(), e.getValue());
// }
// return this;
// }
//
// public static Iterable<Map.Entry<String,String>> parseParameters(String text) {
// StringTokenizer t = new StringTokenizer(text, " \t\r\n,");
// return new Iterable<Map.Entry<String,String>>() {
// @Override
// public Iterator<Entry<String, String>> iterator() {
// return new Iterator<Map.Entry<String,String>>() {
//
// @Override
// public Entry<String, String> next() {
// String next = t.nextToken();
// String[] parts = next.split("=",2);
// if (parts.length != 2)
// return new AbstractMap.SimpleImmutableEntry<String,String>(parts[0], null);
// while (parts[1].startsWith("\"") && !parts[1].endsWith("\"") && t.hasMoreTokens())
// parts[1] += " " + t.nextToken();
// if (parts[1].startsWith("\""))
// parts[1] = parts[1].substring(1, parts[1].length()-1);
// return new AbstractMap.SimpleImmutableEntry<String,String>(parts[0], parts[1]);
// }
//
// @Override
// public boolean hasNext() {
// return t.hasMoreTokens();
// }
// };
// }
// };
// }
//
// public String getParameter(String param) {
// return parameters.get(param);
// }
//
// public static String toHex(byte[] data) {
// StringBuilder sb = new StringBuilder(data.length * 2);
// for(byte b: data)
// sb.append(String.format("%02x", b));
// return sb.toString();
// }
//
// }
| import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import io.vertx.core.buffer.Buffer;
import tech.greenfield.vertx.irked.auth.ParameterEncodedAuthorizationToken;
import tech.greenfield.vertx.irked.status.Unauthorized; |
public DigestAuthenticate(String realm, String opaque) {
this(realm, generateNonce("", TimeUnit.MINUTES.toMillis(5)), opaque, "MD5", true);
}
public DigestAuthenticate(String realm, boolean allowQopIntegrity) {
this(realm, generateNonce("", TimeUnit.MINUTES.toSeconds(5)), "", "MD5", allowQopIntegrity);
}
public DigestAuthenticate(String realm, String opaque, boolean allowQopIntegrity) {
this(realm, generateNonce("", TimeUnit.MINUTES.toSeconds(5)), opaque, "MD5", allowQopIntegrity);
}
public DigestAuthenticate(String realm, String nonce, String opaque, String algorithm) {
this(realm, nonce, opaque, algorithm, true);
}
public DigestAuthenticate(String realm, String nonce, String opaque, String algorithm, boolean allowQopIntegrity) {
addHeader("WWW-Authenticate", "Digest " + Stream.of(
"realm=\"" + realm + "\"",
"qop=\"auth" + (allowQopIntegrity ? ", auth-int" : "") + "\"",
"algorithm=\"" + algorithm + "\"",
"nonce=\"" + nonce + "\"",
"opaque=\"" + opaque + "\""
).collect(Collectors.joining(", ")));
}
public static String generateNonce(String tag, long expiry) {
byte[] randdata = new byte[8];
rand.nextBytes(randdata); | // Path: src/main/java/tech/greenfield/vertx/irked/auth/ParameterEncodedAuthorizationToken.java
// public class ParameterEncodedAuthorizationToken extends AuthorizationToken {
//
// Map<String,String> parameters = new HashMap<>();
//
// /* (non-Javadoc)
// * @see tech.greenfield.vertx.irked.auth.AuthorizationToken#update(java.lang.String, java.lang.String)
// */
// @Override
// protected AuthorizationToken update(String type, String token) {
// super.update(type, token);
// for (Map.Entry<String,String> e : parseParameters(token)) {
// parameters.put(e.getKey(), e.getValue());
// }
// return this;
// }
//
// public static Iterable<Map.Entry<String,String>> parseParameters(String text) {
// StringTokenizer t = new StringTokenizer(text, " \t\r\n,");
// return new Iterable<Map.Entry<String,String>>() {
// @Override
// public Iterator<Entry<String, String>> iterator() {
// return new Iterator<Map.Entry<String,String>>() {
//
// @Override
// public Entry<String, String> next() {
// String next = t.nextToken();
// String[] parts = next.split("=",2);
// if (parts.length != 2)
// return new AbstractMap.SimpleImmutableEntry<String,String>(parts[0], null);
// while (parts[1].startsWith("\"") && !parts[1].endsWith("\"") && t.hasMoreTokens())
// parts[1] += " " + t.nextToken();
// if (parts[1].startsWith("\""))
// parts[1] = parts[1].substring(1, parts[1].length()-1);
// return new AbstractMap.SimpleImmutableEntry<String,String>(parts[0], parts[1]);
// }
//
// @Override
// public boolean hasNext() {
// return t.hasMoreTokens();
// }
// };
// }
// };
// }
//
// public String getParameter(String param) {
// return parameters.get(param);
// }
//
// public static String toHex(byte[] data) {
// StringBuilder sb = new StringBuilder(data.length * 2);
// for(byte b: data)
// sb.append(String.format("%02x", b));
// return sb.toString();
// }
//
// }
// Path: src/main/java/tech/greenfield/vertx/irked/helpers/DigestAuthenticate.java
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import io.vertx.core.buffer.Buffer;
import tech.greenfield.vertx.irked.auth.ParameterEncodedAuthorizationToken;
import tech.greenfield.vertx.irked.status.Unauthorized;
public DigestAuthenticate(String realm, String opaque) {
this(realm, generateNonce("", TimeUnit.MINUTES.toMillis(5)), opaque, "MD5", true);
}
public DigestAuthenticate(String realm, boolean allowQopIntegrity) {
this(realm, generateNonce("", TimeUnit.MINUTES.toSeconds(5)), "", "MD5", allowQopIntegrity);
}
public DigestAuthenticate(String realm, String opaque, boolean allowQopIntegrity) {
this(realm, generateNonce("", TimeUnit.MINUTES.toSeconds(5)), opaque, "MD5", allowQopIntegrity);
}
public DigestAuthenticate(String realm, String nonce, String opaque, String algorithm) {
this(realm, nonce, opaque, algorithm, true);
}
public DigestAuthenticate(String realm, String nonce, String opaque, String algorithm, boolean allowQopIntegrity) {
addHeader("WWW-Authenticate", "Digest " + Stream.of(
"realm=\"" + realm + "\"",
"qop=\"auth" + (allowQopIntegrity ? ", auth-int" : "") + "\"",
"algorithm=\"" + algorithm + "\"",
"nonce=\"" + nonce + "\"",
"opaque=\"" + opaque + "\""
).collect(Collectors.joining(", ")));
}
public static String generateNonce(String tag, long expiry) {
byte[] randdata = new byte[8];
rand.nextBytes(randdata); | String nonce = String.valueOf(System.currentTimeMillis() / 1000 + expiry) + ":" + tag + ":" + ParameterEncodedAuthorizationToken.toHex(randdata); |
GreenfieldTech/irked | src/main/java/tech/greenfield/vertx/irked/Request.java | // Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// protected interface WebHandler extends Handler<Request> {}
//
// Path: src/main/java/tech/greenfield/vertx/irked/auth/AuthorizationToken.java
// public class AuthorizationToken {
//
// private String token;
// private String type;
//
// /**
// * Constructor for token implementations is internal - use {@link #parse(String)} to create tokens
// */
// protected AuthorizationToken() {
// }
//
// /**
// * Parse an Authorization header text to create a specific token implementation
// *
// * This method uses the convention of the first word in the Authorization value being the
// * IANA HTTP Authentication Scheme Name, to dynamically load an appropriate implementation
// * from the tech.greenfield.vertx.irked.auth.AuthorizationToken service loader. If the
// * header value is incompatible (i.e. contains only one "word") then a token with the type
// * "simple" will be returned. Otherwise if no supporting implementation is found, an instance
// * of the {@link AuthorizationToken} class will be created.
// * @param authorizationHeader value of the HTTP Authorization header
// * @return a
// */
// public static AuthorizationToken parse(String authorizationHeader) {
// if (Objects.isNull(authorizationHeader))
// return new NullAuthorizationToken();
// String[] parts = authorizationHeader.split("\\s+",2);
// if (parts.length == 1)
// return new SimpleAuthrizationToken(parts[0]);
// for (AuthorizationToken a : ServiceLoader.load(AuthorizationToken.class)) {
// if (a.supports(parts[0]))
// return a.update(parts[0], parts[1]);
// }
// return new AuthorizationToken().update(parts[0], parts[1]);
// }
//
// /**
// * Update a service-loader loaded implementation with the actual details
// * @param type IANA HTTP Authentication Scheme Name
// * @param token token text
// * @return itself for fluent calling
// */
// protected AuthorizationToken update(String type, String token) {
// this.type = type;
// this.token = token;
// return this;
// }
//
// /**
// * Check whether an AuthorizationToken implementation supports the speciefied IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether this implementation supports the specified name
// */
// protected boolean supports(String type) {
// return false;
// }
//
// /**
// * Check whether the token implementation implements the specified IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether the implementation is valid for that scheme name
// */
// public boolean is(String type) {
// return Objects.isNull(type) ? Objects.isNull(this.type) : type.equalsIgnoreCase(this.type);
// }
//
// /**
// * Retrieve the authorization token text
// * @return authorization token text
// */
// public String getToken() {
// return token;
// }
//
// /**
// * Retrieve the IANA HTTP Authentication Scheme Name this token is an implementation of
// * @return IANA HTTP Authentication Scheme Name
// */
// public String getType() {
// return type;
// }
//
// public String toString() {
// return type + " " + token;
// }
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/exceptions/MissingBodyException.java
// public class MissingBodyException extends BadRequest {
//
// private static final long serialVersionUID = 4458613845508649207L;
//
// public MissingBodyException() {
// super("Required request body is missing");
// }
//
// }
| import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.*;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.impl.RoutingContextDecorator;
import io.vertx.ext.web.impl.RoutingContextInternal;
import tech.greenfield.vertx.irked.Controller.WebHandler;
import tech.greenfield.vertx.irked.auth.AuthorizationToken;
import tech.greenfield.vertx.irked.exceptions.MissingBodyException;
import tech.greenfield.vertx.irked.status.BadRequest;
import tech.greenfield.vertx.irked.status.OK; | fail((HttpError)failure);
else
fail(failure);
return null;
}
/**
* Helper failure handler for CompletableFuture users.
* Use in the middle an async chain to succinctly propagate exceptions, or
* success values as thus: <code>.whenComplete(req::handlePossibleFailure)</code>.
* This method will call {@link Request#fail(Throwable)} if a failure occurred,
* after unwrapping {@link RuntimeException}s as needed. It will also pass on
* the success value (or null if there was a failure) for the next async
* element. Subsequent code can check whether a failure was propagated
* by calling {@link #failed()}
* @param <V> the type of previous completion value that will be returned as the completion value for completion stages running this method
* @param successValue successful completion value to return in case no failure occurred
* @param throwable A {@link Throwable} error to fail on
* @return null
*/
public <V> V handlePossibleFailure(V successValue, Throwable throwable) {
if (Objects.nonNull(throwable))
fail(HttpError.unwrap(throwable));
return successValue;
}
/**
* Helper to easily configure standard failure handlers
* @return a WebHandler that sends Irked status exceptions as HTTP responses
*/ | // Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// protected interface WebHandler extends Handler<Request> {}
//
// Path: src/main/java/tech/greenfield/vertx/irked/auth/AuthorizationToken.java
// public class AuthorizationToken {
//
// private String token;
// private String type;
//
// /**
// * Constructor for token implementations is internal - use {@link #parse(String)} to create tokens
// */
// protected AuthorizationToken() {
// }
//
// /**
// * Parse an Authorization header text to create a specific token implementation
// *
// * This method uses the convention of the first word in the Authorization value being the
// * IANA HTTP Authentication Scheme Name, to dynamically load an appropriate implementation
// * from the tech.greenfield.vertx.irked.auth.AuthorizationToken service loader. If the
// * header value is incompatible (i.e. contains only one "word") then a token with the type
// * "simple" will be returned. Otherwise if no supporting implementation is found, an instance
// * of the {@link AuthorizationToken} class will be created.
// * @param authorizationHeader value of the HTTP Authorization header
// * @return a
// */
// public static AuthorizationToken parse(String authorizationHeader) {
// if (Objects.isNull(authorizationHeader))
// return new NullAuthorizationToken();
// String[] parts = authorizationHeader.split("\\s+",2);
// if (parts.length == 1)
// return new SimpleAuthrizationToken(parts[0]);
// for (AuthorizationToken a : ServiceLoader.load(AuthorizationToken.class)) {
// if (a.supports(parts[0]))
// return a.update(parts[0], parts[1]);
// }
// return new AuthorizationToken().update(parts[0], parts[1]);
// }
//
// /**
// * Update a service-loader loaded implementation with the actual details
// * @param type IANA HTTP Authentication Scheme Name
// * @param token token text
// * @return itself for fluent calling
// */
// protected AuthorizationToken update(String type, String token) {
// this.type = type;
// this.token = token;
// return this;
// }
//
// /**
// * Check whether an AuthorizationToken implementation supports the speciefied IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether this implementation supports the specified name
// */
// protected boolean supports(String type) {
// return false;
// }
//
// /**
// * Check whether the token implementation implements the specified IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether the implementation is valid for that scheme name
// */
// public boolean is(String type) {
// return Objects.isNull(type) ? Objects.isNull(this.type) : type.equalsIgnoreCase(this.type);
// }
//
// /**
// * Retrieve the authorization token text
// * @return authorization token text
// */
// public String getToken() {
// return token;
// }
//
// /**
// * Retrieve the IANA HTTP Authentication Scheme Name this token is an implementation of
// * @return IANA HTTP Authentication Scheme Name
// */
// public String getType() {
// return type;
// }
//
// public String toString() {
// return type + " " + token;
// }
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/exceptions/MissingBodyException.java
// public class MissingBodyException extends BadRequest {
//
// private static final long serialVersionUID = 4458613845508649207L;
//
// public MissingBodyException() {
// super("Required request body is missing");
// }
//
// }
// Path: src/main/java/tech/greenfield/vertx/irked/Request.java
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.*;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.impl.RoutingContextDecorator;
import io.vertx.ext.web.impl.RoutingContextInternal;
import tech.greenfield.vertx.irked.Controller.WebHandler;
import tech.greenfield.vertx.irked.auth.AuthorizationToken;
import tech.greenfield.vertx.irked.exceptions.MissingBodyException;
import tech.greenfield.vertx.irked.status.BadRequest;
import tech.greenfield.vertx.irked.status.OK;
fail((HttpError)failure);
else
fail(failure);
return null;
}
/**
* Helper failure handler for CompletableFuture users.
* Use in the middle an async chain to succinctly propagate exceptions, or
* success values as thus: <code>.whenComplete(req::handlePossibleFailure)</code>.
* This method will call {@link Request#fail(Throwable)} if a failure occurred,
* after unwrapping {@link RuntimeException}s as needed. It will also pass on
* the success value (or null if there was a failure) for the next async
* element. Subsequent code can check whether a failure was propagated
* by calling {@link #failed()}
* @param <V> the type of previous completion value that will be returned as the completion value for completion stages running this method
* @param successValue successful completion value to return in case no failure occurred
* @param throwable A {@link Throwable} error to fail on
* @return null
*/
public <V> V handlePossibleFailure(V successValue, Throwable throwable) {
if (Objects.nonNull(throwable))
fail(HttpError.unwrap(throwable));
return successValue;
}
/**
* Helper to easily configure standard failure handlers
* @return a WebHandler that sends Irked status exceptions as HTTP responses
*/ | public static WebHandler failureHandler() { |
GreenfieldTech/irked | src/main/java/tech/greenfield/vertx/irked/Request.java | // Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// protected interface WebHandler extends Handler<Request> {}
//
// Path: src/main/java/tech/greenfield/vertx/irked/auth/AuthorizationToken.java
// public class AuthorizationToken {
//
// private String token;
// private String type;
//
// /**
// * Constructor for token implementations is internal - use {@link #parse(String)} to create tokens
// */
// protected AuthorizationToken() {
// }
//
// /**
// * Parse an Authorization header text to create a specific token implementation
// *
// * This method uses the convention of the first word in the Authorization value being the
// * IANA HTTP Authentication Scheme Name, to dynamically load an appropriate implementation
// * from the tech.greenfield.vertx.irked.auth.AuthorizationToken service loader. If the
// * header value is incompatible (i.e. contains only one "word") then a token with the type
// * "simple" will be returned. Otherwise if no supporting implementation is found, an instance
// * of the {@link AuthorizationToken} class will be created.
// * @param authorizationHeader value of the HTTP Authorization header
// * @return a
// */
// public static AuthorizationToken parse(String authorizationHeader) {
// if (Objects.isNull(authorizationHeader))
// return new NullAuthorizationToken();
// String[] parts = authorizationHeader.split("\\s+",2);
// if (parts.length == 1)
// return new SimpleAuthrizationToken(parts[0]);
// for (AuthorizationToken a : ServiceLoader.load(AuthorizationToken.class)) {
// if (a.supports(parts[0]))
// return a.update(parts[0], parts[1]);
// }
// return new AuthorizationToken().update(parts[0], parts[1]);
// }
//
// /**
// * Update a service-loader loaded implementation with the actual details
// * @param type IANA HTTP Authentication Scheme Name
// * @param token token text
// * @return itself for fluent calling
// */
// protected AuthorizationToken update(String type, String token) {
// this.type = type;
// this.token = token;
// return this;
// }
//
// /**
// * Check whether an AuthorizationToken implementation supports the speciefied IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether this implementation supports the specified name
// */
// protected boolean supports(String type) {
// return false;
// }
//
// /**
// * Check whether the token implementation implements the specified IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether the implementation is valid for that scheme name
// */
// public boolean is(String type) {
// return Objects.isNull(type) ? Objects.isNull(this.type) : type.equalsIgnoreCase(this.type);
// }
//
// /**
// * Retrieve the authorization token text
// * @return authorization token text
// */
// public String getToken() {
// return token;
// }
//
// /**
// * Retrieve the IANA HTTP Authentication Scheme Name this token is an implementation of
// * @return IANA HTTP Authentication Scheme Name
// */
// public String getType() {
// return type;
// }
//
// public String toString() {
// return type + " " + token;
// }
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/exceptions/MissingBodyException.java
// public class MissingBodyException extends BadRequest {
//
// private static final long serialVersionUID = 4458613845508649207L;
//
// public MissingBodyException() {
// super("Required request body is missing");
// }
//
// }
| import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.*;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.impl.RoutingContextDecorator;
import io.vertx.ext.web.impl.RoutingContextInternal;
import tech.greenfield.vertx.irked.Controller.WebHandler;
import tech.greenfield.vertx.irked.auth.AuthorizationToken;
import tech.greenfield.vertx.irked.exceptions.MissingBodyException;
import tech.greenfield.vertx.irked.status.BadRequest;
import tech.greenfield.vertx.irked.status.OK; | *
* @param <T>
* @param type
* @return
*/
public <T> T getBodyAs(Class<T> type) {
String contentType = this.request().getHeader("Content-Type");
if (Objects.isNull(contentType)) contentType = "application/json"; // we love JSON
String[] ctParts = contentType.split(";\\s*");
switch (ctParts[0]) {
case "application/x-www-form-urlencoded":
JsonObject out = new JsonObject();
request().formAttributes().forEach(e -> {
Object old = out.getValue(e.getKey());
if (Objects.isNull(old)) {
out.put(e.getKey(), e.getValue());
return;
}
if (old instanceof JsonArray) {
((JsonArray)old).add(e.getValue());
return;
}
out.put(e.getKey(), new JsonArray().add(old).add(e.getValue()));
});
return out.mapTo(type);
case "application/json":
default:
try {
JsonObject body = getBodyAsJson();
if (body == null) | // Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// protected interface WebHandler extends Handler<Request> {}
//
// Path: src/main/java/tech/greenfield/vertx/irked/auth/AuthorizationToken.java
// public class AuthorizationToken {
//
// private String token;
// private String type;
//
// /**
// * Constructor for token implementations is internal - use {@link #parse(String)} to create tokens
// */
// protected AuthorizationToken() {
// }
//
// /**
// * Parse an Authorization header text to create a specific token implementation
// *
// * This method uses the convention of the first word in the Authorization value being the
// * IANA HTTP Authentication Scheme Name, to dynamically load an appropriate implementation
// * from the tech.greenfield.vertx.irked.auth.AuthorizationToken service loader. If the
// * header value is incompatible (i.e. contains only one "word") then a token with the type
// * "simple" will be returned. Otherwise if no supporting implementation is found, an instance
// * of the {@link AuthorizationToken} class will be created.
// * @param authorizationHeader value of the HTTP Authorization header
// * @return a
// */
// public static AuthorizationToken parse(String authorizationHeader) {
// if (Objects.isNull(authorizationHeader))
// return new NullAuthorizationToken();
// String[] parts = authorizationHeader.split("\\s+",2);
// if (parts.length == 1)
// return new SimpleAuthrizationToken(parts[0]);
// for (AuthorizationToken a : ServiceLoader.load(AuthorizationToken.class)) {
// if (a.supports(parts[0]))
// return a.update(parts[0], parts[1]);
// }
// return new AuthorizationToken().update(parts[0], parts[1]);
// }
//
// /**
// * Update a service-loader loaded implementation with the actual details
// * @param type IANA HTTP Authentication Scheme Name
// * @param token token text
// * @return itself for fluent calling
// */
// protected AuthorizationToken update(String type, String token) {
// this.type = type;
// this.token = token;
// return this;
// }
//
// /**
// * Check whether an AuthorizationToken implementation supports the speciefied IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether this implementation supports the specified name
// */
// protected boolean supports(String type) {
// return false;
// }
//
// /**
// * Check whether the token implementation implements the specified IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether the implementation is valid for that scheme name
// */
// public boolean is(String type) {
// return Objects.isNull(type) ? Objects.isNull(this.type) : type.equalsIgnoreCase(this.type);
// }
//
// /**
// * Retrieve the authorization token text
// * @return authorization token text
// */
// public String getToken() {
// return token;
// }
//
// /**
// * Retrieve the IANA HTTP Authentication Scheme Name this token is an implementation of
// * @return IANA HTTP Authentication Scheme Name
// */
// public String getType() {
// return type;
// }
//
// public String toString() {
// return type + " " + token;
// }
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/exceptions/MissingBodyException.java
// public class MissingBodyException extends BadRequest {
//
// private static final long serialVersionUID = 4458613845508649207L;
//
// public MissingBodyException() {
// super("Required request body is missing");
// }
//
// }
// Path: src/main/java/tech/greenfield/vertx/irked/Request.java
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.*;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.impl.RoutingContextDecorator;
import io.vertx.ext.web.impl.RoutingContextInternal;
import tech.greenfield.vertx.irked.Controller.WebHandler;
import tech.greenfield.vertx.irked.auth.AuthorizationToken;
import tech.greenfield.vertx.irked.exceptions.MissingBodyException;
import tech.greenfield.vertx.irked.status.BadRequest;
import tech.greenfield.vertx.irked.status.OK;
*
* @param <T>
* @param type
* @return
*/
public <T> T getBodyAs(Class<T> type) {
String contentType = this.request().getHeader("Content-Type");
if (Objects.isNull(contentType)) contentType = "application/json"; // we love JSON
String[] ctParts = contentType.split(";\\s*");
switch (ctParts[0]) {
case "application/x-www-form-urlencoded":
JsonObject out = new JsonObject();
request().formAttributes().forEach(e -> {
Object old = out.getValue(e.getKey());
if (Objects.isNull(old)) {
out.put(e.getKey(), e.getValue());
return;
}
if (old instanceof JsonArray) {
((JsonArray)old).add(e.getValue());
return;
}
out.put(e.getKey(), new JsonArray().add(old).add(e.getValue()));
});
return out.mapTo(type);
case "application/json":
default:
try {
JsonObject body = getBodyAsJson();
if (body == null) | throw new MissingBodyException().unchecked(); |
GreenfieldTech/irked | src/main/java/tech/greenfield/vertx/irked/Request.java | // Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// protected interface WebHandler extends Handler<Request> {}
//
// Path: src/main/java/tech/greenfield/vertx/irked/auth/AuthorizationToken.java
// public class AuthorizationToken {
//
// private String token;
// private String type;
//
// /**
// * Constructor for token implementations is internal - use {@link #parse(String)} to create tokens
// */
// protected AuthorizationToken() {
// }
//
// /**
// * Parse an Authorization header text to create a specific token implementation
// *
// * This method uses the convention of the first word in the Authorization value being the
// * IANA HTTP Authentication Scheme Name, to dynamically load an appropriate implementation
// * from the tech.greenfield.vertx.irked.auth.AuthorizationToken service loader. If the
// * header value is incompatible (i.e. contains only one "word") then a token with the type
// * "simple" will be returned. Otherwise if no supporting implementation is found, an instance
// * of the {@link AuthorizationToken} class will be created.
// * @param authorizationHeader value of the HTTP Authorization header
// * @return a
// */
// public static AuthorizationToken parse(String authorizationHeader) {
// if (Objects.isNull(authorizationHeader))
// return new NullAuthorizationToken();
// String[] parts = authorizationHeader.split("\\s+",2);
// if (parts.length == 1)
// return new SimpleAuthrizationToken(parts[0]);
// for (AuthorizationToken a : ServiceLoader.load(AuthorizationToken.class)) {
// if (a.supports(parts[0]))
// return a.update(parts[0], parts[1]);
// }
// return new AuthorizationToken().update(parts[0], parts[1]);
// }
//
// /**
// * Update a service-loader loaded implementation with the actual details
// * @param type IANA HTTP Authentication Scheme Name
// * @param token token text
// * @return itself for fluent calling
// */
// protected AuthorizationToken update(String type, String token) {
// this.type = type;
// this.token = token;
// return this;
// }
//
// /**
// * Check whether an AuthorizationToken implementation supports the speciefied IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether this implementation supports the specified name
// */
// protected boolean supports(String type) {
// return false;
// }
//
// /**
// * Check whether the token implementation implements the specified IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether the implementation is valid for that scheme name
// */
// public boolean is(String type) {
// return Objects.isNull(type) ? Objects.isNull(this.type) : type.equalsIgnoreCase(this.type);
// }
//
// /**
// * Retrieve the authorization token text
// * @return authorization token text
// */
// public String getToken() {
// return token;
// }
//
// /**
// * Retrieve the IANA HTTP Authentication Scheme Name this token is an implementation of
// * @return IANA HTTP Authentication Scheme Name
// */
// public String getType() {
// return type;
// }
//
// public String toString() {
// return type + " " + token;
// }
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/exceptions/MissingBodyException.java
// public class MissingBodyException extends BadRequest {
//
// private static final long serialVersionUID = 4458613845508649207L;
//
// public MissingBodyException() {
// super("Required request body is missing");
// }
//
// }
| import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.*;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.impl.RoutingContextDecorator;
import io.vertx.ext.web.impl.RoutingContextInternal;
import tech.greenfield.vertx.irked.Controller.WebHandler;
import tech.greenfield.vertx.irked.auth.AuthorizationToken;
import tech.greenfield.vertx.irked.exceptions.MissingBodyException;
import tech.greenfield.vertx.irked.status.BadRequest;
import tech.greenfield.vertx.irked.status.OK; | public HttpServerResponse response(HttpError status) {
HttpServerResponse res = response();
for (Entry<String, String> h : status.getHeaders())
res.putHeader(h.getKey(), h.getValue());
return res.setStatusCode(status.getStatusCode()).setStatusMessage(status.getStatusText());
}
/**
* Check if the client requested a connection upgrade, regardless which type
* of upgrade is required.
* @return {@literal true} if the request includes a 'Connection: upgrade' header.
*/
public boolean needUpgrade() {
return needUpgrade(null);
}
/**
* check if the client requested a specific connection upgrade.
* @param type What upgrade type to test against, case insensitive
* @return {@literal true} if the request includes a 'Connection: upgrade' header and an 'Upgrade' header with the specified type.
*/
public boolean needUpgrade(String type) {
HttpServerRequest req = request();
return req.getHeader("Connection").equalsIgnoreCase("upgrade") && (Objects.isNull(type) || req.getHeader("Upgrade").equalsIgnoreCase(type));
}
/**
* Helper for authorization header parsing
* @return A parsed {@link AuthorizationToken}
*/ | // Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// protected interface WebHandler extends Handler<Request> {}
//
// Path: src/main/java/tech/greenfield/vertx/irked/auth/AuthorizationToken.java
// public class AuthorizationToken {
//
// private String token;
// private String type;
//
// /**
// * Constructor for token implementations is internal - use {@link #parse(String)} to create tokens
// */
// protected AuthorizationToken() {
// }
//
// /**
// * Parse an Authorization header text to create a specific token implementation
// *
// * This method uses the convention of the first word in the Authorization value being the
// * IANA HTTP Authentication Scheme Name, to dynamically load an appropriate implementation
// * from the tech.greenfield.vertx.irked.auth.AuthorizationToken service loader. If the
// * header value is incompatible (i.e. contains only one "word") then a token with the type
// * "simple" will be returned. Otherwise if no supporting implementation is found, an instance
// * of the {@link AuthorizationToken} class will be created.
// * @param authorizationHeader value of the HTTP Authorization header
// * @return a
// */
// public static AuthorizationToken parse(String authorizationHeader) {
// if (Objects.isNull(authorizationHeader))
// return new NullAuthorizationToken();
// String[] parts = authorizationHeader.split("\\s+",2);
// if (parts.length == 1)
// return new SimpleAuthrizationToken(parts[0]);
// for (AuthorizationToken a : ServiceLoader.load(AuthorizationToken.class)) {
// if (a.supports(parts[0]))
// return a.update(parts[0], parts[1]);
// }
// return new AuthorizationToken().update(parts[0], parts[1]);
// }
//
// /**
// * Update a service-loader loaded implementation with the actual details
// * @param type IANA HTTP Authentication Scheme Name
// * @param token token text
// * @return itself for fluent calling
// */
// protected AuthorizationToken update(String type, String token) {
// this.type = type;
// this.token = token;
// return this;
// }
//
// /**
// * Check whether an AuthorizationToken implementation supports the speciefied IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether this implementation supports the specified name
// */
// protected boolean supports(String type) {
// return false;
// }
//
// /**
// * Check whether the token implementation implements the specified IANA HTTP Authentication Scheme Name
// * @param type IANA HTTP Authentication Scheme Name
// * @return whether the implementation is valid for that scheme name
// */
// public boolean is(String type) {
// return Objects.isNull(type) ? Objects.isNull(this.type) : type.equalsIgnoreCase(this.type);
// }
//
// /**
// * Retrieve the authorization token text
// * @return authorization token text
// */
// public String getToken() {
// return token;
// }
//
// /**
// * Retrieve the IANA HTTP Authentication Scheme Name this token is an implementation of
// * @return IANA HTTP Authentication Scheme Name
// */
// public String getType() {
// return type;
// }
//
// public String toString() {
// return type + " " + token;
// }
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/exceptions/MissingBodyException.java
// public class MissingBodyException extends BadRequest {
//
// private static final long serialVersionUID = 4458613845508649207L;
//
// public MissingBodyException() {
// super("Required request body is missing");
// }
//
// }
// Path: src/main/java/tech/greenfield/vertx/irked/Request.java
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.*;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.impl.RoutingContextDecorator;
import io.vertx.ext.web.impl.RoutingContextInternal;
import tech.greenfield.vertx.irked.Controller.WebHandler;
import tech.greenfield.vertx.irked.auth.AuthorizationToken;
import tech.greenfield.vertx.irked.exceptions.MissingBodyException;
import tech.greenfield.vertx.irked.status.BadRequest;
import tech.greenfield.vertx.irked.status.OK;
public HttpServerResponse response(HttpError status) {
HttpServerResponse res = response();
for (Entry<String, String> h : status.getHeaders())
res.putHeader(h.getKey(), h.getValue());
return res.setStatusCode(status.getStatusCode()).setStatusMessage(status.getStatusText());
}
/**
* Check if the client requested a connection upgrade, regardless which type
* of upgrade is required.
* @return {@literal true} if the request includes a 'Connection: upgrade' header.
*/
public boolean needUpgrade() {
return needUpgrade(null);
}
/**
* check if the client requested a specific connection upgrade.
* @param type What upgrade type to test against, case insensitive
* @return {@literal true} if the request includes a 'Connection: upgrade' header and an 'Upgrade' header with the specified type.
*/
public boolean needUpgrade(String type) {
HttpServerRequest req = request();
return req.getHeader("Connection").equalsIgnoreCase("upgrade") && (Objects.isNull(type) || req.getHeader("Upgrade").equalsIgnoreCase(type));
}
/**
* Helper for authorization header parsing
* @return A parsed {@link AuthorizationToken}
*/ | public AuthorizationToken getAuthorization() { |
GreenfieldTech/irked | src/test/java/tech/greenfield/vertx/irked/server/Server.java | // Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// public class Controller {
//
// protected interface RawVertxHandler extends Handler<RoutingContext> {}
// protected interface WebHandler extends Handler<Request> {}
// protected interface MessageHandler extends Handler<WebSocketMessage> {}
//
// private List<RouteConfiguration> routes;
//
// /**
// * Controller implementations should override this to generate local
// * request implementation (wrapped routing contexts).
// *
// * The default implementation just returns the passes request wrapper
// * @param request Top level request wrapper generated by Irked
// * @return Implementation of a sub-context request
// */
// protected Request getRequestContext(Request request) {
// return request;
// }
//
// /**
// * Helper method for {@link Router} to discover routing endpoints
// * @return list of fields that are routing endpoints
// * @throws InvalidRouteConfiguration If one of the declared and annotated routes is invalid
// */
// List<RouteConfiguration> getRoutes() throws InvalidRouteConfiguration {
// ArrayList<RouteConfiguration> out = new ArrayList<>();
// for (Field f : getClass().getDeclaredFields())
// out.add(RouteConfiguration.wrap(this, f));
// for (Method m : getClass().getDeclaredMethods())
// out.add(RouteConfiguration.wrap(this, m));
// return routes = out.stream().filter(RouteConfiguration::isValid).collect(Collectors.toList());
// }
//
// /**
// * Helper method for {@link Router} to create the appropriate request
// * handler for Vert.X
// * @param field routing endpoint handler exposed by this controller
// * @return a handler that takes a Vert.x original routing context and
// * wraps it in a local request context before delegating to the routing endpoint
// */
// @SuppressWarnings("unchecked")
// Handler<RoutingContext> getHandler(Field field) {
// try {
// field.setAccessible(true);
// if (Handler.class.isAssignableFrom(field.getType()))
// return (Handler<RoutingContext>)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// /**
// * Helper method for {@link Router} to mount sub-controllers
// * @param field routing endpoint exposed by this controller
// * @return Controller instance if the routing endpoint is a sub-controller,
// * null otherwise
// */
// Controller getController(Field field) {
// try {
// field.setAccessible(true);
// if (Controller.class.isAssignableFrom(field.getType()))
// return (Controller)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// public void remove() {
// routes.forEach(RouteConfiguration::remove);
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName();
// }
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/Irked.java
// public class Irked {
//
// private Vertx vertx;
//
// /**
// * Vert.x-styled Irked factory method.
// * @param vertx Vert.x instance in which to generated routers
// * @return a new Irked instance that can generate {@link Router}s and request handlers
// */
// public static Irked irked(Vertx vertx) {
// return new Irked(vertx);
// }
//
// /**
// * Create new Irked instance that can generate request handlers
// * @deprecated please use {@link Irked#irked(Vertx)} instead
// * @param vertx Vert.x instance in which to generate routers
// */
// public Irked(Vertx vertx) {
// this.vertx = vertx;
// }
//
// /**
// * Create an HTTP request handler, that can be used in {@link HttpServer#requestHandler()},
// * with the provided set of APIs configured
// * @param apis set of Irked API controllers to configure routing for
// * @return an HTTP request handler for the Vert.x HTTP server
// * @throws InvalidRouteConfiguration in case one of the route configurations is invalid
// */
// public Handler<HttpServerRequest> setupRequestHandler(Controller... apis) throws InvalidRouteConfiguration {
// Router router = new Router(vertx);
// for (Controller api : apis)
// router.configure(api);
// return router;
// }
//
// /**
// * Create a new Irked router
// * @return router that can be used to configure Irked API controllers and handle HTTP requests from Vert.x HTTP server
// */
// public Router router() {
// return new Router(vertx);
// }
//
// /**
// * Create a new Irked router
// * @param vertx Vert.x instance in which to generate routers
// * @return router that can be used to configure Irked API controllers and handle HTTP requests from Vert.x HTTP server
// */
// public static Router router(Vertx vertx) {
// return new Router(vertx);
// }
// }
| import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import tech.greenfield.vertx.irked.Controller;
import tech.greenfield.vertx.irked.Irked; | package tech.greenfield.vertx.irked.server;
public class Server extends AbstractVerticle {
private Controller test;
private HttpServer server;
private static HttpServerOptions httpServerOptions = new HttpServerOptions();
public Server(Controller testController) {
test = testController;
}
@Override
public void start(Promise<Void> startFuture) throws Exception {
Promise<HttpServer> async = Promise.promise();
(server = vertx.createHttpServer(getHttpServerOptions())).requestHandler( | // Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// public class Controller {
//
// protected interface RawVertxHandler extends Handler<RoutingContext> {}
// protected interface WebHandler extends Handler<Request> {}
// protected interface MessageHandler extends Handler<WebSocketMessage> {}
//
// private List<RouteConfiguration> routes;
//
// /**
// * Controller implementations should override this to generate local
// * request implementation (wrapped routing contexts).
// *
// * The default implementation just returns the passes request wrapper
// * @param request Top level request wrapper generated by Irked
// * @return Implementation of a sub-context request
// */
// protected Request getRequestContext(Request request) {
// return request;
// }
//
// /**
// * Helper method for {@link Router} to discover routing endpoints
// * @return list of fields that are routing endpoints
// * @throws InvalidRouteConfiguration If one of the declared and annotated routes is invalid
// */
// List<RouteConfiguration> getRoutes() throws InvalidRouteConfiguration {
// ArrayList<RouteConfiguration> out = new ArrayList<>();
// for (Field f : getClass().getDeclaredFields())
// out.add(RouteConfiguration.wrap(this, f));
// for (Method m : getClass().getDeclaredMethods())
// out.add(RouteConfiguration.wrap(this, m));
// return routes = out.stream().filter(RouteConfiguration::isValid).collect(Collectors.toList());
// }
//
// /**
// * Helper method for {@link Router} to create the appropriate request
// * handler for Vert.X
// * @param field routing endpoint handler exposed by this controller
// * @return a handler that takes a Vert.x original routing context and
// * wraps it in a local request context before delegating to the routing endpoint
// */
// @SuppressWarnings("unchecked")
// Handler<RoutingContext> getHandler(Field field) {
// try {
// field.setAccessible(true);
// if (Handler.class.isAssignableFrom(field.getType()))
// return (Handler<RoutingContext>)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// /**
// * Helper method for {@link Router} to mount sub-controllers
// * @param field routing endpoint exposed by this controller
// * @return Controller instance if the routing endpoint is a sub-controller,
// * null otherwise
// */
// Controller getController(Field field) {
// try {
// field.setAccessible(true);
// if (Controller.class.isAssignableFrom(field.getType()))
// return (Controller)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// public void remove() {
// routes.forEach(RouteConfiguration::remove);
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName();
// }
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/Irked.java
// public class Irked {
//
// private Vertx vertx;
//
// /**
// * Vert.x-styled Irked factory method.
// * @param vertx Vert.x instance in which to generated routers
// * @return a new Irked instance that can generate {@link Router}s and request handlers
// */
// public static Irked irked(Vertx vertx) {
// return new Irked(vertx);
// }
//
// /**
// * Create new Irked instance that can generate request handlers
// * @deprecated please use {@link Irked#irked(Vertx)} instead
// * @param vertx Vert.x instance in which to generate routers
// */
// public Irked(Vertx vertx) {
// this.vertx = vertx;
// }
//
// /**
// * Create an HTTP request handler, that can be used in {@link HttpServer#requestHandler()},
// * with the provided set of APIs configured
// * @param apis set of Irked API controllers to configure routing for
// * @return an HTTP request handler for the Vert.x HTTP server
// * @throws InvalidRouteConfiguration in case one of the route configurations is invalid
// */
// public Handler<HttpServerRequest> setupRequestHandler(Controller... apis) throws InvalidRouteConfiguration {
// Router router = new Router(vertx);
// for (Controller api : apis)
// router.configure(api);
// return router;
// }
//
// /**
// * Create a new Irked router
// * @return router that can be used to configure Irked API controllers and handle HTTP requests from Vert.x HTTP server
// */
// public Router router() {
// return new Router(vertx);
// }
//
// /**
// * Create a new Irked router
// * @param vertx Vert.x instance in which to generate routers
// * @return router that can be used to configure Irked API controllers and handle HTTP requests from Vert.x HTTP server
// */
// public static Router router(Vertx vertx) {
// return new Router(vertx);
// }
// }
// Path: src/test/java/tech/greenfield/vertx/irked/server/Server.java
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import tech.greenfield.vertx.irked.Controller;
import tech.greenfield.vertx.irked.Irked;
package tech.greenfield.vertx.irked.server;
public class Server extends AbstractVerticle {
private Controller test;
private HttpServer server;
private static HttpServerOptions httpServerOptions = new HttpServerOptions();
public Server(Controller testController) {
test = testController;
}
@Override
public void start(Promise<Void> startFuture) throws Exception {
Promise<HttpServer> async = Promise.promise();
(server = vertx.createHttpServer(getHttpServerOptions())).requestHandler( | Irked.router(vertx).configure(test).configReport(System.out)) |
GreenfieldTech/irked | src/test/java/tech/greenfield/vertx/irked/TestBadController.java | // Path: src/test/java/tech/greenfield/vertx/irked/base/TestBase.java
// public class TestBase {
//
// // client max message
// private static final int MAX_WEBSOCKET_MESSAGE_SIZE = 1024 * 1024 * 1024; // 1G. Frame size is 64K
//
// @RegisterExtension
// static VertxExtension vertxExtension = new VertxExtension();
// protected final Integer port = new Random().nextInt(30000)+10000;
//
// protected static WebClientExt getClient(Vertx vertx) {
// return new WebClientExt(vertx, new WebClientOptions(new HttpClientOptions()
// .setIdleTimeout(0)
// .setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE)));
// }
//
// protected void deployController(Controller controller, Vertx vertx, Handler<AsyncResult<String>> handler) {
// Server server = new Server(controller);
//
// DeploymentOptions options = new DeploymentOptions().setConfig(new JsonObject().put("port", port));
// vertx.deployVerticle(server, options, handler);
// }
//
// protected static Function<Throwable, Void> failureHandler(VertxTestContext context) {
// return t -> {
// context.failNow(t);
// return null;
// };
// }
//
// protected void verifyNotFound(HttpResponse<Buffer> r) {
// assertThat(r, is(notFound()));
// }
//
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/exceptions/InvalidRouteConfiguration.java
// public class InvalidRouteConfiguration extends Exception {
//
// private static final long serialVersionUID = 4458613845508649189L;
//
// public InvalidRouteConfiguration(String message) {
// super(message);
// }
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import org.junit.jupiter.api.Test;
import io.vertx.core.Vertx;
import io.vertx.junit5.VertxTestContext;
import tech.greenfield.vertx.irked.annotations.Get;
import tech.greenfield.vertx.irked.base.TestBase;
import tech.greenfield.vertx.irked.exceptions.InvalidRouteConfiguration; | package tech.greenfield.vertx.irked;
public class TestBadController extends TestBase {
public class TestControllerBadField extends Controller {
@Get("/")
String invalidHandler = "test";
}
public class TestControllerBadMethod extends Controller {
@Get("/")
boolean invalidMethod() {
return true;
}
}
@Test
public void testInvalidFieldHandlerError(VertxTestContext context, Vertx vertx) {
deployController(new TestControllerBadField(), vertx, context.failing(t -> { | // Path: src/test/java/tech/greenfield/vertx/irked/base/TestBase.java
// public class TestBase {
//
// // client max message
// private static final int MAX_WEBSOCKET_MESSAGE_SIZE = 1024 * 1024 * 1024; // 1G. Frame size is 64K
//
// @RegisterExtension
// static VertxExtension vertxExtension = new VertxExtension();
// protected final Integer port = new Random().nextInt(30000)+10000;
//
// protected static WebClientExt getClient(Vertx vertx) {
// return new WebClientExt(vertx, new WebClientOptions(new HttpClientOptions()
// .setIdleTimeout(0)
// .setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE)));
// }
//
// protected void deployController(Controller controller, Vertx vertx, Handler<AsyncResult<String>> handler) {
// Server server = new Server(controller);
//
// DeploymentOptions options = new DeploymentOptions().setConfig(new JsonObject().put("port", port));
// vertx.deployVerticle(server, options, handler);
// }
//
// protected static Function<Throwable, Void> failureHandler(VertxTestContext context) {
// return t -> {
// context.failNow(t);
// return null;
// };
// }
//
// protected void verifyNotFound(HttpResponse<Buffer> r) {
// assertThat(r, is(notFound()));
// }
//
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/exceptions/InvalidRouteConfiguration.java
// public class InvalidRouteConfiguration extends Exception {
//
// private static final long serialVersionUID = 4458613845508649189L;
//
// public InvalidRouteConfiguration(String message) {
// super(message);
// }
//
// }
// Path: src/test/java/tech/greenfield/vertx/irked/TestBadController.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import org.junit.jupiter.api.Test;
import io.vertx.core.Vertx;
import io.vertx.junit5.VertxTestContext;
import tech.greenfield.vertx.irked.annotations.Get;
import tech.greenfield.vertx.irked.base.TestBase;
import tech.greenfield.vertx.irked.exceptions.InvalidRouteConfiguration;
package tech.greenfield.vertx.irked;
public class TestBadController extends TestBase {
public class TestControllerBadField extends Controller {
@Get("/")
String invalidHandler = "test";
}
public class TestControllerBadMethod extends Controller {
@Get("/")
boolean invalidMethod() {
return true;
}
}
@Test
public void testInvalidFieldHandlerError(VertxTestContext context, Vertx vertx) {
deployController(new TestControllerBadField(), vertx, context.failing(t -> { | assertThat(t, is(instanceOf(InvalidRouteConfiguration.class))); |
GreenfieldTech/irked | src/main/java/tech/greenfield/vertx/irked/Irked.java | // Path: src/main/java/tech/greenfield/vertx/irked/exceptions/InvalidRouteConfiguration.java
// public class InvalidRouteConfiguration extends Exception {
//
// private static final long serialVersionUID = 4458613845508649189L;
//
// public InvalidRouteConfiguration(String message) {
// super(message);
// }
//
// }
| import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerRequest;
import tech.greenfield.vertx.irked.exceptions.InvalidRouteConfiguration; | package tech.greenfield.vertx.irked;
/**
* Helper for creating Irked routers
* @author odeda
*/
public class Irked {
private Vertx vertx;
/**
* Vert.x-styled Irked factory method.
* @param vertx Vert.x instance in which to generated routers
* @return a new Irked instance that can generate {@link Router}s and request handlers
*/
public static Irked irked(Vertx vertx) {
return new Irked(vertx);
}
/**
* Create new Irked instance that can generate request handlers
* @deprecated please use {@link Irked#irked(Vertx)} instead
* @param vertx Vert.x instance in which to generate routers
*/
public Irked(Vertx vertx) {
this.vertx = vertx;
}
/**
* Create an HTTP request handler, that can be used in {@link HttpServer#requestHandler()},
* with the provided set of APIs configured
* @param apis set of Irked API controllers to configure routing for
* @return an HTTP request handler for the Vert.x HTTP server
* @throws InvalidRouteConfiguration in case one of the route configurations is invalid
*/ | // Path: src/main/java/tech/greenfield/vertx/irked/exceptions/InvalidRouteConfiguration.java
// public class InvalidRouteConfiguration extends Exception {
//
// private static final long serialVersionUID = 4458613845508649189L;
//
// public InvalidRouteConfiguration(String message) {
// super(message);
// }
//
// }
// Path: src/main/java/tech/greenfield/vertx/irked/Irked.java
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerRequest;
import tech.greenfield.vertx.irked.exceptions.InvalidRouteConfiguration;
package tech.greenfield.vertx.irked;
/**
* Helper for creating Irked routers
* @author odeda
*/
public class Irked {
private Vertx vertx;
/**
* Vert.x-styled Irked factory method.
* @param vertx Vert.x instance in which to generated routers
* @return a new Irked instance that can generate {@link Router}s and request handlers
*/
public static Irked irked(Vertx vertx) {
return new Irked(vertx);
}
/**
* Create new Irked instance that can generate request handlers
* @deprecated please use {@link Irked#irked(Vertx)} instead
* @param vertx Vert.x instance in which to generate routers
*/
public Irked(Vertx vertx) {
this.vertx = vertx;
}
/**
* Create an HTTP request handler, that can be used in {@link HttpServer#requestHandler()},
* with the provided set of APIs configured
* @param apis set of Irked API controllers to configure routing for
* @return an HTTP request handler for the Vert.x HTTP server
* @throws InvalidRouteConfiguration in case one of the route configurations is invalid
*/ | public Handler<HttpServerRequest> setupRequestHandler(Controller... apis) throws InvalidRouteConfiguration { |
GreenfieldTech/irked | src/test/java/tech/greenfield/vertx/irked/TestWebSocketPayloads.java | // Path: src/test/java/tech/greenfield/vertx/irked/base/TestBase.java
// public class TestBase {
//
// // client max message
// private static final int MAX_WEBSOCKET_MESSAGE_SIZE = 1024 * 1024 * 1024; // 1G. Frame size is 64K
//
// @RegisterExtension
// static VertxExtension vertxExtension = new VertxExtension();
// protected final Integer port = new Random().nextInt(30000)+10000;
//
// protected static WebClientExt getClient(Vertx vertx) {
// return new WebClientExt(vertx, new WebClientOptions(new HttpClientOptions()
// .setIdleTimeout(0)
// .setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE)));
// }
//
// protected void deployController(Controller controller, Vertx vertx, Handler<AsyncResult<String>> handler) {
// Server server = new Server(controller);
//
// DeploymentOptions options = new DeploymentOptions().setConfig(new JsonObject().put("port", port));
// vertx.deployVerticle(server, options, handler);
// }
//
// protected static Function<Throwable, Void> failureHandler(VertxTestContext context) {
// return t -> {
// context.failNow(t);
// return null;
// };
// }
//
// protected void verifyNotFound(HttpResponse<Buffer> r) {
// assertThat(r, is(notFound()));
// }
//
// }
//
// Path: src/test/java/tech/greenfield/vertx/irked/server/Server.java
// public class Server extends AbstractVerticle {
//
// private Controller test;
// private HttpServer server;
// private static HttpServerOptions httpServerOptions = new HttpServerOptions();
//
// public Server(Controller testController) {
// test = testController;
// }
//
// @Override
// public void start(Promise<Void> startFuture) throws Exception {
// Promise<HttpServer> async = Promise.promise();
// (server = vertx.createHttpServer(getHttpServerOptions())).requestHandler(
// Irked.router(vertx).configure(test).configReport(System.out))
// .listen(config().getInteger("port"), async);
// async.future().map((Void) null).onComplete(startFuture);
// }
//
// public static HttpServerOptions getHttpServerOptions() {
// return httpServerOptions;
// }
//
// @Override
// public void stop(Promise<Void> stopFuture) throws Exception {
// server.close(stopFuture);
// }
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.ServerWebSocket;
import io.vertx.junit5.Checkpoint;
import io.vertx.junit5.VertxTestContext;
import tech.greenfield.vertx.irked.annotations.Get;
import tech.greenfield.vertx.irked.annotations.WebSocket;
import tech.greenfield.vertx.irked.base.TestBase;
import tech.greenfield.vertx.irked.server.Server; | payloadTester(ctr, context, vertx, true);
}
@Test
public void testLargestPayloadMsg(VertxTestContext context, Vertx vertx) {
var ctr = new TestControllerForLargePayloads(8000);
payloadTester(ctr, context, vertx, true);
}
@Test
public void testLargePayload(VertxTestContext context, Vertx vertx) {
var ctr = new TestControllerForLargePayloads(1000);
payloadTester(ctr, context, vertx, false);
}
@Test
public void testLargerPayload(VertxTestContext context, Vertx vertx) {
var ctr = new TestControllerForLargePayloads(40000);
payloadTester(ctr, context, vertx, false);
}
@Test
public void testLargestPayload(VertxTestContext context, Vertx vertx) {
var ctr = new TestControllerForLargePayloads(70000);
payloadTester(ctr, context, vertx, false);
}
private void payloadTester(TestControllerForLargePayloads ctr, VertxTestContext context, Vertx vertx, boolean wsmsg) {
Checkpoint async = context.checkpoint();
log.info("deploying verticle"); | // Path: src/test/java/tech/greenfield/vertx/irked/base/TestBase.java
// public class TestBase {
//
// // client max message
// private static final int MAX_WEBSOCKET_MESSAGE_SIZE = 1024 * 1024 * 1024; // 1G. Frame size is 64K
//
// @RegisterExtension
// static VertxExtension vertxExtension = new VertxExtension();
// protected final Integer port = new Random().nextInt(30000)+10000;
//
// protected static WebClientExt getClient(Vertx vertx) {
// return new WebClientExt(vertx, new WebClientOptions(new HttpClientOptions()
// .setIdleTimeout(0)
// .setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE)));
// }
//
// protected void deployController(Controller controller, Vertx vertx, Handler<AsyncResult<String>> handler) {
// Server server = new Server(controller);
//
// DeploymentOptions options = new DeploymentOptions().setConfig(new JsonObject().put("port", port));
// vertx.deployVerticle(server, options, handler);
// }
//
// protected static Function<Throwable, Void> failureHandler(VertxTestContext context) {
// return t -> {
// context.failNow(t);
// return null;
// };
// }
//
// protected void verifyNotFound(HttpResponse<Buffer> r) {
// assertThat(r, is(notFound()));
// }
//
// }
//
// Path: src/test/java/tech/greenfield/vertx/irked/server/Server.java
// public class Server extends AbstractVerticle {
//
// private Controller test;
// private HttpServer server;
// private static HttpServerOptions httpServerOptions = new HttpServerOptions();
//
// public Server(Controller testController) {
// test = testController;
// }
//
// @Override
// public void start(Promise<Void> startFuture) throws Exception {
// Promise<HttpServer> async = Promise.promise();
// (server = vertx.createHttpServer(getHttpServerOptions())).requestHandler(
// Irked.router(vertx).configure(test).configReport(System.out))
// .listen(config().getInteger("port"), async);
// async.future().map((Void) null).onComplete(startFuture);
// }
//
// public static HttpServerOptions getHttpServerOptions() {
// return httpServerOptions;
// }
//
// @Override
// public void stop(Promise<Void> stopFuture) throws Exception {
// server.close(stopFuture);
// }
//
// }
// Path: src/test/java/tech/greenfield/vertx/irked/TestWebSocketPayloads.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.ServerWebSocket;
import io.vertx.junit5.Checkpoint;
import io.vertx.junit5.VertxTestContext;
import tech.greenfield.vertx.irked.annotations.Get;
import tech.greenfield.vertx.irked.annotations.WebSocket;
import tech.greenfield.vertx.irked.base.TestBase;
import tech.greenfield.vertx.irked.server.Server;
payloadTester(ctr, context, vertx, true);
}
@Test
public void testLargestPayloadMsg(VertxTestContext context, Vertx vertx) {
var ctr = new TestControllerForLargePayloads(8000);
payloadTester(ctr, context, vertx, true);
}
@Test
public void testLargePayload(VertxTestContext context, Vertx vertx) {
var ctr = new TestControllerForLargePayloads(1000);
payloadTester(ctr, context, vertx, false);
}
@Test
public void testLargerPayload(VertxTestContext context, Vertx vertx) {
var ctr = new TestControllerForLargePayloads(40000);
payloadTester(ctr, context, vertx, false);
}
@Test
public void testLargestPayload(VertxTestContext context, Vertx vertx) {
var ctr = new TestControllerForLargePayloads(70000);
payloadTester(ctr, context, vertx, false);
}
private void payloadTester(TestControllerForLargePayloads ctr, VertxTestContext context, Vertx vertx, boolean wsmsg) {
Checkpoint async = context.checkpoint();
log.info("deploying verticle"); | Server.getHttpServerOptions().setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE); |
GreenfieldTech/irked | src/test/java/tech/greenfield/vertx/irked/base/TestBase.java | // Path: src/test/java/tech/greenfield/vertx/irked/Matchers.java
// public static Matcher<HttpResponse<?>> notFound() {
// return status(new NotFound());
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// public class Controller {
//
// protected interface RawVertxHandler extends Handler<RoutingContext> {}
// protected interface WebHandler extends Handler<Request> {}
// protected interface MessageHandler extends Handler<WebSocketMessage> {}
//
// private List<RouteConfiguration> routes;
//
// /**
// * Controller implementations should override this to generate local
// * request implementation (wrapped routing contexts).
// *
// * The default implementation just returns the passes request wrapper
// * @param request Top level request wrapper generated by Irked
// * @return Implementation of a sub-context request
// */
// protected Request getRequestContext(Request request) {
// return request;
// }
//
// /**
// * Helper method for {@link Router} to discover routing endpoints
// * @return list of fields that are routing endpoints
// * @throws InvalidRouteConfiguration If one of the declared and annotated routes is invalid
// */
// List<RouteConfiguration> getRoutes() throws InvalidRouteConfiguration {
// ArrayList<RouteConfiguration> out = new ArrayList<>();
// for (Field f : getClass().getDeclaredFields())
// out.add(RouteConfiguration.wrap(this, f));
// for (Method m : getClass().getDeclaredMethods())
// out.add(RouteConfiguration.wrap(this, m));
// return routes = out.stream().filter(RouteConfiguration::isValid).collect(Collectors.toList());
// }
//
// /**
// * Helper method for {@link Router} to create the appropriate request
// * handler for Vert.X
// * @param field routing endpoint handler exposed by this controller
// * @return a handler that takes a Vert.x original routing context and
// * wraps it in a local request context before delegating to the routing endpoint
// */
// @SuppressWarnings("unchecked")
// Handler<RoutingContext> getHandler(Field field) {
// try {
// field.setAccessible(true);
// if (Handler.class.isAssignableFrom(field.getType()))
// return (Handler<RoutingContext>)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// /**
// * Helper method for {@link Router} to mount sub-controllers
// * @param field routing endpoint exposed by this controller
// * @return Controller instance if the routing endpoint is a sub-controller,
// * null otherwise
// */
// Controller getController(Field field) {
// try {
// field.setAccessible(true);
// if (Controller.class.isAssignableFrom(field.getType()))
// return (Controller)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// public void remove() {
// routes.forEach(RouteConfiguration::remove);
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName();
// }
// }
//
// Path: src/test/java/tech/greenfield/vertx/irked/server/Server.java
// public class Server extends AbstractVerticle {
//
// private Controller test;
// private HttpServer server;
// private static HttpServerOptions httpServerOptions = new HttpServerOptions();
//
// public Server(Controller testController) {
// test = testController;
// }
//
// @Override
// public void start(Promise<Void> startFuture) throws Exception {
// Promise<HttpServer> async = Promise.promise();
// (server = vertx.createHttpServer(getHttpServerOptions())).requestHandler(
// Irked.router(vertx).configure(test).configReport(System.out))
// .listen(config().getInteger("port"), async);
// async.future().map((Void) null).onComplete(startFuture);
// }
//
// public static HttpServerOptions getHttpServerOptions() {
// return httpServerOptions;
// }
//
// @Override
// public void stop(Promise<Void> stopFuture) throws Exception {
// server.close(stopFuture);
// }
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static tech.greenfield.vertx.irked.Matchers.notFound;
import java.util.Random;
import java.util.function.Function;
import org.junit.jupiter.api.extension.RegisterExtension;
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import tech.greenfield.vertx.irked.Controller;
import tech.greenfield.vertx.irked.server.Server; | package tech.greenfield.vertx.irked.base;
public class TestBase {
// client max message
private static final int MAX_WEBSOCKET_MESSAGE_SIZE = 1024 * 1024 * 1024; // 1G. Frame size is 64K
@RegisterExtension
static VertxExtension vertxExtension = new VertxExtension();
protected final Integer port = new Random().nextInt(30000)+10000;
protected static WebClientExt getClient(Vertx vertx) {
return new WebClientExt(vertx, new WebClientOptions(new HttpClientOptions()
.setIdleTimeout(0)
.setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE)));
}
| // Path: src/test/java/tech/greenfield/vertx/irked/Matchers.java
// public static Matcher<HttpResponse<?>> notFound() {
// return status(new NotFound());
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// public class Controller {
//
// protected interface RawVertxHandler extends Handler<RoutingContext> {}
// protected interface WebHandler extends Handler<Request> {}
// protected interface MessageHandler extends Handler<WebSocketMessage> {}
//
// private List<RouteConfiguration> routes;
//
// /**
// * Controller implementations should override this to generate local
// * request implementation (wrapped routing contexts).
// *
// * The default implementation just returns the passes request wrapper
// * @param request Top level request wrapper generated by Irked
// * @return Implementation of a sub-context request
// */
// protected Request getRequestContext(Request request) {
// return request;
// }
//
// /**
// * Helper method for {@link Router} to discover routing endpoints
// * @return list of fields that are routing endpoints
// * @throws InvalidRouteConfiguration If one of the declared and annotated routes is invalid
// */
// List<RouteConfiguration> getRoutes() throws InvalidRouteConfiguration {
// ArrayList<RouteConfiguration> out = new ArrayList<>();
// for (Field f : getClass().getDeclaredFields())
// out.add(RouteConfiguration.wrap(this, f));
// for (Method m : getClass().getDeclaredMethods())
// out.add(RouteConfiguration.wrap(this, m));
// return routes = out.stream().filter(RouteConfiguration::isValid).collect(Collectors.toList());
// }
//
// /**
// * Helper method for {@link Router} to create the appropriate request
// * handler for Vert.X
// * @param field routing endpoint handler exposed by this controller
// * @return a handler that takes a Vert.x original routing context and
// * wraps it in a local request context before delegating to the routing endpoint
// */
// @SuppressWarnings("unchecked")
// Handler<RoutingContext> getHandler(Field field) {
// try {
// field.setAccessible(true);
// if (Handler.class.isAssignableFrom(field.getType()))
// return (Handler<RoutingContext>)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// /**
// * Helper method for {@link Router} to mount sub-controllers
// * @param field routing endpoint exposed by this controller
// * @return Controller instance if the routing endpoint is a sub-controller,
// * null otherwise
// */
// Controller getController(Field field) {
// try {
// field.setAccessible(true);
// if (Controller.class.isAssignableFrom(field.getType()))
// return (Controller)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// public void remove() {
// routes.forEach(RouteConfiguration::remove);
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName();
// }
// }
//
// Path: src/test/java/tech/greenfield/vertx/irked/server/Server.java
// public class Server extends AbstractVerticle {
//
// private Controller test;
// private HttpServer server;
// private static HttpServerOptions httpServerOptions = new HttpServerOptions();
//
// public Server(Controller testController) {
// test = testController;
// }
//
// @Override
// public void start(Promise<Void> startFuture) throws Exception {
// Promise<HttpServer> async = Promise.promise();
// (server = vertx.createHttpServer(getHttpServerOptions())).requestHandler(
// Irked.router(vertx).configure(test).configReport(System.out))
// .listen(config().getInteger("port"), async);
// async.future().map((Void) null).onComplete(startFuture);
// }
//
// public static HttpServerOptions getHttpServerOptions() {
// return httpServerOptions;
// }
//
// @Override
// public void stop(Promise<Void> stopFuture) throws Exception {
// server.close(stopFuture);
// }
//
// }
// Path: src/test/java/tech/greenfield/vertx/irked/base/TestBase.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static tech.greenfield.vertx.irked.Matchers.notFound;
import java.util.Random;
import java.util.function.Function;
import org.junit.jupiter.api.extension.RegisterExtension;
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import tech.greenfield.vertx.irked.Controller;
import tech.greenfield.vertx.irked.server.Server;
package tech.greenfield.vertx.irked.base;
public class TestBase {
// client max message
private static final int MAX_WEBSOCKET_MESSAGE_SIZE = 1024 * 1024 * 1024; // 1G. Frame size is 64K
@RegisterExtension
static VertxExtension vertxExtension = new VertxExtension();
protected final Integer port = new Random().nextInt(30000)+10000;
protected static WebClientExt getClient(Vertx vertx) {
return new WebClientExt(vertx, new WebClientOptions(new HttpClientOptions()
.setIdleTimeout(0)
.setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE)));
}
| protected void deployController(Controller controller, Vertx vertx, Handler<AsyncResult<String>> handler) { |
GreenfieldTech/irked | src/test/java/tech/greenfield/vertx/irked/base/TestBase.java | // Path: src/test/java/tech/greenfield/vertx/irked/Matchers.java
// public static Matcher<HttpResponse<?>> notFound() {
// return status(new NotFound());
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// public class Controller {
//
// protected interface RawVertxHandler extends Handler<RoutingContext> {}
// protected interface WebHandler extends Handler<Request> {}
// protected interface MessageHandler extends Handler<WebSocketMessage> {}
//
// private List<RouteConfiguration> routes;
//
// /**
// * Controller implementations should override this to generate local
// * request implementation (wrapped routing contexts).
// *
// * The default implementation just returns the passes request wrapper
// * @param request Top level request wrapper generated by Irked
// * @return Implementation of a sub-context request
// */
// protected Request getRequestContext(Request request) {
// return request;
// }
//
// /**
// * Helper method for {@link Router} to discover routing endpoints
// * @return list of fields that are routing endpoints
// * @throws InvalidRouteConfiguration If one of the declared and annotated routes is invalid
// */
// List<RouteConfiguration> getRoutes() throws InvalidRouteConfiguration {
// ArrayList<RouteConfiguration> out = new ArrayList<>();
// for (Field f : getClass().getDeclaredFields())
// out.add(RouteConfiguration.wrap(this, f));
// for (Method m : getClass().getDeclaredMethods())
// out.add(RouteConfiguration.wrap(this, m));
// return routes = out.stream().filter(RouteConfiguration::isValid).collect(Collectors.toList());
// }
//
// /**
// * Helper method for {@link Router} to create the appropriate request
// * handler for Vert.X
// * @param field routing endpoint handler exposed by this controller
// * @return a handler that takes a Vert.x original routing context and
// * wraps it in a local request context before delegating to the routing endpoint
// */
// @SuppressWarnings("unchecked")
// Handler<RoutingContext> getHandler(Field field) {
// try {
// field.setAccessible(true);
// if (Handler.class.isAssignableFrom(field.getType()))
// return (Handler<RoutingContext>)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// /**
// * Helper method for {@link Router} to mount sub-controllers
// * @param field routing endpoint exposed by this controller
// * @return Controller instance if the routing endpoint is a sub-controller,
// * null otherwise
// */
// Controller getController(Field field) {
// try {
// field.setAccessible(true);
// if (Controller.class.isAssignableFrom(field.getType()))
// return (Controller)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// public void remove() {
// routes.forEach(RouteConfiguration::remove);
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName();
// }
// }
//
// Path: src/test/java/tech/greenfield/vertx/irked/server/Server.java
// public class Server extends AbstractVerticle {
//
// private Controller test;
// private HttpServer server;
// private static HttpServerOptions httpServerOptions = new HttpServerOptions();
//
// public Server(Controller testController) {
// test = testController;
// }
//
// @Override
// public void start(Promise<Void> startFuture) throws Exception {
// Promise<HttpServer> async = Promise.promise();
// (server = vertx.createHttpServer(getHttpServerOptions())).requestHandler(
// Irked.router(vertx).configure(test).configReport(System.out))
// .listen(config().getInteger("port"), async);
// async.future().map((Void) null).onComplete(startFuture);
// }
//
// public static HttpServerOptions getHttpServerOptions() {
// return httpServerOptions;
// }
//
// @Override
// public void stop(Promise<Void> stopFuture) throws Exception {
// server.close(stopFuture);
// }
//
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static tech.greenfield.vertx.irked.Matchers.notFound;
import java.util.Random;
import java.util.function.Function;
import org.junit.jupiter.api.extension.RegisterExtension;
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import tech.greenfield.vertx.irked.Controller;
import tech.greenfield.vertx.irked.server.Server; | package tech.greenfield.vertx.irked.base;
public class TestBase {
// client max message
private static final int MAX_WEBSOCKET_MESSAGE_SIZE = 1024 * 1024 * 1024; // 1G. Frame size is 64K
@RegisterExtension
static VertxExtension vertxExtension = new VertxExtension();
protected final Integer port = new Random().nextInt(30000)+10000;
protected static WebClientExt getClient(Vertx vertx) {
return new WebClientExt(vertx, new WebClientOptions(new HttpClientOptions()
.setIdleTimeout(0)
.setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE)));
}
protected void deployController(Controller controller, Vertx vertx, Handler<AsyncResult<String>> handler) { | // Path: src/test/java/tech/greenfield/vertx/irked/Matchers.java
// public static Matcher<HttpResponse<?>> notFound() {
// return status(new NotFound());
// }
//
// Path: src/main/java/tech/greenfield/vertx/irked/Controller.java
// public class Controller {
//
// protected interface RawVertxHandler extends Handler<RoutingContext> {}
// protected interface WebHandler extends Handler<Request> {}
// protected interface MessageHandler extends Handler<WebSocketMessage> {}
//
// private List<RouteConfiguration> routes;
//
// /**
// * Controller implementations should override this to generate local
// * request implementation (wrapped routing contexts).
// *
// * The default implementation just returns the passes request wrapper
// * @param request Top level request wrapper generated by Irked
// * @return Implementation of a sub-context request
// */
// protected Request getRequestContext(Request request) {
// return request;
// }
//
// /**
// * Helper method for {@link Router} to discover routing endpoints
// * @return list of fields that are routing endpoints
// * @throws InvalidRouteConfiguration If one of the declared and annotated routes is invalid
// */
// List<RouteConfiguration> getRoutes() throws InvalidRouteConfiguration {
// ArrayList<RouteConfiguration> out = new ArrayList<>();
// for (Field f : getClass().getDeclaredFields())
// out.add(RouteConfiguration.wrap(this, f));
// for (Method m : getClass().getDeclaredMethods())
// out.add(RouteConfiguration.wrap(this, m));
// return routes = out.stream().filter(RouteConfiguration::isValid).collect(Collectors.toList());
// }
//
// /**
// * Helper method for {@link Router} to create the appropriate request
// * handler for Vert.X
// * @param field routing endpoint handler exposed by this controller
// * @return a handler that takes a Vert.x original routing context and
// * wraps it in a local request context before delegating to the routing endpoint
// */
// @SuppressWarnings("unchecked")
// Handler<RoutingContext> getHandler(Field field) {
// try {
// field.setAccessible(true);
// if (Handler.class.isAssignableFrom(field.getType()))
// return (Handler<RoutingContext>)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// /**
// * Helper method for {@link Router} to mount sub-controllers
// * @param field routing endpoint exposed by this controller
// * @return Controller instance if the routing endpoint is a sub-controller,
// * null otherwise
// */
// Controller getController(Field field) {
// try {
// field.setAccessible(true);
// if (Controller.class.isAssignableFrom(field.getType()))
// return (Controller)field.get(this);
// return null;
// } catch (IllegalArgumentException | IllegalAccessException e) {
// // shouldn't happen
// throw new RuntimeException("Error accessing field " + field + ": " + e, e);
// }
// }
//
// public void remove() {
// routes.forEach(RouteConfiguration::remove);
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName();
// }
// }
//
// Path: src/test/java/tech/greenfield/vertx/irked/server/Server.java
// public class Server extends AbstractVerticle {
//
// private Controller test;
// private HttpServer server;
// private static HttpServerOptions httpServerOptions = new HttpServerOptions();
//
// public Server(Controller testController) {
// test = testController;
// }
//
// @Override
// public void start(Promise<Void> startFuture) throws Exception {
// Promise<HttpServer> async = Promise.promise();
// (server = vertx.createHttpServer(getHttpServerOptions())).requestHandler(
// Irked.router(vertx).configure(test).configReport(System.out))
// .listen(config().getInteger("port"), async);
// async.future().map((Void) null).onComplete(startFuture);
// }
//
// public static HttpServerOptions getHttpServerOptions() {
// return httpServerOptions;
// }
//
// @Override
// public void stop(Promise<Void> stopFuture) throws Exception {
// server.close(stopFuture);
// }
//
// }
// Path: src/test/java/tech/greenfield/vertx/irked/base/TestBase.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static tech.greenfield.vertx.irked.Matchers.notFound;
import java.util.Random;
import java.util.function.Function;
import org.junit.jupiter.api.extension.RegisterExtension;
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.junit5.VertxExtension;
import io.vertx.junit5.VertxTestContext;
import tech.greenfield.vertx.irked.Controller;
import tech.greenfield.vertx.irked.server.Server;
package tech.greenfield.vertx.irked.base;
public class TestBase {
// client max message
private static final int MAX_WEBSOCKET_MESSAGE_SIZE = 1024 * 1024 * 1024; // 1G. Frame size is 64K
@RegisterExtension
static VertxExtension vertxExtension = new VertxExtension();
protected final Integer port = new Random().nextInt(30000)+10000;
protected static WebClientExt getClient(Vertx vertx) {
return new WebClientExt(vertx, new WebClientOptions(new HttpClientOptions()
.setIdleTimeout(0)
.setMaxWebSocketMessageSize(MAX_WEBSOCKET_MESSAGE_SIZE)));
}
protected void deployController(Controller controller, Vertx vertx, Handler<AsyncResult<String>> handler) { | Server server = new Server(controller); |
gejinlove/petapojo | main/java/com/viviframework/petapojo/handlers/converters/DefaultEnumConverterFactory.java | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/enums/EnumUtils.java
// public class EnumUtils {
//
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static Map<Class<? extends IEnumMessage>, Map<Integer, IEnumMessage>> ENUM_MAPS = new HashMap<>();
//
// public static <T extends IEnumMessage> T getEnum(Class<T> type, int value) {
// return (T) getEnumValues(type).get(value);
// }
//
// public static <T extends IEnumMessage> Map<Integer, String> getEnumItems(Class<T> type) {
// Map<Integer, IEnumMessage> map = getEnumValues(type);
// Map<Integer, String> resultMap = new HashMap<>();
// map.forEach((k, v) -> {
// resultMap.put(k, v.getName());
// });
// return resultMap;
// }
//
// private static <T extends IEnumMessage> Map<Integer, IEnumMessage> getEnumValues(Class<T> clazz) {
// rl.lock();
// try {
// if (ENUM_MAPS.containsKey(clazz))
// return ENUM_MAPS.get(clazz);
// } finally {
// rl.unlock();
// }
//
// wl.lock();
// try {
// if (ENUM_MAPS.containsKey(clazz))
// return ENUM_MAPS.get(clazz);
//
// Map<Integer, IEnumMessage> map = new HashMap<>();
// try {
// for (IEnumMessage enumMessage : clazz.getEnumConstants()) {
// map.put(enumMessage.getValue(), enumMessage);
// }
// } catch (Exception e) {
// throw new RuntimeException("getEnumValues error", e);
// }
// ENUM_MAPS.put(clazz, map);
//
// return map;
// } finally {
// wl.unlock();
// }
// }
// }
| import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.enums.EnumUtils; | package com.viviframework.petapojo.handlers.converters;
/**
* 枚举转换器
*/
public class DefaultEnumConverterFactory implements EnumConverterFactory {
@Override | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/enums/EnumUtils.java
// public class EnumUtils {
//
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static Map<Class<? extends IEnumMessage>, Map<Integer, IEnumMessage>> ENUM_MAPS = new HashMap<>();
//
// public static <T extends IEnumMessage> T getEnum(Class<T> type, int value) {
// return (T) getEnumValues(type).get(value);
// }
//
// public static <T extends IEnumMessage> Map<Integer, String> getEnumItems(Class<T> type) {
// Map<Integer, IEnumMessage> map = getEnumValues(type);
// Map<Integer, String> resultMap = new HashMap<>();
// map.forEach((k, v) -> {
// resultMap.put(k, v.getName());
// });
// return resultMap;
// }
//
// private static <T extends IEnumMessage> Map<Integer, IEnumMessage> getEnumValues(Class<T> clazz) {
// rl.lock();
// try {
// if (ENUM_MAPS.containsKey(clazz))
// return ENUM_MAPS.get(clazz);
// } finally {
// rl.unlock();
// }
//
// wl.lock();
// try {
// if (ENUM_MAPS.containsKey(clazz))
// return ENUM_MAPS.get(clazz);
//
// Map<Integer, IEnumMessage> map = new HashMap<>();
// try {
// for (IEnumMessage enumMessage : clazz.getEnumConstants()) {
// map.put(enumMessage.getValue(), enumMessage);
// }
// } catch (Exception e) {
// throw new RuntimeException("getEnumValues error", e);
// }
// ENUM_MAPS.put(clazz, map);
//
// return map;
// } finally {
// wl.unlock();
// }
// }
// }
// Path: main/java/com/viviframework/petapojo/handlers/converters/DefaultEnumConverterFactory.java
import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.enums.EnumUtils;
package com.viviframework.petapojo.handlers.converters;
/**
* 枚举转换器
*/
public class DefaultEnumConverterFactory implements EnumConverterFactory {
@Override | public <T extends IEnumMessage> Converter<T> newConverter(final Class<T> enumClass) { |
gejinlove/petapojo | main/java/com/viviframework/petapojo/handlers/converters/DefaultEnumConverterFactory.java | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/enums/EnumUtils.java
// public class EnumUtils {
//
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static Map<Class<? extends IEnumMessage>, Map<Integer, IEnumMessage>> ENUM_MAPS = new HashMap<>();
//
// public static <T extends IEnumMessage> T getEnum(Class<T> type, int value) {
// return (T) getEnumValues(type).get(value);
// }
//
// public static <T extends IEnumMessage> Map<Integer, String> getEnumItems(Class<T> type) {
// Map<Integer, IEnumMessage> map = getEnumValues(type);
// Map<Integer, String> resultMap = new HashMap<>();
// map.forEach((k, v) -> {
// resultMap.put(k, v.getName());
// });
// return resultMap;
// }
//
// private static <T extends IEnumMessage> Map<Integer, IEnumMessage> getEnumValues(Class<T> clazz) {
// rl.lock();
// try {
// if (ENUM_MAPS.containsKey(clazz))
// return ENUM_MAPS.get(clazz);
// } finally {
// rl.unlock();
// }
//
// wl.lock();
// try {
// if (ENUM_MAPS.containsKey(clazz))
// return ENUM_MAPS.get(clazz);
//
// Map<Integer, IEnumMessage> map = new HashMap<>();
// try {
// for (IEnumMessage enumMessage : clazz.getEnumConstants()) {
// map.put(enumMessage.getValue(), enumMessage);
// }
// } catch (Exception e) {
// throw new RuntimeException("getEnumValues error", e);
// }
// ENUM_MAPS.put(clazz, map);
//
// return map;
// } finally {
// wl.unlock();
// }
// }
// }
| import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.enums.EnumUtils; | package com.viviframework.petapojo.handlers.converters;
/**
* 枚举转换器
*/
public class DefaultEnumConverterFactory implements EnumConverterFactory {
@Override
public <T extends IEnumMessage> Converter<T> newConverter(final Class<T> enumClass) {
return new Converter<T>() {
@Override
public T convert(Object val) throws ConvertException {
if (val == null) {
return null;
}
if(!IEnumMessage.class.isAssignableFrom(enumClass)){
throw new ConvertException(String.format("enum [%s] must extend IEnumMessage",enumClass.toString()));
}
if(!(val instanceof Number)){
throw new ConvertException(String.format("enum value [%s] must bu Number", val.getClass().toString()));
}
try { | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/enums/EnumUtils.java
// public class EnumUtils {
//
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static Map<Class<? extends IEnumMessage>, Map<Integer, IEnumMessage>> ENUM_MAPS = new HashMap<>();
//
// public static <T extends IEnumMessage> T getEnum(Class<T> type, int value) {
// return (T) getEnumValues(type).get(value);
// }
//
// public static <T extends IEnumMessage> Map<Integer, String> getEnumItems(Class<T> type) {
// Map<Integer, IEnumMessage> map = getEnumValues(type);
// Map<Integer, String> resultMap = new HashMap<>();
// map.forEach((k, v) -> {
// resultMap.put(k, v.getName());
// });
// return resultMap;
// }
//
// private static <T extends IEnumMessage> Map<Integer, IEnumMessage> getEnumValues(Class<T> clazz) {
// rl.lock();
// try {
// if (ENUM_MAPS.containsKey(clazz))
// return ENUM_MAPS.get(clazz);
// } finally {
// rl.unlock();
// }
//
// wl.lock();
// try {
// if (ENUM_MAPS.containsKey(clazz))
// return ENUM_MAPS.get(clazz);
//
// Map<Integer, IEnumMessage> map = new HashMap<>();
// try {
// for (IEnumMessage enumMessage : clazz.getEnumConstants()) {
// map.put(enumMessage.getValue(), enumMessage);
// }
// } catch (Exception e) {
// throw new RuntimeException("getEnumValues error", e);
// }
// ENUM_MAPS.put(clazz, map);
//
// return map;
// } finally {
// wl.unlock();
// }
// }
// }
// Path: main/java/com/viviframework/petapojo/handlers/converters/DefaultEnumConverterFactory.java
import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.enums.EnumUtils;
package com.viviframework.petapojo.handlers.converters;
/**
* 枚举转换器
*/
public class DefaultEnumConverterFactory implements EnumConverterFactory {
@Override
public <T extends IEnumMessage> Converter<T> newConverter(final Class<T> enumClass) {
return new Converter<T>() {
@Override
public T convert(Object val) throws ConvertException {
if (val == null) {
return null;
}
if(!IEnumMessage.class.isAssignableFrom(enumClass)){
throw new ConvertException(String.format("enum [%s] must extend IEnumMessage",enumClass.toString()));
}
if(!(val instanceof Number)){
throw new ConvertException(String.format("enum value [%s] must bu Number", val.getClass().toString()));
}
try { | return EnumUtils.getEnum(enumClass,((Number)val).intValue()); |
gejinlove/petapojo | main/java/com/viviframework/petapojo/handlers/converters/number/NumberConverter.java | // Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
| import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter; | package com.viviframework.petapojo.handlers.converters.number;
/**
* Number 类型转换器基类
*/
public abstract class NumberConverter<T extends Number> implements Converter<T> {
private boolean isPrimitive;
public NumberConverter(boolean primitive) {
isPrimitive = primitive;
}
| // Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
// Path: main/java/com/viviframework/petapojo/handlers/converters/number/NumberConverter.java
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
package com.viviframework.petapojo.handlers.converters.number;
/**
* Number 类型转换器基类
*/
public abstract class NumberConverter<T extends Number> implements Converter<T> {
private boolean isPrimitive;
public NumberConverter(boolean primitive) {
isPrimitive = primitive;
}
| public T convert(Object val) throws ConvertException { |
gejinlove/petapojo | main/java/com/viviframework/petapojo/handlers/converters/StringConverter.java | // Path: main/java/com/viviframework/petapojo/tools/IOUtils.java
// public class IOUtils {
//
// private static final int EOF = -1;
// private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
//
// public static byte[] toByteArray(InputStream input) throws IOException {
// ByteArrayOutputStream output = new ByteArrayOutputStream();
// byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
// int n;
// while (EOF != (n = input.read(buffer))) {
// output.write(buffer, 0, n);
// }
// return output.toByteArray();
// }
//
// public static String toString(Reader input) throws IOException {
// StringBuilder output = new StringBuilder();
// char[] buffer = new char[DEFAULT_BUFFER_SIZE];
// int n;
// while (EOF != (n = input.read(buffer))) {
// output.append(buffer, 0, n);
// }
// return output.toString();
// }
//
//
// }
| import com.viviframework.petapojo.tools.IOUtils;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException; | package com.viviframework.petapojo.handlers.converters;
/**
* String类型转换器
*/
public class StringConverter implements Converter<String> {
@Override
public String convert(Object val) throws ConvertException {
if (val == null) {
return null;
}
if (val instanceof Clob) {
Clob clobVal = (Clob) val;
try {
try {
return clobVal.getSubString(1, (int) clobVal.length());
} catch (SQLException ex) {
throw new ConvertException("error converting clob to String", ex);
}
} finally {
try {
clobVal.free();
} catch (Throwable ignore) {
}
}
}
if (val instanceof Reader) {
Reader reader = (Reader) val;
try {
try { | // Path: main/java/com/viviframework/petapojo/tools/IOUtils.java
// public class IOUtils {
//
// private static final int EOF = -1;
// private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
//
// public static byte[] toByteArray(InputStream input) throws IOException {
// ByteArrayOutputStream output = new ByteArrayOutputStream();
// byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
// int n;
// while (EOF != (n = input.read(buffer))) {
// output.write(buffer, 0, n);
// }
// return output.toByteArray();
// }
//
// public static String toString(Reader input) throws IOException {
// StringBuilder output = new StringBuilder();
// char[] buffer = new char[DEFAULT_BUFFER_SIZE];
// int n;
// while (EOF != (n = input.read(buffer))) {
// output.append(buffer, 0, n);
// }
// return output.toString();
// }
//
//
// }
// Path: main/java/com/viviframework/petapojo/handlers/converters/StringConverter.java
import com.viviframework.petapojo.tools.IOUtils;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;
package com.viviframework.petapojo.handlers.converters;
/**
* String类型转换器
*/
public class StringConverter implements Converter<String> {
@Override
public String convert(Object val) throws ConvertException {
if (val == null) {
return null;
}
if (val instanceof Clob) {
Clob clobVal = (Clob) val;
try {
try {
return clobVal.getSubString(1, (int) clobVal.length());
} catch (SQLException ex) {
throw new ConvertException("error converting clob to String", ex);
}
} finally {
try {
clobVal.free();
} catch (Throwable ignore) {
}
}
}
if (val instanceof Reader) {
Reader reader = (Reader) val;
try {
try { | return IOUtils.toString(reader); |
gejinlove/petapojo | main/java/com/viviframework/petapojo/handlers/converters/dates/joda/DateTimeConverter.java | // Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
| import com.viviframework.petapojo.handlers.converters.ConvertException;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDateTime;
import com.viviframework.petapojo.handlers.converters.Converter; | package com.viviframework.petapojo.handlers.converters.dates.joda;
/**
* 时间类型转换器
*/
public class DateTimeConverter implements Converter<DateTime> {
private final DateTimeZone timeZone;
public DateTimeConverter(DateTimeZone timeZone) {
this.timeZone = timeZone;
}
public DateTimeConverter() {
this(DateTimeZone.getDefault());
}
| // Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
// Path: main/java/com/viviframework/petapojo/handlers/converters/dates/joda/DateTimeConverter.java
import com.viviframework.petapojo.handlers.converters.ConvertException;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDateTime;
import com.viviframework.petapojo.handlers.converters.Converter;
package com.viviframework.petapojo.handlers.converters.dates.joda;
/**
* 时间类型转换器
*/
public class DateTimeConverter implements Converter<DateTime> {
private final DateTimeZone timeZone;
public DateTimeConverter(DateTimeZone timeZone) {
this.timeZone = timeZone;
}
public DateTimeConverter() {
this(DateTimeZone.getDefault());
}
| public DateTime convert(Object val) throws ConvertException { |
gejinlove/petapojo | main/java/com/viviframework/petapojo/handlers/converters/ByteArrayConverter.java | // Path: main/java/com/viviframework/petapojo/tools/IOUtils.java
// public class IOUtils {
//
// private static final int EOF = -1;
// private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
//
// public static byte[] toByteArray(InputStream input) throws IOException {
// ByteArrayOutputStream output = new ByteArrayOutputStream();
// byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
// int n;
// while (EOF != (n = input.read(buffer))) {
// output.write(buffer, 0, n);
// }
// return output.toByteArray();
// }
//
// public static String toString(Reader input) throws IOException {
// StringBuilder output = new StringBuilder();
// char[] buffer = new char[DEFAULT_BUFFER_SIZE];
// int n;
// while (EOF != (n = input.read(buffer))) {
// output.append(buffer, 0, n);
// }
// return output.toString();
// }
//
//
// }
| import com.viviframework.petapojo.tools.IOUtils;
import java.io.InputStream;
import java.sql.Blob; | package com.viviframework.petapojo.handlers.converters;
/**
* byte[] 类型转换器
*/
public class ByteArrayConverter implements Converter<byte[]> {
@Override
public byte[] convert(Object val) throws ConvertException {
if (val == null) {
return null;
}
if (val instanceof Blob) {
Blob b = (Blob) val;
InputStream stream = null;
try {
try {
stream = b.getBinaryStream(); | // Path: main/java/com/viviframework/petapojo/tools/IOUtils.java
// public class IOUtils {
//
// private static final int EOF = -1;
// private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
//
// public static byte[] toByteArray(InputStream input) throws IOException {
// ByteArrayOutputStream output = new ByteArrayOutputStream();
// byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
// int n;
// while (EOF != (n = input.read(buffer))) {
// output.write(buffer, 0, n);
// }
// return output.toByteArray();
// }
//
// public static String toString(Reader input) throws IOException {
// StringBuilder output = new StringBuilder();
// char[] buffer = new char[DEFAULT_BUFFER_SIZE];
// int n;
// while (EOF != (n = input.read(buffer))) {
// output.append(buffer, 0, n);
// }
// return output.toString();
// }
//
//
// }
// Path: main/java/com/viviframework/petapojo/handlers/converters/ByteArrayConverter.java
import com.viviframework.petapojo.tools.IOUtils;
import java.io.InputStream;
import java.sql.Blob;
package com.viviframework.petapojo.handlers.converters;
/**
* byte[] 类型转换器
*/
public class ByteArrayConverter implements Converter<byte[]> {
@Override
public byte[] convert(Object val) throws ConvertException {
if (val == null) {
return null;
}
if (val instanceof Blob) {
Blob b = (Blob) val;
InputStream stream = null;
try {
try {
stream = b.getBinaryStream(); | return IOUtils.toByteArray(stream); |
gejinlove/petapojo | main/java/com/viviframework/petapojo/pojo/PojoColumn.java | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Convert.java
// public class Convert {
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static volatile EnumConverterFactory registeredEnumConverterFactory = new DefaultEnumConverterFactory();
// private static Map<Class<?>, Converter<?>> registeredConverters = new HashMap<Class<?>, Converter<?>>();
//
// static {
// fillDefaults(registeredConverters);
// }
//
// public static <T> Converter<T> throwIfNull(Class<T> clazz, Converter<T> converter) throws ConvertException {
// if (converter == null)
// throw new ConvertException("Cannot find converter:" + clazz.getName());
//
// return converter;
// }
//
// public static <T> Converter<T> getConverterIfExists(Class<T> clazz) {
// Converter c;
// rl.lock();
// try {
// c = registeredConverters.get(clazz);
// } finally {
// rl.unlock();
// }
//
// if (c != null) {
// return c;
// }
//
// if (clazz.isEnum()) {
// return registeredEnumConverterFactory.newConverter((Class) clazz);
// }
//
// return null;
// }
//
// private static void fillDefaults(Map<Class<?>, Converter<?>> mapToFill) {
// mapToFill.put(Integer.class, new IntegerConverter(false));
// mapToFill.put(int.class, new IntegerConverter(true));
//
// mapToFill.put(Byte.class, new ByteConverter(false));
// mapToFill.put(byte.class, new ByteConverter(true));
//
// mapToFill.put(Short.class, new ShortConverter(false));
// mapToFill.put(short.class, new ShortConverter(true));
//
// mapToFill.put(Long.class, new LongConverter(false));
// mapToFill.put(long.class, new LongConverter(true));
//
// mapToFill.put(Float.class, new FloatConverter(false));
// mapToFill.put(float.class, new FloatConverter(true));
//
// mapToFill.put(Double.class, new DoubleConverter(false));
// mapToFill.put(double.class, new DoubleConverter(true));
//
// mapToFill.put(Boolean.class, new BooleanConverter());
// mapToFill.put(boolean.class, new BooleanConverter());
//
// mapToFill.put(BigDecimal.class, new BigDecimalConverter());
//
// mapToFill.put(String.class, new StringConverter());
//
// mapToFill.put(UUID.class, new UUIDConverter());
//
// mapToFill.put(byte[].class, new ByteArrayConverter());
//
// InputStreamConverter inputStreamConverter = new InputStreamConverter();
// mapToFill.put(InputStream.class, inputStreamConverter);
// mapToFill.put(ByteArrayInputStream.class, inputStreamConverter);
//
// mapToFill.put(java.util.Date.class, DateConverter.instance);
// mapToFill.put(Date.class, new AbstractDateConverter<Date>(Date.class) {
// @Override
// protected Date fromMilliseconds(long time) {
// return new Date(time);
// }
// });
// mapToFill.put(java.sql.Time.class, new AbstractDateConverter<java.sql.Time>(java.sql.Time.class) {
// @Override
// protected java.sql.Time fromMilliseconds(long time) {
// return new java.sql.Time(time);
// }
// });
// mapToFill.put(java.sql.Timestamp.class, new AbstractDateConverter<java.sql.Timestamp>(java.sql.Timestamp.class) {
// @Override
// protected java.sql.Timestamp fromMilliseconds(long time) {
// return new java.sql.Timestamp(time);
// }
// });
// if (FeatureDetector.isJodaTimeAvailable()) {
// mapToFill.put(DateTime.class, new DateTimeConverter());
// mapToFill.put(LocalTime.class, new LocalTimeConverter());
// }
//
// }
//
//
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
| import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.handlers.converters.Convert;
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.lang.reflect.Field; | package com.viviframework.petapojo.pojo;
public class PojoColumn {
private String columnName;
private Field field;
| // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Convert.java
// public class Convert {
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static volatile EnumConverterFactory registeredEnumConverterFactory = new DefaultEnumConverterFactory();
// private static Map<Class<?>, Converter<?>> registeredConverters = new HashMap<Class<?>, Converter<?>>();
//
// static {
// fillDefaults(registeredConverters);
// }
//
// public static <T> Converter<T> throwIfNull(Class<T> clazz, Converter<T> converter) throws ConvertException {
// if (converter == null)
// throw new ConvertException("Cannot find converter:" + clazz.getName());
//
// return converter;
// }
//
// public static <T> Converter<T> getConverterIfExists(Class<T> clazz) {
// Converter c;
// rl.lock();
// try {
// c = registeredConverters.get(clazz);
// } finally {
// rl.unlock();
// }
//
// if (c != null) {
// return c;
// }
//
// if (clazz.isEnum()) {
// return registeredEnumConverterFactory.newConverter((Class) clazz);
// }
//
// return null;
// }
//
// private static void fillDefaults(Map<Class<?>, Converter<?>> mapToFill) {
// mapToFill.put(Integer.class, new IntegerConverter(false));
// mapToFill.put(int.class, new IntegerConverter(true));
//
// mapToFill.put(Byte.class, new ByteConverter(false));
// mapToFill.put(byte.class, new ByteConverter(true));
//
// mapToFill.put(Short.class, new ShortConverter(false));
// mapToFill.put(short.class, new ShortConverter(true));
//
// mapToFill.put(Long.class, new LongConverter(false));
// mapToFill.put(long.class, new LongConverter(true));
//
// mapToFill.put(Float.class, new FloatConverter(false));
// mapToFill.put(float.class, new FloatConverter(true));
//
// mapToFill.put(Double.class, new DoubleConverter(false));
// mapToFill.put(double.class, new DoubleConverter(true));
//
// mapToFill.put(Boolean.class, new BooleanConverter());
// mapToFill.put(boolean.class, new BooleanConverter());
//
// mapToFill.put(BigDecimal.class, new BigDecimalConverter());
//
// mapToFill.put(String.class, new StringConverter());
//
// mapToFill.put(UUID.class, new UUIDConverter());
//
// mapToFill.put(byte[].class, new ByteArrayConverter());
//
// InputStreamConverter inputStreamConverter = new InputStreamConverter();
// mapToFill.put(InputStream.class, inputStreamConverter);
// mapToFill.put(ByteArrayInputStream.class, inputStreamConverter);
//
// mapToFill.put(java.util.Date.class, DateConverter.instance);
// mapToFill.put(Date.class, new AbstractDateConverter<Date>(Date.class) {
// @Override
// protected Date fromMilliseconds(long time) {
// return new Date(time);
// }
// });
// mapToFill.put(java.sql.Time.class, new AbstractDateConverter<java.sql.Time>(java.sql.Time.class) {
// @Override
// protected java.sql.Time fromMilliseconds(long time) {
// return new java.sql.Time(time);
// }
// });
// mapToFill.put(java.sql.Timestamp.class, new AbstractDateConverter<java.sql.Timestamp>(java.sql.Timestamp.class) {
// @Override
// protected java.sql.Timestamp fromMilliseconds(long time) {
// return new java.sql.Timestamp(time);
// }
// });
// if (FeatureDetector.isJodaTimeAvailable()) {
// mapToFill.put(DateTime.class, new DateTimeConverter());
// mapToFill.put(LocalTime.class, new LocalTimeConverter());
// }
//
// }
//
//
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
// Path: main/java/com/viviframework/petapojo/pojo/PojoColumn.java
import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.handlers.converters.Convert;
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.lang.reflect.Field;
package com.viviframework.petapojo.pojo;
public class PojoColumn {
private String columnName;
private Field field;
| public void setValue(Object target, Object val) throws ConvertException { |
gejinlove/petapojo | main/java/com/viviframework/petapojo/pojo/PojoColumn.java | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Convert.java
// public class Convert {
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static volatile EnumConverterFactory registeredEnumConverterFactory = new DefaultEnumConverterFactory();
// private static Map<Class<?>, Converter<?>> registeredConverters = new HashMap<Class<?>, Converter<?>>();
//
// static {
// fillDefaults(registeredConverters);
// }
//
// public static <T> Converter<T> throwIfNull(Class<T> clazz, Converter<T> converter) throws ConvertException {
// if (converter == null)
// throw new ConvertException("Cannot find converter:" + clazz.getName());
//
// return converter;
// }
//
// public static <T> Converter<T> getConverterIfExists(Class<T> clazz) {
// Converter c;
// rl.lock();
// try {
// c = registeredConverters.get(clazz);
// } finally {
// rl.unlock();
// }
//
// if (c != null) {
// return c;
// }
//
// if (clazz.isEnum()) {
// return registeredEnumConverterFactory.newConverter((Class) clazz);
// }
//
// return null;
// }
//
// private static void fillDefaults(Map<Class<?>, Converter<?>> mapToFill) {
// mapToFill.put(Integer.class, new IntegerConverter(false));
// mapToFill.put(int.class, new IntegerConverter(true));
//
// mapToFill.put(Byte.class, new ByteConverter(false));
// mapToFill.put(byte.class, new ByteConverter(true));
//
// mapToFill.put(Short.class, new ShortConverter(false));
// mapToFill.put(short.class, new ShortConverter(true));
//
// mapToFill.put(Long.class, new LongConverter(false));
// mapToFill.put(long.class, new LongConverter(true));
//
// mapToFill.put(Float.class, new FloatConverter(false));
// mapToFill.put(float.class, new FloatConverter(true));
//
// mapToFill.put(Double.class, new DoubleConverter(false));
// mapToFill.put(double.class, new DoubleConverter(true));
//
// mapToFill.put(Boolean.class, new BooleanConverter());
// mapToFill.put(boolean.class, new BooleanConverter());
//
// mapToFill.put(BigDecimal.class, new BigDecimalConverter());
//
// mapToFill.put(String.class, new StringConverter());
//
// mapToFill.put(UUID.class, new UUIDConverter());
//
// mapToFill.put(byte[].class, new ByteArrayConverter());
//
// InputStreamConverter inputStreamConverter = new InputStreamConverter();
// mapToFill.put(InputStream.class, inputStreamConverter);
// mapToFill.put(ByteArrayInputStream.class, inputStreamConverter);
//
// mapToFill.put(java.util.Date.class, DateConverter.instance);
// mapToFill.put(Date.class, new AbstractDateConverter<Date>(Date.class) {
// @Override
// protected Date fromMilliseconds(long time) {
// return new Date(time);
// }
// });
// mapToFill.put(java.sql.Time.class, new AbstractDateConverter<java.sql.Time>(java.sql.Time.class) {
// @Override
// protected java.sql.Time fromMilliseconds(long time) {
// return new java.sql.Time(time);
// }
// });
// mapToFill.put(java.sql.Timestamp.class, new AbstractDateConverter<java.sql.Timestamp>(java.sql.Timestamp.class) {
// @Override
// protected java.sql.Timestamp fromMilliseconds(long time) {
// return new java.sql.Timestamp(time);
// }
// });
// if (FeatureDetector.isJodaTimeAvailable()) {
// mapToFill.put(DateTime.class, new DateTimeConverter());
// mapToFill.put(LocalTime.class, new LocalTimeConverter());
// }
//
// }
//
//
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
| import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.handlers.converters.Convert;
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.lang.reflect.Field; | package com.viviframework.petapojo.pojo;
public class PojoColumn {
private String columnName;
private Field field;
public void setValue(Object target, Object val) throws ConvertException {
BeanWrapper bw = new BeanWrapperImpl(target); | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Convert.java
// public class Convert {
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static volatile EnumConverterFactory registeredEnumConverterFactory = new DefaultEnumConverterFactory();
// private static Map<Class<?>, Converter<?>> registeredConverters = new HashMap<Class<?>, Converter<?>>();
//
// static {
// fillDefaults(registeredConverters);
// }
//
// public static <T> Converter<T> throwIfNull(Class<T> clazz, Converter<T> converter) throws ConvertException {
// if (converter == null)
// throw new ConvertException("Cannot find converter:" + clazz.getName());
//
// return converter;
// }
//
// public static <T> Converter<T> getConverterIfExists(Class<T> clazz) {
// Converter c;
// rl.lock();
// try {
// c = registeredConverters.get(clazz);
// } finally {
// rl.unlock();
// }
//
// if (c != null) {
// return c;
// }
//
// if (clazz.isEnum()) {
// return registeredEnumConverterFactory.newConverter((Class) clazz);
// }
//
// return null;
// }
//
// private static void fillDefaults(Map<Class<?>, Converter<?>> mapToFill) {
// mapToFill.put(Integer.class, new IntegerConverter(false));
// mapToFill.put(int.class, new IntegerConverter(true));
//
// mapToFill.put(Byte.class, new ByteConverter(false));
// mapToFill.put(byte.class, new ByteConverter(true));
//
// mapToFill.put(Short.class, new ShortConverter(false));
// mapToFill.put(short.class, new ShortConverter(true));
//
// mapToFill.put(Long.class, new LongConverter(false));
// mapToFill.put(long.class, new LongConverter(true));
//
// mapToFill.put(Float.class, new FloatConverter(false));
// mapToFill.put(float.class, new FloatConverter(true));
//
// mapToFill.put(Double.class, new DoubleConverter(false));
// mapToFill.put(double.class, new DoubleConverter(true));
//
// mapToFill.put(Boolean.class, new BooleanConverter());
// mapToFill.put(boolean.class, new BooleanConverter());
//
// mapToFill.put(BigDecimal.class, new BigDecimalConverter());
//
// mapToFill.put(String.class, new StringConverter());
//
// mapToFill.put(UUID.class, new UUIDConverter());
//
// mapToFill.put(byte[].class, new ByteArrayConverter());
//
// InputStreamConverter inputStreamConverter = new InputStreamConverter();
// mapToFill.put(InputStream.class, inputStreamConverter);
// mapToFill.put(ByteArrayInputStream.class, inputStreamConverter);
//
// mapToFill.put(java.util.Date.class, DateConverter.instance);
// mapToFill.put(Date.class, new AbstractDateConverter<Date>(Date.class) {
// @Override
// protected Date fromMilliseconds(long time) {
// return new Date(time);
// }
// });
// mapToFill.put(java.sql.Time.class, new AbstractDateConverter<java.sql.Time>(java.sql.Time.class) {
// @Override
// protected java.sql.Time fromMilliseconds(long time) {
// return new java.sql.Time(time);
// }
// });
// mapToFill.put(java.sql.Timestamp.class, new AbstractDateConverter<java.sql.Timestamp>(java.sql.Timestamp.class) {
// @Override
// protected java.sql.Timestamp fromMilliseconds(long time) {
// return new java.sql.Timestamp(time);
// }
// });
// if (FeatureDetector.isJodaTimeAvailable()) {
// mapToFill.put(DateTime.class, new DateTimeConverter());
// mapToFill.put(LocalTime.class, new LocalTimeConverter());
// }
//
// }
//
//
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
// Path: main/java/com/viviframework/petapojo/pojo/PojoColumn.java
import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.handlers.converters.Convert;
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.lang.reflect.Field;
package com.viviframework.petapojo.pojo;
public class PojoColumn {
private String columnName;
private Field field;
public void setValue(Object target, Object val) throws ConvertException {
BeanWrapper bw = new BeanWrapperImpl(target); | Converter converter = Convert.getConverterIfExists(field.getType()); |
gejinlove/petapojo | main/java/com/viviframework/petapojo/pojo/PojoColumn.java | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Convert.java
// public class Convert {
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static volatile EnumConverterFactory registeredEnumConverterFactory = new DefaultEnumConverterFactory();
// private static Map<Class<?>, Converter<?>> registeredConverters = new HashMap<Class<?>, Converter<?>>();
//
// static {
// fillDefaults(registeredConverters);
// }
//
// public static <T> Converter<T> throwIfNull(Class<T> clazz, Converter<T> converter) throws ConvertException {
// if (converter == null)
// throw new ConvertException("Cannot find converter:" + clazz.getName());
//
// return converter;
// }
//
// public static <T> Converter<T> getConverterIfExists(Class<T> clazz) {
// Converter c;
// rl.lock();
// try {
// c = registeredConverters.get(clazz);
// } finally {
// rl.unlock();
// }
//
// if (c != null) {
// return c;
// }
//
// if (clazz.isEnum()) {
// return registeredEnumConverterFactory.newConverter((Class) clazz);
// }
//
// return null;
// }
//
// private static void fillDefaults(Map<Class<?>, Converter<?>> mapToFill) {
// mapToFill.put(Integer.class, new IntegerConverter(false));
// mapToFill.put(int.class, new IntegerConverter(true));
//
// mapToFill.put(Byte.class, new ByteConverter(false));
// mapToFill.put(byte.class, new ByteConverter(true));
//
// mapToFill.put(Short.class, new ShortConverter(false));
// mapToFill.put(short.class, new ShortConverter(true));
//
// mapToFill.put(Long.class, new LongConverter(false));
// mapToFill.put(long.class, new LongConverter(true));
//
// mapToFill.put(Float.class, new FloatConverter(false));
// mapToFill.put(float.class, new FloatConverter(true));
//
// mapToFill.put(Double.class, new DoubleConverter(false));
// mapToFill.put(double.class, new DoubleConverter(true));
//
// mapToFill.put(Boolean.class, new BooleanConverter());
// mapToFill.put(boolean.class, new BooleanConverter());
//
// mapToFill.put(BigDecimal.class, new BigDecimalConverter());
//
// mapToFill.put(String.class, new StringConverter());
//
// mapToFill.put(UUID.class, new UUIDConverter());
//
// mapToFill.put(byte[].class, new ByteArrayConverter());
//
// InputStreamConverter inputStreamConverter = new InputStreamConverter();
// mapToFill.put(InputStream.class, inputStreamConverter);
// mapToFill.put(ByteArrayInputStream.class, inputStreamConverter);
//
// mapToFill.put(java.util.Date.class, DateConverter.instance);
// mapToFill.put(Date.class, new AbstractDateConverter<Date>(Date.class) {
// @Override
// protected Date fromMilliseconds(long time) {
// return new Date(time);
// }
// });
// mapToFill.put(java.sql.Time.class, new AbstractDateConverter<java.sql.Time>(java.sql.Time.class) {
// @Override
// protected java.sql.Time fromMilliseconds(long time) {
// return new java.sql.Time(time);
// }
// });
// mapToFill.put(java.sql.Timestamp.class, new AbstractDateConverter<java.sql.Timestamp>(java.sql.Timestamp.class) {
// @Override
// protected java.sql.Timestamp fromMilliseconds(long time) {
// return new java.sql.Timestamp(time);
// }
// });
// if (FeatureDetector.isJodaTimeAvailable()) {
// mapToFill.put(DateTime.class, new DateTimeConverter());
// mapToFill.put(LocalTime.class, new LocalTimeConverter());
// }
//
// }
//
//
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
| import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.handlers.converters.Convert;
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.lang.reflect.Field; | package com.viviframework.petapojo.pojo;
public class PojoColumn {
private String columnName;
private Field field;
public void setValue(Object target, Object val) throws ConvertException {
BeanWrapper bw = new BeanWrapperImpl(target); | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Convert.java
// public class Convert {
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static volatile EnumConverterFactory registeredEnumConverterFactory = new DefaultEnumConverterFactory();
// private static Map<Class<?>, Converter<?>> registeredConverters = new HashMap<Class<?>, Converter<?>>();
//
// static {
// fillDefaults(registeredConverters);
// }
//
// public static <T> Converter<T> throwIfNull(Class<T> clazz, Converter<T> converter) throws ConvertException {
// if (converter == null)
// throw new ConvertException("Cannot find converter:" + clazz.getName());
//
// return converter;
// }
//
// public static <T> Converter<T> getConverterIfExists(Class<T> clazz) {
// Converter c;
// rl.lock();
// try {
// c = registeredConverters.get(clazz);
// } finally {
// rl.unlock();
// }
//
// if (c != null) {
// return c;
// }
//
// if (clazz.isEnum()) {
// return registeredEnumConverterFactory.newConverter((Class) clazz);
// }
//
// return null;
// }
//
// private static void fillDefaults(Map<Class<?>, Converter<?>> mapToFill) {
// mapToFill.put(Integer.class, new IntegerConverter(false));
// mapToFill.put(int.class, new IntegerConverter(true));
//
// mapToFill.put(Byte.class, new ByteConverter(false));
// mapToFill.put(byte.class, new ByteConverter(true));
//
// mapToFill.put(Short.class, new ShortConverter(false));
// mapToFill.put(short.class, new ShortConverter(true));
//
// mapToFill.put(Long.class, new LongConverter(false));
// mapToFill.put(long.class, new LongConverter(true));
//
// mapToFill.put(Float.class, new FloatConverter(false));
// mapToFill.put(float.class, new FloatConverter(true));
//
// mapToFill.put(Double.class, new DoubleConverter(false));
// mapToFill.put(double.class, new DoubleConverter(true));
//
// mapToFill.put(Boolean.class, new BooleanConverter());
// mapToFill.put(boolean.class, new BooleanConverter());
//
// mapToFill.put(BigDecimal.class, new BigDecimalConverter());
//
// mapToFill.put(String.class, new StringConverter());
//
// mapToFill.put(UUID.class, new UUIDConverter());
//
// mapToFill.put(byte[].class, new ByteArrayConverter());
//
// InputStreamConverter inputStreamConverter = new InputStreamConverter();
// mapToFill.put(InputStream.class, inputStreamConverter);
// mapToFill.put(ByteArrayInputStream.class, inputStreamConverter);
//
// mapToFill.put(java.util.Date.class, DateConverter.instance);
// mapToFill.put(Date.class, new AbstractDateConverter<Date>(Date.class) {
// @Override
// protected Date fromMilliseconds(long time) {
// return new Date(time);
// }
// });
// mapToFill.put(java.sql.Time.class, new AbstractDateConverter<java.sql.Time>(java.sql.Time.class) {
// @Override
// protected java.sql.Time fromMilliseconds(long time) {
// return new java.sql.Time(time);
// }
// });
// mapToFill.put(java.sql.Timestamp.class, new AbstractDateConverter<java.sql.Timestamp>(java.sql.Timestamp.class) {
// @Override
// protected java.sql.Timestamp fromMilliseconds(long time) {
// return new java.sql.Timestamp(time);
// }
// });
// if (FeatureDetector.isJodaTimeAvailable()) {
// mapToFill.put(DateTime.class, new DateTimeConverter());
// mapToFill.put(LocalTime.class, new LocalTimeConverter());
// }
//
// }
//
//
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
// Path: main/java/com/viviframework/petapojo/pojo/PojoColumn.java
import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.handlers.converters.Convert;
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.lang.reflect.Field;
package com.viviframework.petapojo.pojo;
public class PojoColumn {
private String columnName;
private Field field;
public void setValue(Object target, Object val) throws ConvertException {
BeanWrapper bw = new BeanWrapperImpl(target); | Converter converter = Convert.getConverterIfExists(field.getType()); |
gejinlove/petapojo | main/java/com/viviframework/petapojo/pojo/PojoColumn.java | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Convert.java
// public class Convert {
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static volatile EnumConverterFactory registeredEnumConverterFactory = new DefaultEnumConverterFactory();
// private static Map<Class<?>, Converter<?>> registeredConverters = new HashMap<Class<?>, Converter<?>>();
//
// static {
// fillDefaults(registeredConverters);
// }
//
// public static <T> Converter<T> throwIfNull(Class<T> clazz, Converter<T> converter) throws ConvertException {
// if (converter == null)
// throw new ConvertException("Cannot find converter:" + clazz.getName());
//
// return converter;
// }
//
// public static <T> Converter<T> getConverterIfExists(Class<T> clazz) {
// Converter c;
// rl.lock();
// try {
// c = registeredConverters.get(clazz);
// } finally {
// rl.unlock();
// }
//
// if (c != null) {
// return c;
// }
//
// if (clazz.isEnum()) {
// return registeredEnumConverterFactory.newConverter((Class) clazz);
// }
//
// return null;
// }
//
// private static void fillDefaults(Map<Class<?>, Converter<?>> mapToFill) {
// mapToFill.put(Integer.class, new IntegerConverter(false));
// mapToFill.put(int.class, new IntegerConverter(true));
//
// mapToFill.put(Byte.class, new ByteConverter(false));
// mapToFill.put(byte.class, new ByteConverter(true));
//
// mapToFill.put(Short.class, new ShortConverter(false));
// mapToFill.put(short.class, new ShortConverter(true));
//
// mapToFill.put(Long.class, new LongConverter(false));
// mapToFill.put(long.class, new LongConverter(true));
//
// mapToFill.put(Float.class, new FloatConverter(false));
// mapToFill.put(float.class, new FloatConverter(true));
//
// mapToFill.put(Double.class, new DoubleConverter(false));
// mapToFill.put(double.class, new DoubleConverter(true));
//
// mapToFill.put(Boolean.class, new BooleanConverter());
// mapToFill.put(boolean.class, new BooleanConverter());
//
// mapToFill.put(BigDecimal.class, new BigDecimalConverter());
//
// mapToFill.put(String.class, new StringConverter());
//
// mapToFill.put(UUID.class, new UUIDConverter());
//
// mapToFill.put(byte[].class, new ByteArrayConverter());
//
// InputStreamConverter inputStreamConverter = new InputStreamConverter();
// mapToFill.put(InputStream.class, inputStreamConverter);
// mapToFill.put(ByteArrayInputStream.class, inputStreamConverter);
//
// mapToFill.put(java.util.Date.class, DateConverter.instance);
// mapToFill.put(Date.class, new AbstractDateConverter<Date>(Date.class) {
// @Override
// protected Date fromMilliseconds(long time) {
// return new Date(time);
// }
// });
// mapToFill.put(java.sql.Time.class, new AbstractDateConverter<java.sql.Time>(java.sql.Time.class) {
// @Override
// protected java.sql.Time fromMilliseconds(long time) {
// return new java.sql.Time(time);
// }
// });
// mapToFill.put(java.sql.Timestamp.class, new AbstractDateConverter<java.sql.Timestamp>(java.sql.Timestamp.class) {
// @Override
// protected java.sql.Timestamp fromMilliseconds(long time) {
// return new java.sql.Timestamp(time);
// }
// });
// if (FeatureDetector.isJodaTimeAvailable()) {
// mapToFill.put(DateTime.class, new DateTimeConverter());
// mapToFill.put(LocalTime.class, new LocalTimeConverter());
// }
//
// }
//
//
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
| import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.handlers.converters.Convert;
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.lang.reflect.Field; | package com.viviframework.petapojo.pojo;
public class PojoColumn {
private String columnName;
private Field field;
public void setValue(Object target, Object val) throws ConvertException {
BeanWrapper bw = new BeanWrapperImpl(target);
Converter converter = Convert.getConverterIfExists(field.getType());
bw.setPropertyValue(field.getName(), converter.convert(val));
}
public Object getValue(Object target) {
BeanWrapper bw = new BeanWrapperImpl(target);
Object object = bw.getPropertyValue(field.getName());
if(object == null)
return null;
boolean isEnum = object.getClass().isEnum(); | // Path: main/java/com/viviframework/petapojo/enums/IEnumMessage.java
// public interface IEnumMessage {
//
// int getValue();
//
// String getName();
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Convert.java
// public class Convert {
// private static final ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
// private static final ReentrantReadWriteLock.ReadLock rl = rrwl.readLock();
// private static final ReentrantReadWriteLock.WriteLock wl = rrwl.writeLock();
// private static volatile EnumConverterFactory registeredEnumConverterFactory = new DefaultEnumConverterFactory();
// private static Map<Class<?>, Converter<?>> registeredConverters = new HashMap<Class<?>, Converter<?>>();
//
// static {
// fillDefaults(registeredConverters);
// }
//
// public static <T> Converter<T> throwIfNull(Class<T> clazz, Converter<T> converter) throws ConvertException {
// if (converter == null)
// throw new ConvertException("Cannot find converter:" + clazz.getName());
//
// return converter;
// }
//
// public static <T> Converter<T> getConverterIfExists(Class<T> clazz) {
// Converter c;
// rl.lock();
// try {
// c = registeredConverters.get(clazz);
// } finally {
// rl.unlock();
// }
//
// if (c != null) {
// return c;
// }
//
// if (clazz.isEnum()) {
// return registeredEnumConverterFactory.newConverter((Class) clazz);
// }
//
// return null;
// }
//
// private static void fillDefaults(Map<Class<?>, Converter<?>> mapToFill) {
// mapToFill.put(Integer.class, new IntegerConverter(false));
// mapToFill.put(int.class, new IntegerConverter(true));
//
// mapToFill.put(Byte.class, new ByteConverter(false));
// mapToFill.put(byte.class, new ByteConverter(true));
//
// mapToFill.put(Short.class, new ShortConverter(false));
// mapToFill.put(short.class, new ShortConverter(true));
//
// mapToFill.put(Long.class, new LongConverter(false));
// mapToFill.put(long.class, new LongConverter(true));
//
// mapToFill.put(Float.class, new FloatConverter(false));
// mapToFill.put(float.class, new FloatConverter(true));
//
// mapToFill.put(Double.class, new DoubleConverter(false));
// mapToFill.put(double.class, new DoubleConverter(true));
//
// mapToFill.put(Boolean.class, new BooleanConverter());
// mapToFill.put(boolean.class, new BooleanConverter());
//
// mapToFill.put(BigDecimal.class, new BigDecimalConverter());
//
// mapToFill.put(String.class, new StringConverter());
//
// mapToFill.put(UUID.class, new UUIDConverter());
//
// mapToFill.put(byte[].class, new ByteArrayConverter());
//
// InputStreamConverter inputStreamConverter = new InputStreamConverter();
// mapToFill.put(InputStream.class, inputStreamConverter);
// mapToFill.put(ByteArrayInputStream.class, inputStreamConverter);
//
// mapToFill.put(java.util.Date.class, DateConverter.instance);
// mapToFill.put(Date.class, new AbstractDateConverter<Date>(Date.class) {
// @Override
// protected Date fromMilliseconds(long time) {
// return new Date(time);
// }
// });
// mapToFill.put(java.sql.Time.class, new AbstractDateConverter<java.sql.Time>(java.sql.Time.class) {
// @Override
// protected java.sql.Time fromMilliseconds(long time) {
// return new java.sql.Time(time);
// }
// });
// mapToFill.put(java.sql.Timestamp.class, new AbstractDateConverter<java.sql.Timestamp>(java.sql.Timestamp.class) {
// @Override
// protected java.sql.Timestamp fromMilliseconds(long time) {
// return new java.sql.Timestamp(time);
// }
// });
// if (FeatureDetector.isJodaTimeAvailable()) {
// mapToFill.put(DateTime.class, new DateTimeConverter());
// mapToFill.put(LocalTime.class, new LocalTimeConverter());
// }
//
// }
//
//
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
// Path: main/java/com/viviframework/petapojo/pojo/PojoColumn.java
import com.viviframework.petapojo.enums.IEnumMessage;
import com.viviframework.petapojo.handlers.converters.Convert;
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.lang.reflect.Field;
package com.viviframework.petapojo.pojo;
public class PojoColumn {
private String columnName;
private Field field;
public void setValue(Object target, Object val) throws ConvertException {
BeanWrapper bw = new BeanWrapperImpl(target);
Converter converter = Convert.getConverterIfExists(field.getType());
bw.setPropertyValue(field.getName(), converter.convert(val));
}
public Object getValue(Object target) {
BeanWrapper bw = new BeanWrapperImpl(target);
Object object = bw.getPropertyValue(field.getName());
if(object == null)
return null;
boolean isEnum = object.getClass().isEnum(); | if (object.getClass().isEnum() && IEnumMessage.class.isAssignableFrom(object.getClass())) { |
gejinlove/petapojo | main/java/com/viviframework/petapojo/handlers/converters/dates/AbstractDateConverter.java | // Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
| import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import java.util.Date; | package com.viviframework.petapojo.handlers.converters.dates;
/**
* 时间转换器基类
*/
public abstract class AbstractDateConverter<T extends Date> implements Converter<T> {
private final Class<T> classOfDate;
protected AbstractDateConverter(Class<T> classOfDate) {
this.classOfDate = classOfDate;
}
| // Path: main/java/com/viviframework/petapojo/handlers/converters/ConvertException.java
// public class ConvertException extends Exception {
//
// public ConvertException(String message) {
// super(message);
// }
//
// public ConvertException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: main/java/com/viviframework/petapojo/handlers/converters/Converter.java
// public interface Converter<T> {
//
// T convert(Object val) throws ConvertException;
// }
// Path: main/java/com/viviframework/petapojo/handlers/converters/dates/AbstractDateConverter.java
import com.viviframework.petapojo.handlers.converters.ConvertException;
import com.viviframework.petapojo.handlers.converters.Converter;
import java.util.Date;
package com.viviframework.petapojo.handlers.converters.dates;
/**
* 时间转换器基类
*/
public abstract class AbstractDateConverter<T extends Date> implements Converter<T> {
private final Class<T> classOfDate;
protected AbstractDateConverter(Class<T> classOfDate) {
this.classOfDate = classOfDate;
}
| public T convert(Object val) throws ConvertException { |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/GDCU.java | // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryAlarmListener.java
// public class GalleryAlarmListener implements AlarmListener {
//
// @Override
// public void scheduleAlarms(AlarmManager mgr, PendingIntent pendingIntent, Context context) {
// info("Starting alarm with update interval of " + AlarmManager.INTERVAL_HOUR);
// mgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
// SystemClock.elapsedRealtime() + 60000, AlarmManager.INTERVAL_HOUR, pendingIntent);
// }
//
// @Override
// public void sendWakefulWork(Context context) {
// info("Waking up the media service");
// Intent service = new Intent(context, MediaService.class);
// service.setAction(MediaService.NO_WAIT);
// context.startService(service);
// }
//
// /*
// * If the service hasn't been triggered in 12 hours assume it has been
// * killed (non-Javadoc)
// *
// * @see
// * com.commonsware.cwac.wakeful.WakefulIntentService.AlarmListener#getMaxAge
// * ()
// */
// @Override
// public long getMaxAge() {
// return Math.round(AlarmManager.INTERVAL_HALF_DAY);
// }
//
// private void info(String msg) {
// Log.v("GDCU::GalleryAlarmListener", msg);
// }
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryObserver.java
// public class GalleryObserver extends ContentObserver {
//
// private Context context;
// private Uri BASE_URI;
//
// public GalleryObserver(Context context, Uri base) {
// super(null);
// this.context = context;
// this.BASE_URI = base;
// }
//
// @Override
// public void onChange(boolean selfChange) {
// super.onChange(selfChange);
// Media media = readFromMediaStore(context, BASE_URI);
// if (media == null) {
// log("Media returned from database was null");
// return;
// }
//
// Intent service = new Intent(context, MediaService.class);
// context.startService(service);
// }
//
// private static final String[] projection = { MediaColumns.DATA, MediaColumns.MIME_TYPE };
// private static final String sortorder = MediaColumns.DATE_ADDED + " DESC LIMIT 1";
//
// private Media readFromMediaStore(Context context, Uri uri) {
// Cursor cursor = context.getContentResolver().query(uri, projection, null, null, sortorder);
// Media media = null;
// if (cursor.moveToNext()) {
// int dataColumn = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
// String filePath = cursor.getString(dataColumn);
// int mimeTypeColumn = cursor.getColumnIndexOrThrow(MediaColumns.MIME_TYPE);
// String mimeType = cursor.getString(mimeTypeColumn);
// media = new Media(new File(filePath), mimeType);
// }
// cursor.close();
// return media;
// }
//
// private void log(String msg) {
// Log.v("GDCU::GalleryObserver", msg);
// }
//
// }
| import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.provider.MediaStore;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.crittercism.app.Crittercism;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.service.GalleryAlarmListener;
import com.darrenmowat.gdcu.service.GalleryObserver;
import com.flurry.android.FlurryAgent;
import com.google.api.services.drive.model.File; | package com.darrenmowat.gdcu;
public class GDCU extends Application {
public static final boolean DEVEL_BUILD = true;
public static final String APP_NAME = "PicSync Beta";
public static int VERSION;
public static String VERSION_STRING;
public static final String BUILD_TYPE = DEVEL_BUILD ? "Development Build" : "Beta Build";
public static String PRETTY_BUILD_STRING;
public static final String FEEDBACK_EMAIL = "dmowat91@gmail.com";
| // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryAlarmListener.java
// public class GalleryAlarmListener implements AlarmListener {
//
// @Override
// public void scheduleAlarms(AlarmManager mgr, PendingIntent pendingIntent, Context context) {
// info("Starting alarm with update interval of " + AlarmManager.INTERVAL_HOUR);
// mgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
// SystemClock.elapsedRealtime() + 60000, AlarmManager.INTERVAL_HOUR, pendingIntent);
// }
//
// @Override
// public void sendWakefulWork(Context context) {
// info("Waking up the media service");
// Intent service = new Intent(context, MediaService.class);
// service.setAction(MediaService.NO_WAIT);
// context.startService(service);
// }
//
// /*
// * If the service hasn't been triggered in 12 hours assume it has been
// * killed (non-Javadoc)
// *
// * @see
// * com.commonsware.cwac.wakeful.WakefulIntentService.AlarmListener#getMaxAge
// * ()
// */
// @Override
// public long getMaxAge() {
// return Math.round(AlarmManager.INTERVAL_HALF_DAY);
// }
//
// private void info(String msg) {
// Log.v("GDCU::GalleryAlarmListener", msg);
// }
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryObserver.java
// public class GalleryObserver extends ContentObserver {
//
// private Context context;
// private Uri BASE_URI;
//
// public GalleryObserver(Context context, Uri base) {
// super(null);
// this.context = context;
// this.BASE_URI = base;
// }
//
// @Override
// public void onChange(boolean selfChange) {
// super.onChange(selfChange);
// Media media = readFromMediaStore(context, BASE_URI);
// if (media == null) {
// log("Media returned from database was null");
// return;
// }
//
// Intent service = new Intent(context, MediaService.class);
// context.startService(service);
// }
//
// private static final String[] projection = { MediaColumns.DATA, MediaColumns.MIME_TYPE };
// private static final String sortorder = MediaColumns.DATE_ADDED + " DESC LIMIT 1";
//
// private Media readFromMediaStore(Context context, Uri uri) {
// Cursor cursor = context.getContentResolver().query(uri, projection, null, null, sortorder);
// Media media = null;
// if (cursor.moveToNext()) {
// int dataColumn = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
// String filePath = cursor.getString(dataColumn);
// int mimeTypeColumn = cursor.getColumnIndexOrThrow(MediaColumns.MIME_TYPE);
// String mimeType = cursor.getString(mimeTypeColumn);
// media = new Media(new File(filePath), mimeType);
// }
// cursor.close();
// return media;
// }
//
// private void log(String msg) {
// Log.v("GDCU::GalleryObserver", msg);
// }
//
// }
// Path: src/com/darrenmowat/gdcu/GDCU.java
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.provider.MediaStore;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.crittercism.app.Crittercism;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.service.GalleryAlarmListener;
import com.darrenmowat.gdcu.service.GalleryObserver;
import com.flurry.android.FlurryAgent;
import com.google.api.services.drive.model.File;
package com.darrenmowat.gdcu;
public class GDCU extends Application {
public static final boolean DEVEL_BUILD = true;
public static final String APP_NAME = "PicSync Beta";
public static int VERSION;
public static String VERSION_STRING;
public static final String BUILD_TYPE = DEVEL_BUILD ? "Development Build" : "Beta Build";
public static String PRETTY_BUILD_STRING;
public static final String FEEDBACK_EMAIL = "dmowat91@gmail.com";
| private GalleryObserver photoObserver; |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/GDCU.java | // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryAlarmListener.java
// public class GalleryAlarmListener implements AlarmListener {
//
// @Override
// public void scheduleAlarms(AlarmManager mgr, PendingIntent pendingIntent, Context context) {
// info("Starting alarm with update interval of " + AlarmManager.INTERVAL_HOUR);
// mgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
// SystemClock.elapsedRealtime() + 60000, AlarmManager.INTERVAL_HOUR, pendingIntent);
// }
//
// @Override
// public void sendWakefulWork(Context context) {
// info("Waking up the media service");
// Intent service = new Intent(context, MediaService.class);
// service.setAction(MediaService.NO_WAIT);
// context.startService(service);
// }
//
// /*
// * If the service hasn't been triggered in 12 hours assume it has been
// * killed (non-Javadoc)
// *
// * @see
// * com.commonsware.cwac.wakeful.WakefulIntentService.AlarmListener#getMaxAge
// * ()
// */
// @Override
// public long getMaxAge() {
// return Math.round(AlarmManager.INTERVAL_HALF_DAY);
// }
//
// private void info(String msg) {
// Log.v("GDCU::GalleryAlarmListener", msg);
// }
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryObserver.java
// public class GalleryObserver extends ContentObserver {
//
// private Context context;
// private Uri BASE_URI;
//
// public GalleryObserver(Context context, Uri base) {
// super(null);
// this.context = context;
// this.BASE_URI = base;
// }
//
// @Override
// public void onChange(boolean selfChange) {
// super.onChange(selfChange);
// Media media = readFromMediaStore(context, BASE_URI);
// if (media == null) {
// log("Media returned from database was null");
// return;
// }
//
// Intent service = new Intent(context, MediaService.class);
// context.startService(service);
// }
//
// private static final String[] projection = { MediaColumns.DATA, MediaColumns.MIME_TYPE };
// private static final String sortorder = MediaColumns.DATE_ADDED + " DESC LIMIT 1";
//
// private Media readFromMediaStore(Context context, Uri uri) {
// Cursor cursor = context.getContentResolver().query(uri, projection, null, null, sortorder);
// Media media = null;
// if (cursor.moveToNext()) {
// int dataColumn = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
// String filePath = cursor.getString(dataColumn);
// int mimeTypeColumn = cursor.getColumnIndexOrThrow(MediaColumns.MIME_TYPE);
// String mimeType = cursor.getString(mimeTypeColumn);
// media = new Media(new File(filePath), mimeType);
// }
// cursor.close();
// return media;
// }
//
// private void log(String msg) {
// Log.v("GDCU::GalleryObserver", msg);
// }
//
// }
| import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.provider.MediaStore;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.crittercism.app.Crittercism;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.service.GalleryAlarmListener;
import com.darrenmowat.gdcu.service.GalleryObserver;
import com.flurry.android.FlurryAgent;
import com.google.api.services.drive.model.File; | private static File uploadsDir = null;
private static String rootId = null;
private String userToken = null;
private String apiToken = null;
public static GDCU getGDCU(Context context) {
return (GDCU) context.getApplicationContext();
}
@Override
public void onCreate() {
super.onCreate();
try {
PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
VERSION = app.versionCode;
VERSION_STRING = app.versionName;
PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
} catch (NameNotFoundException e) {
// We should never be here, unless our package doesn't exist on the
// system
// But how would this be running if it didn't
}
if (!DEVEL_BUILD) {
FlurryAgent.setCaptureUncaughtExceptions(false);
Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
}
| // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryAlarmListener.java
// public class GalleryAlarmListener implements AlarmListener {
//
// @Override
// public void scheduleAlarms(AlarmManager mgr, PendingIntent pendingIntent, Context context) {
// info("Starting alarm with update interval of " + AlarmManager.INTERVAL_HOUR);
// mgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
// SystemClock.elapsedRealtime() + 60000, AlarmManager.INTERVAL_HOUR, pendingIntent);
// }
//
// @Override
// public void sendWakefulWork(Context context) {
// info("Waking up the media service");
// Intent service = new Intent(context, MediaService.class);
// service.setAction(MediaService.NO_WAIT);
// context.startService(service);
// }
//
// /*
// * If the service hasn't been triggered in 12 hours assume it has been
// * killed (non-Javadoc)
// *
// * @see
// * com.commonsware.cwac.wakeful.WakefulIntentService.AlarmListener#getMaxAge
// * ()
// */
// @Override
// public long getMaxAge() {
// return Math.round(AlarmManager.INTERVAL_HALF_DAY);
// }
//
// private void info(String msg) {
// Log.v("GDCU::GalleryAlarmListener", msg);
// }
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryObserver.java
// public class GalleryObserver extends ContentObserver {
//
// private Context context;
// private Uri BASE_URI;
//
// public GalleryObserver(Context context, Uri base) {
// super(null);
// this.context = context;
// this.BASE_URI = base;
// }
//
// @Override
// public void onChange(boolean selfChange) {
// super.onChange(selfChange);
// Media media = readFromMediaStore(context, BASE_URI);
// if (media == null) {
// log("Media returned from database was null");
// return;
// }
//
// Intent service = new Intent(context, MediaService.class);
// context.startService(service);
// }
//
// private static final String[] projection = { MediaColumns.DATA, MediaColumns.MIME_TYPE };
// private static final String sortorder = MediaColumns.DATE_ADDED + " DESC LIMIT 1";
//
// private Media readFromMediaStore(Context context, Uri uri) {
// Cursor cursor = context.getContentResolver().query(uri, projection, null, null, sortorder);
// Media media = null;
// if (cursor.moveToNext()) {
// int dataColumn = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
// String filePath = cursor.getString(dataColumn);
// int mimeTypeColumn = cursor.getColumnIndexOrThrow(MediaColumns.MIME_TYPE);
// String mimeType = cursor.getString(mimeTypeColumn);
// media = new Media(new File(filePath), mimeType);
// }
// cursor.close();
// return media;
// }
//
// private void log(String msg) {
// Log.v("GDCU::GalleryObserver", msg);
// }
//
// }
// Path: src/com/darrenmowat/gdcu/GDCU.java
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.provider.MediaStore;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.crittercism.app.Crittercism;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.service.GalleryAlarmListener;
import com.darrenmowat.gdcu.service.GalleryObserver;
import com.flurry.android.FlurryAgent;
import com.google.api.services.drive.model.File;
private static File uploadsDir = null;
private static String rootId = null;
private String userToken = null;
private String apiToken = null;
public static GDCU getGDCU(Context context) {
return (GDCU) context.getApplicationContext();
}
@Override
public void onCreate() {
super.onCreate();
try {
PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
VERSION = app.versionCode;
VERSION_STRING = app.versionName;
PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
} catch (NameNotFoundException e) {
// We should never be here, unless our package doesn't exist on the
// system
// But how would this be running if it didn't
}
if (!DEVEL_BUILD) {
FlurryAgent.setCaptureUncaughtExceptions(false);
Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
}
| DataBus.getInstance().register(this); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/GDCU.java | // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryAlarmListener.java
// public class GalleryAlarmListener implements AlarmListener {
//
// @Override
// public void scheduleAlarms(AlarmManager mgr, PendingIntent pendingIntent, Context context) {
// info("Starting alarm with update interval of " + AlarmManager.INTERVAL_HOUR);
// mgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
// SystemClock.elapsedRealtime() + 60000, AlarmManager.INTERVAL_HOUR, pendingIntent);
// }
//
// @Override
// public void sendWakefulWork(Context context) {
// info("Waking up the media service");
// Intent service = new Intent(context, MediaService.class);
// service.setAction(MediaService.NO_WAIT);
// context.startService(service);
// }
//
// /*
// * If the service hasn't been triggered in 12 hours assume it has been
// * killed (non-Javadoc)
// *
// * @see
// * com.commonsware.cwac.wakeful.WakefulIntentService.AlarmListener#getMaxAge
// * ()
// */
// @Override
// public long getMaxAge() {
// return Math.round(AlarmManager.INTERVAL_HALF_DAY);
// }
//
// private void info(String msg) {
// Log.v("GDCU::GalleryAlarmListener", msg);
// }
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryObserver.java
// public class GalleryObserver extends ContentObserver {
//
// private Context context;
// private Uri BASE_URI;
//
// public GalleryObserver(Context context, Uri base) {
// super(null);
// this.context = context;
// this.BASE_URI = base;
// }
//
// @Override
// public void onChange(boolean selfChange) {
// super.onChange(selfChange);
// Media media = readFromMediaStore(context, BASE_URI);
// if (media == null) {
// log("Media returned from database was null");
// return;
// }
//
// Intent service = new Intent(context, MediaService.class);
// context.startService(service);
// }
//
// private static final String[] projection = { MediaColumns.DATA, MediaColumns.MIME_TYPE };
// private static final String sortorder = MediaColumns.DATE_ADDED + " DESC LIMIT 1";
//
// private Media readFromMediaStore(Context context, Uri uri) {
// Cursor cursor = context.getContentResolver().query(uri, projection, null, null, sortorder);
// Media media = null;
// if (cursor.moveToNext()) {
// int dataColumn = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
// String filePath = cursor.getString(dataColumn);
// int mimeTypeColumn = cursor.getColumnIndexOrThrow(MediaColumns.MIME_TYPE);
// String mimeType = cursor.getString(mimeTypeColumn);
// media = new Media(new File(filePath), mimeType);
// }
// cursor.close();
// return media;
// }
//
// private void log(String msg) {
// Log.v("GDCU::GalleryObserver", msg);
// }
//
// }
| import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.provider.MediaStore;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.crittercism.app.Crittercism;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.service.GalleryAlarmListener;
import com.darrenmowat.gdcu.service.GalleryObserver;
import com.flurry.android.FlurryAgent;
import com.google.api.services.drive.model.File; | @Override
public void onCreate() {
super.onCreate();
try {
PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
VERSION = app.versionCode;
VERSION_STRING = app.versionName;
PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
} catch (NameNotFoundException e) {
// We should never be here, unless our package doesn't exist on the
// system
// But how would this be running if it didn't
}
if (!DEVEL_BUILD) {
FlurryAgent.setCaptureUncaughtExceptions(false);
Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
}
DataBus.getInstance().register(this);
// Setup our media observers
Uri PHOTO_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
photoObserver = new GalleryObserver(this, PHOTO_URI);
getContentResolver().registerContentObserver(PHOTO_URI, false, photoObserver);
Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
videoObserver = new GalleryObserver(this, VIDEO_URI);
getContentResolver().registerContentObserver(VIDEO_URI, false, videoObserver);
| // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryAlarmListener.java
// public class GalleryAlarmListener implements AlarmListener {
//
// @Override
// public void scheduleAlarms(AlarmManager mgr, PendingIntent pendingIntent, Context context) {
// info("Starting alarm with update interval of " + AlarmManager.INTERVAL_HOUR);
// mgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
// SystemClock.elapsedRealtime() + 60000, AlarmManager.INTERVAL_HOUR, pendingIntent);
// }
//
// @Override
// public void sendWakefulWork(Context context) {
// info("Waking up the media service");
// Intent service = new Intent(context, MediaService.class);
// service.setAction(MediaService.NO_WAIT);
// context.startService(service);
// }
//
// /*
// * If the service hasn't been triggered in 12 hours assume it has been
// * killed (non-Javadoc)
// *
// * @see
// * com.commonsware.cwac.wakeful.WakefulIntentService.AlarmListener#getMaxAge
// * ()
// */
// @Override
// public long getMaxAge() {
// return Math.round(AlarmManager.INTERVAL_HALF_DAY);
// }
//
// private void info(String msg) {
// Log.v("GDCU::GalleryAlarmListener", msg);
// }
// }
//
// Path: src/com/darrenmowat/gdcu/service/GalleryObserver.java
// public class GalleryObserver extends ContentObserver {
//
// private Context context;
// private Uri BASE_URI;
//
// public GalleryObserver(Context context, Uri base) {
// super(null);
// this.context = context;
// this.BASE_URI = base;
// }
//
// @Override
// public void onChange(boolean selfChange) {
// super.onChange(selfChange);
// Media media = readFromMediaStore(context, BASE_URI);
// if (media == null) {
// log("Media returned from database was null");
// return;
// }
//
// Intent service = new Intent(context, MediaService.class);
// context.startService(service);
// }
//
// private static final String[] projection = { MediaColumns.DATA, MediaColumns.MIME_TYPE };
// private static final String sortorder = MediaColumns.DATE_ADDED + " DESC LIMIT 1";
//
// private Media readFromMediaStore(Context context, Uri uri) {
// Cursor cursor = context.getContentResolver().query(uri, projection, null, null, sortorder);
// Media media = null;
// if (cursor.moveToNext()) {
// int dataColumn = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
// String filePath = cursor.getString(dataColumn);
// int mimeTypeColumn = cursor.getColumnIndexOrThrow(MediaColumns.MIME_TYPE);
// String mimeType = cursor.getString(mimeTypeColumn);
// media = new Media(new File(filePath), mimeType);
// }
// cursor.close();
// return media;
// }
//
// private void log(String msg) {
// Log.v("GDCU::GalleryObserver", msg);
// }
//
// }
// Path: src/com/darrenmowat/gdcu/GDCU.java
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.provider.MediaStore;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.crittercism.app.Crittercism;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.service.GalleryAlarmListener;
import com.darrenmowat.gdcu.service.GalleryObserver;
import com.flurry.android.FlurryAgent;
import com.google.api.services.drive.model.File;
@Override
public void onCreate() {
super.onCreate();
try {
PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
VERSION = app.versionCode;
VERSION_STRING = app.versionName;
PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
} catch (NameNotFoundException e) {
// We should never be here, unless our package doesn't exist on the
// system
// But how would this be running if it didn't
}
if (!DEVEL_BUILD) {
FlurryAgent.setCaptureUncaughtExceptions(false);
Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
}
DataBus.getInstance().register(this);
// Setup our media observers
Uri PHOTO_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
photoObserver = new GalleryObserver(this, PHOTO_URI);
getContentResolver().registerContentObserver(PHOTO_URI, false, photoObserver);
Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
videoObserver = new GalleryObserver(this, VIDEO_URI);
getContentResolver().registerContentObserver(VIDEO_URI, false, videoObserver);
| WakefulIntentService.scheduleAlarms(new GalleryAlarmListener(), this, false); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/UploadService.java | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
| import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException; | package com.darrenmowat.gdcu.service;
public class UploadService extends Service implements ThreadCallbacks {
public static boolean uploading = false;
private WakeLock wakelock;
private UploadThread thread;
private String email;
@Override
public void onStart(Intent intent, int startId) {
handleCommand(intent);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
handleCommand(intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return START_STICKY;
}
@Override
public void onDestroy() {
if (thread != null && thread.uploading) {
thread.stopSoon();
// The thread will notify this once it has actually stopped running
return;
}
// Ensure the thread has been stopped
// Ensure the WakeLock has been given up
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
uploading = false;
super.onDestroy();
}
private void handleCommand(Intent intent) {
uploading = true; | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
// Path: src/com/darrenmowat/gdcu/service/UploadService.java
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException;
package com.darrenmowat.gdcu.service;
public class UploadService extends Service implements ThreadCallbacks {
public static boolean uploading = false;
private WakeLock wakelock;
private UploadThread thread;
private String email;
@Override
public void onStart(Intent intent, int startId) {
handleCommand(intent);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
handleCommand(intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
return START_STICKY;
}
@Override
public void onDestroy() {
if (thread != null && thread.uploading) {
thread.stopSoon();
// The thread will notify this once it has actually stopped running
return;
}
// Ensure the thread has been stopped
// Ensure the WakeLock has been given up
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
uploading = false;
super.onDestroy();
}
private void handleCommand(Intent intent) {
uploading = true; | email = Preferences.getEmail(UploadService.this); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/UploadService.java | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
| import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException; | return null;
}
private void log(String msg) {
Log.v("GDCU::UploadService", msg);
}
@Override
public void onThreadFinished() {
thread = null;
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
stopSelf();
}
@Override
public void onThreadError(Exception e) {
log("UploadService crashed");
e.printStackTrace();
thread = null;
if (e instanceof UserRecoverableAuthException) {
UserRecoverableAuthException userException = (UserRecoverableAuthException) e;
Notifier.notifyAuthError(UploadService.this, email, userException.getIntent());
} else {
e.printStackTrace();
String title = getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = getResources().getString(
R.string.pref_summary_upload_status_uploads_failed); | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
// Path: src/com/darrenmowat/gdcu/service/UploadService.java
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException;
return null;
}
private void log(String msg) {
Log.v("GDCU::UploadService", msg);
}
@Override
public void onThreadFinished() {
thread = null;
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
stopSelf();
}
@Override
public void onThreadError(Exception e) {
log("UploadService crashed");
e.printStackTrace();
thread = null;
if (e instanceof UserRecoverableAuthException) {
UserRecoverableAuthException userException = (UserRecoverableAuthException) e;
Notifier.notifyAuthError(UploadService.this, email, userException.getIntent());
} else {
e.printStackTrace();
String title = getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = getResources().getString(
R.string.pref_summary_upload_status_uploads_failed); | DataBus.getInstance().post(new UploadStatusEvent(title, msg)); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/UploadService.java | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
| import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException; | return null;
}
private void log(String msg) {
Log.v("GDCU::UploadService", msg);
}
@Override
public void onThreadFinished() {
thread = null;
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
stopSelf();
}
@Override
public void onThreadError(Exception e) {
log("UploadService crashed");
e.printStackTrace();
thread = null;
if (e instanceof UserRecoverableAuthException) {
UserRecoverableAuthException userException = (UserRecoverableAuthException) e;
Notifier.notifyAuthError(UploadService.this, email, userException.getIntent());
} else {
e.printStackTrace();
String title = getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = getResources().getString(
R.string.pref_summary_upload_status_uploads_failed); | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
// Path: src/com/darrenmowat/gdcu/service/UploadService.java
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException;
return null;
}
private void log(String msg) {
Log.v("GDCU::UploadService", msg);
}
@Override
public void onThreadFinished() {
thread = null;
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
stopSelf();
}
@Override
public void onThreadError(Exception e) {
log("UploadService crashed");
e.printStackTrace();
thread = null;
if (e instanceof UserRecoverableAuthException) {
UserRecoverableAuthException userException = (UserRecoverableAuthException) e;
Notifier.notifyAuthError(UploadService.this, email, userException.getIntent());
} else {
e.printStackTrace();
String title = getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = getResources().getString(
R.string.pref_summary_upload_status_uploads_failed); | DataBus.getInstance().post(new UploadStatusEvent(title, msg)); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/activity/WebviewActivity.java | // Path: src/com/darrenmowat/gdcu/GDCU.java
// public class GDCU extends Application {
//
// public static final boolean DEVEL_BUILD = true;
//
// public static final String APP_NAME = "PicSync Beta";
//
// public static int VERSION;
// public static String VERSION_STRING;
// public static final String BUILD_TYPE = DEVEL_BUILD ? "Development Build" : "Beta Build";
//
// public static String PRETTY_BUILD_STRING;
//
// public static final String FEEDBACK_EMAIL = "dmowat91@gmail.com";
//
// private GalleryObserver photoObserver;
// private GalleryObserver videoObserver;
//
// private static File uploadsDir = null;
// private static String rootId = null;
//
// private String userToken = null;
// private String apiToken = null;
//
// public static GDCU getGDCU(Context context) {
// return (GDCU) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// try {
// PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
// VERSION = app.versionCode;
// VERSION_STRING = app.versionName;
// PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
// } catch (NameNotFoundException e) {
// // We should never be here, unless our package doesn't exist on the
// // system
// // But how would this be running if it didn't
// }
//
// if (!DEVEL_BUILD) {
// FlurryAgent.setCaptureUncaughtExceptions(false);
// Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
// }
//
// DataBus.getInstance().register(this);
//
// // Setup our media observers
// Uri PHOTO_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
// photoObserver = new GalleryObserver(this, PHOTO_URI);
// getContentResolver().registerContentObserver(PHOTO_URI, false, photoObserver);
// Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
// videoObserver = new GalleryObserver(this, VIDEO_URI);
// getContentResolver().registerContentObserver(VIDEO_URI, false, videoObserver);
//
// WakefulIntentService.scheduleAlarms(new GalleryAlarmListener(), this, false);
// }
//
// public static void setCachedUploadsDir(File uploadsDir) {
// GDCU.uploadsDir = uploadsDir;
// }
//
// public static File getCachedUploadsDir() {
// return uploadsDir;
// }
//
// public void setUserToken(String token) {
// userToken = token;
// }
//
// public String getUserToken() {
// return userToken;
// }
//
// public void setApiToken(String token) {
// apiToken = token;
// }
//
// public String getApiToken() {
// return apiToken;
// }
//
// public static void setCachedRootDir(String rootId) {
// GDCU.rootId = rootId;
// }
//
// public static String getCachedRootDir() {
// return rootId;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/Keys.java
// public class Keys {
//
// public static final String FLURRY_KEY = "";
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
| import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
import com.darrenmowat.gdcu.GDCU;
import com.darrenmowat.gdcu.Keys;
import com.darrenmowat.gdcu.otto.DataBus;
import com.flurry.android.FlurryAgent; | getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
webview.getSettings().setJavaScriptEnabled(false);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
final Context context = WebviewActivity.this;
Toast.makeText(context, "Couldn't load page! " + description, Toast.LENGTH_SHORT)
.show();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
final Context context = WebviewActivity.this;
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(browserIntent);
return true;
}
});
webview.loadUrl(url);
}
@Override
public void onStart() {
super.onStart(); | // Path: src/com/darrenmowat/gdcu/GDCU.java
// public class GDCU extends Application {
//
// public static final boolean DEVEL_BUILD = true;
//
// public static final String APP_NAME = "PicSync Beta";
//
// public static int VERSION;
// public static String VERSION_STRING;
// public static final String BUILD_TYPE = DEVEL_BUILD ? "Development Build" : "Beta Build";
//
// public static String PRETTY_BUILD_STRING;
//
// public static final String FEEDBACK_EMAIL = "dmowat91@gmail.com";
//
// private GalleryObserver photoObserver;
// private GalleryObserver videoObserver;
//
// private static File uploadsDir = null;
// private static String rootId = null;
//
// private String userToken = null;
// private String apiToken = null;
//
// public static GDCU getGDCU(Context context) {
// return (GDCU) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// try {
// PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
// VERSION = app.versionCode;
// VERSION_STRING = app.versionName;
// PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
// } catch (NameNotFoundException e) {
// // We should never be here, unless our package doesn't exist on the
// // system
// // But how would this be running if it didn't
// }
//
// if (!DEVEL_BUILD) {
// FlurryAgent.setCaptureUncaughtExceptions(false);
// Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
// }
//
// DataBus.getInstance().register(this);
//
// // Setup our media observers
// Uri PHOTO_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
// photoObserver = new GalleryObserver(this, PHOTO_URI);
// getContentResolver().registerContentObserver(PHOTO_URI, false, photoObserver);
// Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
// videoObserver = new GalleryObserver(this, VIDEO_URI);
// getContentResolver().registerContentObserver(VIDEO_URI, false, videoObserver);
//
// WakefulIntentService.scheduleAlarms(new GalleryAlarmListener(), this, false);
// }
//
// public static void setCachedUploadsDir(File uploadsDir) {
// GDCU.uploadsDir = uploadsDir;
// }
//
// public static File getCachedUploadsDir() {
// return uploadsDir;
// }
//
// public void setUserToken(String token) {
// userToken = token;
// }
//
// public String getUserToken() {
// return userToken;
// }
//
// public void setApiToken(String token) {
// apiToken = token;
// }
//
// public String getApiToken() {
// return apiToken;
// }
//
// public static void setCachedRootDir(String rootId) {
// GDCU.rootId = rootId;
// }
//
// public static String getCachedRootDir() {
// return rootId;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/Keys.java
// public class Keys {
//
// public static final String FLURRY_KEY = "";
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
// Path: src/com/darrenmowat/gdcu/activity/WebviewActivity.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
import com.darrenmowat.gdcu.GDCU;
import com.darrenmowat.gdcu.Keys;
import com.darrenmowat.gdcu.otto.DataBus;
import com.flurry.android.FlurryAgent;
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
webview.getSettings().setJavaScriptEnabled(false);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
final Context context = WebviewActivity.this;
Toast.makeText(context, "Couldn't load page! " + description, Toast.LENGTH_SHORT)
.show();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
final Context context = WebviewActivity.this;
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(browserIntent);
return true;
}
});
webview.loadUrl(url);
}
@Override
public void onStart() {
super.onStart(); | DataBus.getInstance().register(this); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/activity/WebviewActivity.java | // Path: src/com/darrenmowat/gdcu/GDCU.java
// public class GDCU extends Application {
//
// public static final boolean DEVEL_BUILD = true;
//
// public static final String APP_NAME = "PicSync Beta";
//
// public static int VERSION;
// public static String VERSION_STRING;
// public static final String BUILD_TYPE = DEVEL_BUILD ? "Development Build" : "Beta Build";
//
// public static String PRETTY_BUILD_STRING;
//
// public static final String FEEDBACK_EMAIL = "dmowat91@gmail.com";
//
// private GalleryObserver photoObserver;
// private GalleryObserver videoObserver;
//
// private static File uploadsDir = null;
// private static String rootId = null;
//
// private String userToken = null;
// private String apiToken = null;
//
// public static GDCU getGDCU(Context context) {
// return (GDCU) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// try {
// PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
// VERSION = app.versionCode;
// VERSION_STRING = app.versionName;
// PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
// } catch (NameNotFoundException e) {
// // We should never be here, unless our package doesn't exist on the
// // system
// // But how would this be running if it didn't
// }
//
// if (!DEVEL_BUILD) {
// FlurryAgent.setCaptureUncaughtExceptions(false);
// Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
// }
//
// DataBus.getInstance().register(this);
//
// // Setup our media observers
// Uri PHOTO_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
// photoObserver = new GalleryObserver(this, PHOTO_URI);
// getContentResolver().registerContentObserver(PHOTO_URI, false, photoObserver);
// Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
// videoObserver = new GalleryObserver(this, VIDEO_URI);
// getContentResolver().registerContentObserver(VIDEO_URI, false, videoObserver);
//
// WakefulIntentService.scheduleAlarms(new GalleryAlarmListener(), this, false);
// }
//
// public static void setCachedUploadsDir(File uploadsDir) {
// GDCU.uploadsDir = uploadsDir;
// }
//
// public static File getCachedUploadsDir() {
// return uploadsDir;
// }
//
// public void setUserToken(String token) {
// userToken = token;
// }
//
// public String getUserToken() {
// return userToken;
// }
//
// public void setApiToken(String token) {
// apiToken = token;
// }
//
// public String getApiToken() {
// return apiToken;
// }
//
// public static void setCachedRootDir(String rootId) {
// GDCU.rootId = rootId;
// }
//
// public static String getCachedRootDir() {
// return rootId;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/Keys.java
// public class Keys {
//
// public static final String FLURRY_KEY = "";
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
| import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
import com.darrenmowat.gdcu.GDCU;
import com.darrenmowat.gdcu.Keys;
import com.darrenmowat.gdcu.otto.DataBus;
import com.flurry.android.FlurryAgent; |
webview.getSettings().setJavaScriptEnabled(false);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
final Context context = WebviewActivity.this;
Toast.makeText(context, "Couldn't load page! " + description, Toast.LENGTH_SHORT)
.show();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
final Context context = WebviewActivity.this;
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(browserIntent);
return true;
}
});
webview.loadUrl(url);
}
@Override
public void onStart() {
super.onStart();
DataBus.getInstance().register(this); | // Path: src/com/darrenmowat/gdcu/GDCU.java
// public class GDCU extends Application {
//
// public static final boolean DEVEL_BUILD = true;
//
// public static final String APP_NAME = "PicSync Beta";
//
// public static int VERSION;
// public static String VERSION_STRING;
// public static final String BUILD_TYPE = DEVEL_BUILD ? "Development Build" : "Beta Build";
//
// public static String PRETTY_BUILD_STRING;
//
// public static final String FEEDBACK_EMAIL = "dmowat91@gmail.com";
//
// private GalleryObserver photoObserver;
// private GalleryObserver videoObserver;
//
// private static File uploadsDir = null;
// private static String rootId = null;
//
// private String userToken = null;
// private String apiToken = null;
//
// public static GDCU getGDCU(Context context) {
// return (GDCU) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// try {
// PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
// VERSION = app.versionCode;
// VERSION_STRING = app.versionName;
// PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
// } catch (NameNotFoundException e) {
// // We should never be here, unless our package doesn't exist on the
// // system
// // But how would this be running if it didn't
// }
//
// if (!DEVEL_BUILD) {
// FlurryAgent.setCaptureUncaughtExceptions(false);
// Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
// }
//
// DataBus.getInstance().register(this);
//
// // Setup our media observers
// Uri PHOTO_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
// photoObserver = new GalleryObserver(this, PHOTO_URI);
// getContentResolver().registerContentObserver(PHOTO_URI, false, photoObserver);
// Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
// videoObserver = new GalleryObserver(this, VIDEO_URI);
// getContentResolver().registerContentObserver(VIDEO_URI, false, videoObserver);
//
// WakefulIntentService.scheduleAlarms(new GalleryAlarmListener(), this, false);
// }
//
// public static void setCachedUploadsDir(File uploadsDir) {
// GDCU.uploadsDir = uploadsDir;
// }
//
// public static File getCachedUploadsDir() {
// return uploadsDir;
// }
//
// public void setUserToken(String token) {
// userToken = token;
// }
//
// public String getUserToken() {
// return userToken;
// }
//
// public void setApiToken(String token) {
// apiToken = token;
// }
//
// public String getApiToken() {
// return apiToken;
// }
//
// public static void setCachedRootDir(String rootId) {
// GDCU.rootId = rootId;
// }
//
// public static String getCachedRootDir() {
// return rootId;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/Keys.java
// public class Keys {
//
// public static final String FLURRY_KEY = "";
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
// Path: src/com/darrenmowat/gdcu/activity/WebviewActivity.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
import com.darrenmowat.gdcu.GDCU;
import com.darrenmowat.gdcu.Keys;
import com.darrenmowat.gdcu.otto.DataBus;
import com.flurry.android.FlurryAgent;
webview.getSettings().setJavaScriptEnabled(false);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
final Context context = WebviewActivity.this;
Toast.makeText(context, "Couldn't load page! " + description, Toast.LENGTH_SHORT)
.show();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
final Context context = WebviewActivity.this;
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(browserIntent);
return true;
}
});
webview.loadUrl(url);
}
@Override
public void onStart() {
super.onStart();
DataBus.getInstance().register(this); | if (!GDCU.DEVEL_BUILD) { |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/activity/WebviewActivity.java | // Path: src/com/darrenmowat/gdcu/GDCU.java
// public class GDCU extends Application {
//
// public static final boolean DEVEL_BUILD = true;
//
// public static final String APP_NAME = "PicSync Beta";
//
// public static int VERSION;
// public static String VERSION_STRING;
// public static final String BUILD_TYPE = DEVEL_BUILD ? "Development Build" : "Beta Build";
//
// public static String PRETTY_BUILD_STRING;
//
// public static final String FEEDBACK_EMAIL = "dmowat91@gmail.com";
//
// private GalleryObserver photoObserver;
// private GalleryObserver videoObserver;
//
// private static File uploadsDir = null;
// private static String rootId = null;
//
// private String userToken = null;
// private String apiToken = null;
//
// public static GDCU getGDCU(Context context) {
// return (GDCU) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// try {
// PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
// VERSION = app.versionCode;
// VERSION_STRING = app.versionName;
// PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
// } catch (NameNotFoundException e) {
// // We should never be here, unless our package doesn't exist on the
// // system
// // But how would this be running if it didn't
// }
//
// if (!DEVEL_BUILD) {
// FlurryAgent.setCaptureUncaughtExceptions(false);
// Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
// }
//
// DataBus.getInstance().register(this);
//
// // Setup our media observers
// Uri PHOTO_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
// photoObserver = new GalleryObserver(this, PHOTO_URI);
// getContentResolver().registerContentObserver(PHOTO_URI, false, photoObserver);
// Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
// videoObserver = new GalleryObserver(this, VIDEO_URI);
// getContentResolver().registerContentObserver(VIDEO_URI, false, videoObserver);
//
// WakefulIntentService.scheduleAlarms(new GalleryAlarmListener(), this, false);
// }
//
// public static void setCachedUploadsDir(File uploadsDir) {
// GDCU.uploadsDir = uploadsDir;
// }
//
// public static File getCachedUploadsDir() {
// return uploadsDir;
// }
//
// public void setUserToken(String token) {
// userToken = token;
// }
//
// public String getUserToken() {
// return userToken;
// }
//
// public void setApiToken(String token) {
// apiToken = token;
// }
//
// public String getApiToken() {
// return apiToken;
// }
//
// public static void setCachedRootDir(String rootId) {
// GDCU.rootId = rootId;
// }
//
// public static String getCachedRootDir() {
// return rootId;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/Keys.java
// public class Keys {
//
// public static final String FLURRY_KEY = "";
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
| import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
import com.darrenmowat.gdcu.GDCU;
import com.darrenmowat.gdcu.Keys;
import com.darrenmowat.gdcu.otto.DataBus;
import com.flurry.android.FlurryAgent; | webview.getSettings().setJavaScriptEnabled(false);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
final Context context = WebviewActivity.this;
Toast.makeText(context, "Couldn't load page! " + description, Toast.LENGTH_SHORT)
.show();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
final Context context = WebviewActivity.this;
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(browserIntent);
return true;
}
});
webview.loadUrl(url);
}
@Override
public void onStart() {
super.onStart();
DataBus.getInstance().register(this);
if (!GDCU.DEVEL_BUILD) { | // Path: src/com/darrenmowat/gdcu/GDCU.java
// public class GDCU extends Application {
//
// public static final boolean DEVEL_BUILD = true;
//
// public static final String APP_NAME = "PicSync Beta";
//
// public static int VERSION;
// public static String VERSION_STRING;
// public static final String BUILD_TYPE = DEVEL_BUILD ? "Development Build" : "Beta Build";
//
// public static String PRETTY_BUILD_STRING;
//
// public static final String FEEDBACK_EMAIL = "dmowat91@gmail.com";
//
// private GalleryObserver photoObserver;
// private GalleryObserver videoObserver;
//
// private static File uploadsDir = null;
// private static String rootId = null;
//
// private String userToken = null;
// private String apiToken = null;
//
// public static GDCU getGDCU(Context context) {
// return (GDCU) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// try {
// PackageInfo app = getPackageManager().getPackageInfo(getPackageName(), 0);
// VERSION = app.versionCode;
// VERSION_STRING = app.versionName;
// PRETTY_BUILD_STRING = VERSION_STRING + " " + BUILD_TYPE;
// } catch (NameNotFoundException e) {
// // We should never be here, unless our package doesn't exist on the
// // system
// // But how would this be running if it didn't
// }
//
// if (!DEVEL_BUILD) {
// FlurryAgent.setCaptureUncaughtExceptions(false);
// Crittercism.init(getApplicationContext(), "50382024eeaf411be9000002");
// }
//
// DataBus.getInstance().register(this);
//
// // Setup our media observers
// Uri PHOTO_URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
// photoObserver = new GalleryObserver(this, PHOTO_URI);
// getContentResolver().registerContentObserver(PHOTO_URI, false, photoObserver);
// Uri VIDEO_URI = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
// videoObserver = new GalleryObserver(this, VIDEO_URI);
// getContentResolver().registerContentObserver(VIDEO_URI, false, videoObserver);
//
// WakefulIntentService.scheduleAlarms(new GalleryAlarmListener(), this, false);
// }
//
// public static void setCachedUploadsDir(File uploadsDir) {
// GDCU.uploadsDir = uploadsDir;
// }
//
// public static File getCachedUploadsDir() {
// return uploadsDir;
// }
//
// public void setUserToken(String token) {
// userToken = token;
// }
//
// public String getUserToken() {
// return userToken;
// }
//
// public void setApiToken(String token) {
// apiToken = token;
// }
//
// public String getApiToken() {
// return apiToken;
// }
//
// public static void setCachedRootDir(String rootId) {
// GDCU.rootId = rootId;
// }
//
// public static String getCachedRootDir() {
// return rootId;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/Keys.java
// public class Keys {
//
// public static final String FLURRY_KEY = "";
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
// Path: src/com/darrenmowat/gdcu/activity/WebviewActivity.java
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockActivity;
import com.darrenmowat.gdcu.GDCU;
import com.darrenmowat.gdcu.Keys;
import com.darrenmowat.gdcu.otto.DataBus;
import com.flurry.android.FlurryAgent;
webview.getSettings().setJavaScriptEnabled(false);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
final Context context = WebviewActivity.this;
Toast.makeText(context, "Couldn't load page! " + description, Toast.LENGTH_SHORT)
.show();
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
final Context context = WebviewActivity.this;
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
context.startActivity(browserIntent);
return true;
}
});
webview.loadUrl(url);
}
@Override
public void onStart() {
super.onStart();
DataBus.getInstance().register(this);
if (!GDCU.DEVEL_BUILD) { | FlurryAgent.onStartSession(this, Keys.FLURRY_KEY); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/MediaService.java | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
| import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException; | if (thread != null && thread.running) {
thread.interrupt();
// The thread will notify this once it has actually stopped running
return;
}
// Ensure the thread has been stopped
// Ensure the WakeLock has been given up
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
super.onDestroy();
}
private void handleCommand(Intent intent) {
if(!ServiceUtils.shouldUpload(this)) {
log("Not syncing just now!");
return;
}
// If we are currently uploading return;
if(UploadService.uploading) {
log("Not scanning for media just now, currently uploading!");
return;
}
boolean should_wait = true;
if (intent != null) {
if (intent.getAction() != null) {
should_wait = !intent.getAction().equals(NO_WAIT);
}
} | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
// Path: src/com/darrenmowat/gdcu/service/MediaService.java
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException;
if (thread != null && thread.running) {
thread.interrupt();
// The thread will notify this once it has actually stopped running
return;
}
// Ensure the thread has been stopped
// Ensure the WakeLock has been given up
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
super.onDestroy();
}
private void handleCommand(Intent intent) {
if(!ServiceUtils.shouldUpload(this)) {
log("Not syncing just now!");
return;
}
// If we are currently uploading return;
if(UploadService.uploading) {
log("Not scanning for media just now, currently uploading!");
return;
}
boolean should_wait = true;
if (intent != null) {
if (intent.getAction() != null) {
should_wait = !intent.getAction().equals(NO_WAIT);
}
} | email = Preferences.getEmail(MediaService.this); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/MediaService.java | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
| import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException; |
private void log(String msg) {
Log.v("GDCU::MediaService", msg);
}
@Override
public void onThreadFinished() {
thread = null;
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
stopSelf();
// Start the upload service
final Context context = MediaService.this;
Intent service = new Intent(context, UploadService.class);
context.startService(service);
}
@Override
public void onThreadError(Exception e) {
thread = null;
if (e instanceof UserRecoverableAuthException) {
UserRecoverableAuthException userException = (UserRecoverableAuthException) e;
Notifier.notifyAuthError(MediaService.this, email, userException.getIntent());
} else {
e.printStackTrace();
String title = getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = getResources().getString(
R.string.pref_summary_upload_status_uploads_failed); | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
// Path: src/com/darrenmowat/gdcu/service/MediaService.java
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException;
private void log(String msg) {
Log.v("GDCU::MediaService", msg);
}
@Override
public void onThreadFinished() {
thread = null;
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
stopSelf();
// Start the upload service
final Context context = MediaService.this;
Intent service = new Intent(context, UploadService.class);
context.startService(service);
}
@Override
public void onThreadError(Exception e) {
thread = null;
if (e instanceof UserRecoverableAuthException) {
UserRecoverableAuthException userException = (UserRecoverableAuthException) e;
Notifier.notifyAuthError(MediaService.this, email, userException.getIntent());
} else {
e.printStackTrace();
String title = getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = getResources().getString(
R.string.pref_summary_upload_status_uploads_failed); | DataBus.getInstance().post(new UploadStatusEvent(title, msg)); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/MediaService.java | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
| import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException; |
private void log(String msg) {
Log.v("GDCU::MediaService", msg);
}
@Override
public void onThreadFinished() {
thread = null;
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
stopSelf();
// Start the upload service
final Context context = MediaService.this;
Intent service = new Intent(context, UploadService.class);
context.startService(service);
}
@Override
public void onThreadError(Exception e) {
thread = null;
if (e instanceof UserRecoverableAuthException) {
UserRecoverableAuthException userException = (UserRecoverableAuthException) e;
Notifier.notifyAuthError(MediaService.this, email, userException.getIntent());
} else {
e.printStackTrace();
String title = getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = getResources().getString(
R.string.pref_summary_upload_status_uploads_failed); | // Path: src/com/darrenmowat/gdcu/data/Preferences.java
// public class Preferences {
//
// public final static String EMAIL = "email";
// public final static String UPLOADS_FOLDER = "uploads_folder";
// public final static String UPLOADS_FOLDER_NAME = "uploads_folder_name";
//
// private static SharedPreferences getSharedPreferences(Context context) {
// Preconditions.checkNotNull(context, "Context passed into Preferences is null");
// return PreferenceManager.getDefaultSharedPreferences(context);
// }
//
// public static String getEmail(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// return sp.getString(EMAIL, null);
// }
//
// public static void storeEmail(Context context, String email) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (email == null) {
// editor.remove(EMAIL);
// } else {
// editor.putString(EMAIL, email);
// }
// editor.commit();
// }
//
// public static String getUploadsFolderName(Context context) {
// SharedPreferences sp = getSharedPreferences(context);
// String def = context.getString(R.string.uploads_folder_name);
// String uploadsFolderName = sp.getString(UPLOADS_FOLDER_NAME, def);
// // If stored vaule is empty, return default
// if(uploadsFolderName == null || uploadsFolderName.trim().equals("")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// // If stored value isnt valid, return default
// if(uploadsFolderName.contains("/")) {
// storeUploadsFolderName(context, null);
// return def;
// }
// return uploadsFolderName;
// }
//
// public static void storeUploadsFolderName(Context context, String uploadsFolderName) {
// SharedPreferences sp = getSharedPreferences(context);
// Editor editor = sp.edit();
// if (uploadsFolderName == null) {
// editor.remove(UPLOADS_FOLDER_NAME);
// } else {
// editor.putString(UPLOADS_FOLDER_NAME, uploadsFolderName);
// }
// editor.commit();
// }
//
// public static void clearPreferences(Context context) {
// Preferences.storeEmail(context, null);
// Preferences.storeUploadsFolderName(context, null);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/service/helpers/ThreadCallbacks.java
// public interface ThreadCallbacks {
//
// public void onThreadFinished();
//
// public void onThreadError(Exception e);
//
// }
// Path: src/com/darrenmowat/gdcu/service/MediaService.java
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import com.commonsware.cwac.wakeful.WakefulIntentService;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.data.Preferences;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
import com.darrenmowat.gdcu.service.helpers.ThreadCallbacks;
import com.google.android.gms.auth.UserRecoverableAuthException;
private void log(String msg) {
Log.v("GDCU::MediaService", msg);
}
@Override
public void onThreadFinished() {
thread = null;
if (wakelock != null && wakelock.isHeld()) {
wakelock.release();
}
stopSelf();
// Start the upload service
final Context context = MediaService.this;
Intent service = new Intent(context, UploadService.class);
context.startService(service);
}
@Override
public void onThreadError(Exception e) {
thread = null;
if (e instanceof UserRecoverableAuthException) {
UserRecoverableAuthException userException = (UserRecoverableAuthException) e;
Notifier.notifyAuthError(MediaService.this, email, userException.getIntent());
} else {
e.printStackTrace();
String title = getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = getResources().getString(
R.string.pref_summary_upload_status_uploads_failed); | DataBus.getInstance().post(new UploadStatusEvent(title, msg)); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/GalleryObserver.java | // Path: src/com/darrenmowat/gdcu/service/helpers/Media.java
// public class Media {
//
// private File file;
// private String type;
// private String md5;
//
// public Media(File file, String type) {
// this.file = file;
// this.type = type;
// this.md5 = "";
// }
//
// public String getType() {
// return type;
// }
//
// public File getFile() {
// return file;
// }
//
// public void setMD5(String md5) {
// this.md5 = md5;
// }
//
// public String getMD5() {
// return md5;
// }
//
// }
| import java.io.File;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore.MediaColumns;
import android.util.Log;
import com.darrenmowat.gdcu.service.helpers.Media; | package com.darrenmowat.gdcu.service;
public class GalleryObserver extends ContentObserver {
private Context context;
private Uri BASE_URI;
public GalleryObserver(Context context, Uri base) {
super(null);
this.context = context;
this.BASE_URI = base;
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange); | // Path: src/com/darrenmowat/gdcu/service/helpers/Media.java
// public class Media {
//
// private File file;
// private String type;
// private String md5;
//
// public Media(File file, String type) {
// this.file = file;
// this.type = type;
// this.md5 = "";
// }
//
// public String getType() {
// return type;
// }
//
// public File getFile() {
// return file;
// }
//
// public void setMD5(String md5) {
// this.md5 = md5;
// }
//
// public String getMD5() {
// return md5;
// }
//
// }
// Path: src/com/darrenmowat/gdcu/service/GalleryObserver.java
import java.io.File;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore.MediaColumns;
import android.util.Log;
import com.darrenmowat.gdcu.service.helpers.Media;
package com.darrenmowat.gdcu.service;
public class GalleryObserver extends ContentObserver {
private Context context;
private Uri BASE_URI;
public GalleryObserver(Context context, Uri base) {
super(null);
this.context = context;
this.BASE_URI = base;
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange); | Media media = readFromMediaStore(context, BASE_URI); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/ServiceUtils.java | // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
| import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.BatteryManager;
import android.preference.PreferenceManager;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent; | if (!isCharging(context)) {
String title = context.getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = context.getResources().getString(
R.string.pref_summary_upload_status_uploading_pending_for_power);
sendServiceUpdate(title, msg);
return false;
}
}
return true;
}
public static boolean isOnWiFi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isOnWiFi = activeNetwork != null
&& activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;
return isOnWiFi;
}
public static boolean isCharging(Context context) {
Intent intent = context.registerReceiver(null, new IntentFilter(
Intent.ACTION_BATTERY_CHANGED));
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
return plugged == BatteryManager.BATTERY_PLUGGED_AC
|| plugged == BatteryManager.BATTERY_PLUGGED_USB;
}
public static void sendServiceUpdate(String title, String msg) { | // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
// Path: src/com/darrenmowat/gdcu/service/ServiceUtils.java
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.BatteryManager;
import android.preference.PreferenceManager;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
if (!isCharging(context)) {
String title = context.getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = context.getResources().getString(
R.string.pref_summary_upload_status_uploading_pending_for_power);
sendServiceUpdate(title, msg);
return false;
}
}
return true;
}
public static boolean isOnWiFi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isOnWiFi = activeNetwork != null
&& activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;
return isOnWiFi;
}
public static boolean isCharging(Context context) {
Intent intent = context.registerReceiver(null, new IntentFilter(
Intent.ACTION_BATTERY_CHANGED));
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
return plugged == BatteryManager.BATTERY_PLUGGED_AC
|| plugged == BatteryManager.BATTERY_PLUGGED_USB;
}
public static void sendServiceUpdate(String title, String msg) { | DataBus.postUploadStatusEventProducer(new UploadStatusEvent(title, msg)); |
DarrenMowat/PicSync | src/com/darrenmowat/gdcu/service/ServiceUtils.java | // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
| import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.BatteryManager;
import android.preference.PreferenceManager;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent; | if (!isCharging(context)) {
String title = context.getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = context.getResources().getString(
R.string.pref_summary_upload_status_uploading_pending_for_power);
sendServiceUpdate(title, msg);
return false;
}
}
return true;
}
public static boolean isOnWiFi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isOnWiFi = activeNetwork != null
&& activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;
return isOnWiFi;
}
public static boolean isCharging(Context context) {
Intent intent = context.registerReceiver(null, new IntentFilter(
Intent.ACTION_BATTERY_CHANGED));
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
return plugged == BatteryManager.BATTERY_PLUGGED_AC
|| plugged == BatteryManager.BATTERY_PLUGGED_USB;
}
public static void sendServiceUpdate(String title, String msg) { | // Path: src/com/darrenmowat/gdcu/otto/DataBus.java
// public class DataBus {
//
// private static Bus mInstance = null;
// private static UploadStatusEventProducer statProducer = null;
//
// public static Bus getInstance() {
// if (mInstance == null) {
// mInstance = new Bus(ThreadEnforcer.ANY);
// }
// if (statProducer == null) {
// statProducer = new UploadStatusEventProducer();
// statProducer.register(mInstance);
// }
// return mInstance;
// }
//
// public static void postUploadStatusEventProducer(UploadStatusEvent event) {
// getInstance().post(event);
// statProducer.setLastServiceRefreshingEvent(event);
// }
//
// }
//
// Path: src/com/darrenmowat/gdcu/otto/UploadStatusEvent.java
// public class UploadStatusEvent {
//
// public String title;
// public String message;
//
// public UploadStatusEvent(String title, String message) {
// this.title = title;
// this.message = message;
// }
//
// }
// Path: src/com/darrenmowat/gdcu/service/ServiceUtils.java
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.BatteryManager;
import android.preference.PreferenceManager;
import com.darrenmowat.gdcu.R;
import com.darrenmowat.gdcu.otto.DataBus;
import com.darrenmowat.gdcu.otto.UploadStatusEvent;
if (!isCharging(context)) {
String title = context.getResources().getString(
R.string.pref_title_upload_status_uploads_pending);
String msg = context.getResources().getString(
R.string.pref_summary_upload_status_uploading_pending_for_power);
sendServiceUpdate(title, msg);
return false;
}
}
return true;
}
public static boolean isOnWiFi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isOnWiFi = activeNetwork != null
&& activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;
return isOnWiFi;
}
public static boolean isCharging(Context context) {
Intent intent = context.registerReceiver(null, new IntentFilter(
Intent.ACTION_BATTERY_CHANGED));
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
return plugged == BatteryManager.BATTERY_PLUGGED_AC
|| plugged == BatteryManager.BATTERY_PLUGGED_USB;
}
public static void sendServiceUpdate(String title, String msg) { | DataBus.postUploadStatusEventProducer(new UploadStatusEvent(title, msg)); |
gp15237125756/PoiExcelExport2.0 | extention/impl/XSSFCellStyleRuleImpl.java | // Path: extention/XSSFCellStyleLib.java
// public class XSSFCellStyleLib {
// /** 樣式緩存*/
// private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFCellStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// ICellStyleConvert convert=new CellStyleConvert();
// //添加cell樣式
// convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this);
// convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this);
// convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
//
// public void addStyle(CellStyle k,XSSFCellStyle v){
// CELL_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(CellStyle k){
// CELL_STYLE_MAP.remove(k);
// }
//
// public XSSFCellStyle get(CellStyle k){
// XSSFCellStyle v=CELL_STYLE_MAP.get(k);
// if(null==v){
// throw new CellStyleNotFoundException("the cell style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// CELL_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFCellStyleRule.java
// public interface XSSFCellStyleRule {
// /**
// * 註冊樣式
// */
// void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib);
// /**
// * 移除樣式
// */
// void removeStyleRule(CellStyle k,XSSFCellStyleLib lib);
//
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import com.ld.datacenter.poi.extention.XSSFCellStyleLib;
import com.ld.datacenter.poi.extention.XSSFCellStyleRule;
import com.ld.datacenter.poi.helper.CellStyle; | package com.ld.datacenter.poi.extention.impl;
public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{
@Override | // Path: extention/XSSFCellStyleLib.java
// public class XSSFCellStyleLib {
// /** 樣式緩存*/
// private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFCellStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// ICellStyleConvert convert=new CellStyleConvert();
// //添加cell樣式
// convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this);
// convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this);
// convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
//
// public void addStyle(CellStyle k,XSSFCellStyle v){
// CELL_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(CellStyle k){
// CELL_STYLE_MAP.remove(k);
// }
//
// public XSSFCellStyle get(CellStyle k){
// XSSFCellStyle v=CELL_STYLE_MAP.get(k);
// if(null==v){
// throw new CellStyleNotFoundException("the cell style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// CELL_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFCellStyleRule.java
// public interface XSSFCellStyleRule {
// /**
// * 註冊樣式
// */
// void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib);
// /**
// * 移除樣式
// */
// void removeStyleRule(CellStyle k,XSSFCellStyleLib lib);
//
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: extention/impl/XSSFCellStyleRuleImpl.java
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import com.ld.datacenter.poi.extention.XSSFCellStyleLib;
import com.ld.datacenter.poi.extention.XSSFCellStyleRule;
import com.ld.datacenter.poi.helper.CellStyle;
package com.ld.datacenter.poi.extention.impl;
public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{
@Override | public void registerStyleRule(CellStyle k, XSSFCellStyle v, |
gp15237125756/PoiExcelExport2.0 | extention/impl/XSSFCellStyleRuleImpl.java | // Path: extention/XSSFCellStyleLib.java
// public class XSSFCellStyleLib {
// /** 樣式緩存*/
// private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFCellStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// ICellStyleConvert convert=new CellStyleConvert();
// //添加cell樣式
// convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this);
// convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this);
// convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
//
// public void addStyle(CellStyle k,XSSFCellStyle v){
// CELL_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(CellStyle k){
// CELL_STYLE_MAP.remove(k);
// }
//
// public XSSFCellStyle get(CellStyle k){
// XSSFCellStyle v=CELL_STYLE_MAP.get(k);
// if(null==v){
// throw new CellStyleNotFoundException("the cell style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// CELL_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFCellStyleRule.java
// public interface XSSFCellStyleRule {
// /**
// * 註冊樣式
// */
// void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib);
// /**
// * 移除樣式
// */
// void removeStyleRule(CellStyle k,XSSFCellStyleLib lib);
//
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import com.ld.datacenter.poi.extention.XSSFCellStyleLib;
import com.ld.datacenter.poi.extention.XSSFCellStyleRule;
import com.ld.datacenter.poi.helper.CellStyle; | package com.ld.datacenter.poi.extention.impl;
public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{
@Override
public void registerStyleRule(CellStyle k, XSSFCellStyle v, | // Path: extention/XSSFCellStyleLib.java
// public class XSSFCellStyleLib {
// /** 樣式緩存*/
// private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFCellStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// ICellStyleConvert convert=new CellStyleConvert();
// //添加cell樣式
// convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this);
// convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this);
// convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
//
// public void addStyle(CellStyle k,XSSFCellStyle v){
// CELL_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(CellStyle k){
// CELL_STYLE_MAP.remove(k);
// }
//
// public XSSFCellStyle get(CellStyle k){
// XSSFCellStyle v=CELL_STYLE_MAP.get(k);
// if(null==v){
// throw new CellStyleNotFoundException("the cell style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// CELL_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFCellStyleRule.java
// public interface XSSFCellStyleRule {
// /**
// * 註冊樣式
// */
// void registerStyleRule(CellStyle k,XSSFCellStyle v,XSSFCellStyleLib lib);
// /**
// * 移除樣式
// */
// void removeStyleRule(CellStyle k,XSSFCellStyleLib lib);
//
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: extention/impl/XSSFCellStyleRuleImpl.java
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import com.ld.datacenter.poi.extention.XSSFCellStyleLib;
import com.ld.datacenter.poi.extention.XSSFCellStyleRule;
import com.ld.datacenter.poi.helper.CellStyle;
package com.ld.datacenter.poi.extention.impl;
public class XSSFCellStyleRuleImpl implements XSSFCellStyleRule{
@Override
public void registerStyleRule(CellStyle k, XSSFCellStyle v, | XSSFCellStyleLib lib) { |
gp15237125756/PoiExcelExport2.0 | annotation/ExcelEntity.java | // Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.annotation;
/**
* 标记实体为Excel实体
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ExcelEntity {
/**
* 年度位置
*/
int[] yrPos() default 0;
<<<<<<< HEAD
/**
*
* 年度格子样式
*/ | // Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: annotation/ExcelEntity.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.annotation;
/**
* 标记实体为Excel实体
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ExcelEntity {
/**
* 年度位置
*/
int[] yrPos() default 0;
<<<<<<< HEAD
/**
*
* 年度格子样式
*/ | CellStyle yrCellStyle() default CellStyle.NONE; |
gp15237125756/PoiExcelExport2.0 | annotation/ExcelEntity.java | // Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.annotation;
/**
* 标记实体为Excel实体
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ExcelEntity {
/**
* 年度位置
*/
int[] yrPos() default 0;
<<<<<<< HEAD
/**
*
* 年度格子样式
*/
CellStyle yrCellStyle() default CellStyle.NONE;
/**
* 年度格子字体
*/ | // Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: annotation/ExcelEntity.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.annotation;
/**
* 标记实体为Excel实体
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ExcelEntity {
/**
* 年度位置
*/
int[] yrPos() default 0;
<<<<<<< HEAD
/**
*
* 年度格子样式
*/
CellStyle yrCellStyle() default CellStyle.NONE;
/**
* 年度格子字体
*/ | FontStyle yrFontStyle() default FontStyle.NONE; |
gp15237125756/PoiExcelExport2.0 | convert/FontStyleConvert.java | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: convert/FontStyleConvert.java
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override | public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { |
gp15237125756/PoiExcelExport2.0 | convert/FontStyleConvert.java | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: convert/FontStyleConvert.java
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override | public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { |
gp15237125756/PoiExcelExport2.0 | convert/FontStyleConvert.java | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: convert/FontStyleConvert.java
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override | public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { |
gp15237125756/PoiExcelExport2.0 | convert/FontStyleConvert.java | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override
public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: convert/FontStyleConvert.java
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override
public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { | XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); |
gp15237125756/PoiExcelExport2.0 | convert/FontStyleConvert.java | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override
public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: extention/impl/XSSFFontStyleRuleImpl.java
// public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
//
// @Override
// public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) {
// lib.addStyle(k, v);
// }
//
// @Override
// public void removeStyleRule(FontStyle k, XSSFFontStyleLib lib) {
// lib.removeStyle(k);
// }
//
//
//
//
//
//
//
// }
//
// Path: font/IFontFactory.java
// public interface IFontFactory {
//
// /**
// * @param wb
// * @return {@code XSSFFont}
// */
// XSSFFont create();
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: convert/FontStyleConvert.java
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.extention.impl.XSSFFontStyleRuleImpl;
import com.ld.datacenter.poi.font.IFontFactory;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.convert;
public class FontStyleConvert implements IFontStyleConvert {
@Override
public void convert(FontStyle style, IFontFactory fac,XSSFFontStyleLib lib) { | XSSFFontStyleRule rule=new XSSFFontStyleRuleImpl(); |
gp15237125756/PoiExcelExport2.0 | extention/XSSFCellStyleLib.java | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl; | package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/ | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
// Path: extention/XSSFCellStyleLib.java
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl;
package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/ | private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>(); |
gp15237125756/PoiExcelExport2.0 | extention/XSSFCellStyleLib.java | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl; | package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb; | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
// Path: extention/XSSFCellStyleLib.java
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl;
package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb; | ICellStyleConvert convert=new CellStyleConvert(); |
gp15237125756/PoiExcelExport2.0 | extention/XSSFCellStyleLib.java | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl; | package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb; | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
// Path: extention/XSSFCellStyleLib.java
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl;
package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb; | ICellStyleConvert convert=new CellStyleConvert(); |
gp15237125756/PoiExcelExport2.0 | extention/XSSFCellStyleLib.java | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl; | package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb;
ICellStyleConvert convert=new CellStyleConvert();
//添加cell樣式 | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
// Path: extention/XSSFCellStyleLib.java
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl;
package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb;
ICellStyleConvert convert=new CellStyleConvert();
//添加cell樣式 | convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this); |
gp15237125756/PoiExcelExport2.0 | extention/XSSFCellStyleLib.java | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl; | package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb;
ICellStyleConvert convert=new CellStyleConvert();
//添加cell樣式
convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this);
convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
// Path: extention/XSSFCellStyleLib.java
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl;
package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb;
ICellStyleConvert convert=new CellStyleConvert();
//添加cell樣式
convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this);
convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this); | convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this); |
gp15237125756/PoiExcelExport2.0 | extention/XSSFCellStyleLib.java | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
| import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl; | package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb;
ICellStyleConvert convert=new CellStyleConvert();
//添加cell樣式
convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this);
convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this);
convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this);
<<<<<<< HEAD
convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this);
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
}
public void addStyle(CellStyle k,XSSFCellStyle v){
CELL_STYLE_MAP.put(k, v);
}
public void removeStyle(CellStyle k){
CELL_STYLE_MAP.remove(k);
}
public XSSFCellStyle get(CellStyle k){
XSSFCellStyle v=CELL_STYLE_MAP.get(k);
if(null==v){ | // Path: convert/CellStyleConvert.java
// public class CellStyleConvert implements ICellStyleConvert {
// @Override
// public void convert(CellStyle k, ICellStyleFactory v,XSSFCellStyleLib lib) {
// <<<<<<< HEAD
// =======
// // TODO Auto-generated method stub
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// XSSFCellStyleRule rule=new XSSFCellStyleRuleImpl();
// rule.registerStyleRule(k, v.create(),lib);
// }
//
// }
//
// Path: convert/ICellStyleConvert.java
// public interface ICellStyleConvert {
//
// void convert(CellStyle style,ICellStyleFactory fac,XSSFCellStyleLib lib);
// }
//
// Path: exception/CellStyleNotFoundException.java
// public class CellStyleNotFoundException extends RuntimeException{
//
// private static final long serialVersionUID = 1845298831506720372L;
//
// public CellStyleNotFoundException(){
// super();
// }
//
//
// public CellStyleNotFoundException(String message){
// super(message);
// }
//
// public CellStyleNotFoundException(Throwable Throwable){
// super(Throwable);
// }
//
// public CellStyleNotFoundException(String message,Throwable cause){
// super(message,cause);
// }
//
// public CellStyleNotFoundException(Class<?> cls,String message){
// super("entity ["+cls.getName()+"] "+message);
// }
// }
//
// Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: style/DefaultCellStyleImpl.java
// public class DefaultCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public DefaultCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
//
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createXSSFCellStyle(this.wb);
// }
//
// }
//
// Path: style/TextCellStyleImpl.java
// public class TextCellStyleImpl implements ICellStyleFactory {
//
// private XSSFWorkbook wb;
//
// public TextCellStyleImpl(XSSFWorkbook wb){
// this.wb=wb;
// }
// @Override
// public XSSFCellStyle create() {
// return XSSFCellUtil.createCenterXSSFCellStyle(this.wb);
// }
//
// }
// Path: extention/XSSFCellStyleLib.java
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.ld.datacenter.poi.convert.CellStyleConvert;
import com.ld.datacenter.poi.convert.ICellStyleConvert;
import com.ld.datacenter.poi.exception.CellStyleNotFoundException;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.style.DefaultCellStyleImpl;
import com.ld.datacenter.poi.style.TextCellStyleImpl;
package com.ld.datacenter.poi.extention;
<<<<<<< HEAD
import com.ld.datacenter.poi.style.TitleCellStyleImpl;
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
/**
* 定義cell樣式庫,可以動態追加
* @author Cruz
* @version 01-00
* @Date 2017/3/31 13:22
*/
public class XSSFCellStyleLib {
/** 樣式緩存*/
private final Map<CellStyle,XSSFCellStyle> CELL_STYLE_MAP=new LinkedHashMap<CellStyle, XSSFCellStyle>();
<<<<<<< HEAD
@SuppressWarnings("unused")
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
private final XSSFWorkbook wb;
public XSSFCellStyleLib(XSSFWorkbook wb){
this.wb=wb;
ICellStyleConvert convert=new CellStyleConvert();
//添加cell樣式
convert.convert(CellStyle.NONE, new DefaultCellStyleImpl(wb),this);
convert.convert(CellStyle.DEFAULT, new DefaultCellStyleImpl(wb),this);
convert.convert(CellStyle.STANDARD, new TextCellStyleImpl(wb),this);
<<<<<<< HEAD
convert.convert(CellStyle.TITLE, new TitleCellStyleImpl(wb),this);
=======
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
}
public void addStyle(CellStyle k,XSSFCellStyle v){
CELL_STYLE_MAP.put(k, v);
}
public void removeStyle(CellStyle k){
CELL_STYLE_MAP.remove(k);
}
public XSSFCellStyle get(CellStyle k){
XSSFCellStyle v=CELL_STYLE_MAP.get(k);
if(null==v){ | throw new CellStyleNotFoundException("the cell style have not been defined!"); |
gp15237125756/PoiExcelExport2.0 | extention/impl/XSSFFontStyleRuleImpl.java | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import org.apache.poi.xssf.usermodel.XSSFFont;
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.extention.impl;
public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
@Override | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: extention/impl/XSSFFontStyleRuleImpl.java
import org.apache.poi.xssf.usermodel.XSSFFont;
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.extention.impl;
public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
@Override | public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) { |
gp15237125756/PoiExcelExport2.0 | extention/impl/XSSFFontStyleRuleImpl.java | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
| import org.apache.poi.xssf.usermodel.XSSFFont;
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.helper.FontStyle; | package com.ld.datacenter.poi.extention.impl;
public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
@Override | // Path: extention/XSSFFontStyleLib.java
// public class XSSFFontStyleLib {
//
// /** 樣式緩存*/
// private final Map<FontStyle,XSSFFont> FONT_STYLE_MAP=new LinkedHashMap<FontStyle, XSSFFont>();
//
// <<<<<<< HEAD
// @SuppressWarnings("unused")
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// private final XSSFWorkbook wb;
//
// public XSSFFontStyleLib(XSSFWorkbook wb){
// this.wb=wb;
// IFontStyleConvert convert=new FontStyleConvert();
// //添加cell樣式
// convert.convert(FontStyle.NONE, new DefaultCellFontImpl(wb),this);
// convert.convert(FontStyle.DEFAULT, new DefaultCellFontImpl(wb),this);
// <<<<<<< HEAD
// convert.convert(FontStyle.TITLE, new TitleCellFontImpl(wb),this);
// =======
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// convert.convert(FontStyle.COLOR, new ColorCellFontImpl(wb),this);
// }
//
// public void addStyle(FontStyle k,XSSFFont v){
// FONT_STYLE_MAP.put(k, v);
// }
//
// public void removeStyle(FontStyle k){
// FONT_STYLE_MAP.remove(k);
// }
//
// public XSSFFont get(FontStyle k){
// XSSFFont v=FONT_STYLE_MAP.get(k);
// if(null==v){
// throw new FontStyleNotFoundException("the font style have not been defined!");
// }
// return v;
// }
//
// public void clear(){
// FONT_STYLE_MAP.clear();
// }
// }
//
// Path: extention/XSSFFontStyleRule.java
// public interface XSSFFontStyleRule {
// /**
// * 註冊字體
// */
// void registerStyleRule(FontStyle k,XSSFFont v,XSSFFontStyleLib lib);
// /**
// * 移除字體
// */
// void removeStyleRule(FontStyle k,XSSFFontStyleLib lib);
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
// Path: extention/impl/XSSFFontStyleRuleImpl.java
import org.apache.poi.xssf.usermodel.XSSFFont;
import com.ld.datacenter.poi.extention.XSSFFontStyleLib;
import com.ld.datacenter.poi.extention.XSSFFontStyleRule;
import com.ld.datacenter.poi.helper.FontStyle;
package com.ld.datacenter.poi.extention.impl;
public class XSSFFontStyleRuleImpl implements XSSFFontStyleRule {
@Override | public void registerStyleRule(FontStyle k, XSSFFont v, XSSFFontStyleLib lib) { |
gp15237125756/PoiExcelExport2.0 | annotation/RenderDirection.java | // Path: helper/RenderStyle.java
// public enum RenderStyle {
// HORIZATION,VERTICAL
// }
| import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ld.datacenter.poi.helper.RenderStyle; | package com.ld.datacenter.poi.annotation;
/**
* 标记数据填充渲染方向
* (1)从左到右
* (2)从上到下
* 默认(1)方式
* 类级别注解
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RenderDirection {
/**
* 年度位置
*/ | // Path: helper/RenderStyle.java
// public enum RenderStyle {
// HORIZATION,VERTICAL
// }
// Path: annotation/RenderDirection.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ld.datacenter.poi.helper.RenderStyle;
package com.ld.datacenter.poi.annotation;
/**
* 标记数据填充渲染方向
* (1)从左到右
* (2)从上到下
* 默认(1)方式
* 类级别注解
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RenderDirection {
/**
* 年度位置
*/ | RenderStyle value() default RenderStyle.HORIZATION; |
gp15237125756/PoiExcelExport2.0 | TempUserPreference.java | // Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/RenderStyle.java
// public enum RenderStyle {
// HORIZATION,VERTICAL
// }
| import com.ld.datacenter.poi.annotation.EntityAttribute;
import com.ld.datacenter.poi.annotation.ExcelEntity;
import com.ld.datacenter.poi.annotation.RenderDirection;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.helper.FontStyle;
import com.ld.datacenter.poi.helper.RenderStyle; | package com.ld.datacenter.template.guide;
/**
* 用户喜好模板
* @author Cruz
* @Date 2017/4/27
* @version 01-00
*/
@ExcelEntity(row=1)
@RenderDirection(RenderStyle.HORIZATION)
public class TempUserPreference { | // Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/RenderStyle.java
// public enum RenderStyle {
// HORIZATION,VERTICAL
// }
// Path: TempUserPreference.java
import com.ld.datacenter.poi.annotation.EntityAttribute;
import com.ld.datacenter.poi.annotation.ExcelEntity;
import com.ld.datacenter.poi.annotation.RenderDirection;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.helper.FontStyle;
import com.ld.datacenter.poi.helper.RenderStyle;
package com.ld.datacenter.template.guide;
/**
* 用户喜好模板
* @author Cruz
* @Date 2017/4/27
* @version 01-00
*/
@ExcelEntity(row=1)
@RenderDirection(RenderStyle.HORIZATION)
public class TempUserPreference { | @EntityAttribute(columnName="70后艺术",required=true,col=2,row={3},merge=false,broken=false,cellStyle=CellStyle.STANDARD,fontStyle=FontStyle.COLOR) |
gp15237125756/PoiExcelExport2.0 | TempUserPreference.java | // Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/RenderStyle.java
// public enum RenderStyle {
// HORIZATION,VERTICAL
// }
| import com.ld.datacenter.poi.annotation.EntityAttribute;
import com.ld.datacenter.poi.annotation.ExcelEntity;
import com.ld.datacenter.poi.annotation.RenderDirection;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.helper.FontStyle;
import com.ld.datacenter.poi.helper.RenderStyle; | package com.ld.datacenter.template.guide;
/**
* 用户喜好模板
* @author Cruz
* @Date 2017/4/27
* @version 01-00
*/
@ExcelEntity(row=1)
@RenderDirection(RenderStyle.HORIZATION)
public class TempUserPreference { | // Path: helper/CellStyle.java
// public enum CellStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,STANDARD
// =======
// NONE,DEFAULT,STANDARD
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/FontStyle.java
// public enum FontStyle {
// <<<<<<< HEAD
// NONE,DEFAULT,TITLE,COLOR
// =======
// NONE,DEFAULT,COLOR
// >>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
// }
//
// Path: helper/RenderStyle.java
// public enum RenderStyle {
// HORIZATION,VERTICAL
// }
// Path: TempUserPreference.java
import com.ld.datacenter.poi.annotation.EntityAttribute;
import com.ld.datacenter.poi.annotation.ExcelEntity;
import com.ld.datacenter.poi.annotation.RenderDirection;
import com.ld.datacenter.poi.helper.CellStyle;
import com.ld.datacenter.poi.helper.FontStyle;
import com.ld.datacenter.poi.helper.RenderStyle;
package com.ld.datacenter.template.guide;
/**
* 用户喜好模板
* @author Cruz
* @Date 2017/4/27
* @version 01-00
*/
@ExcelEntity(row=1)
@RenderDirection(RenderStyle.HORIZATION)
public class TempUserPreference { | @EntityAttribute(columnName="70后艺术",required=true,col=2,row={3},merge=false,broken=false,cellStyle=CellStyle.STANDARD,fontStyle=FontStyle.COLOR) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.